[BACK]Return to dist.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / engine

Diff for /OpenXM_contrib2/asir2000/engine/dist.c between version 1.24 and 1.27

version 1.24, 2003/06/19 07:08:19 version 1.27, 2004/02/03 23:31:57
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.23 2003/05/28 07:32:32 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.26 2003/08/22 08:14:45 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
   
Line 72  int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_
Line 72  int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_
 int do_weyl;  int do_weyl;
   
 int dp_nelim,dp_fcoeffs;  int dp_nelim,dp_fcoeffs;
 struct order_spec dp_current_spec;  struct order_spec *dp_current_spec;
 int *dp_dl_work;  int *dp_dl_work;
   
 void comm_muld_trunc(VL vl,DP p1,DP p2,DL dl,DP *pr);  void comm_muld_trunc(VL vl,DP p1,DP p2,DL dl,DP *pr);
Line 151  void initd(struct order_spec *spec)
Line 151  void initd(struct order_spec *spec)
                         }                          }
                         break;                          break;
         }          }
         dp_current_spec = *spec;          dp_current_spec = spec;
 }  }
   
 void ptod(VL vl,VL dvl,P p,DP *pr)  void ptod(VL vl,VL dvl,P p,DP *pr)
Line 385  void symb_addd(DP p1,DP p2,DP *pr)
Line 385  void symb_addd(DP p1,DP p2,DP *pr)
 NODE symb_merge(NODE m1,NODE m2,int n)  NODE symb_merge(NODE m1,NODE m2,int n)
 {  {
         NODE top,prev,cur,m,t;          NODE top,prev,cur,m,t;
           int c,i;
           DL d1,d2;
   
         if ( !m1 )          if ( !m1 )
                 return m2;                  return m2;
Line 405  NODE symb_merge(NODE m1,NODE m2,int n)
Line 407  NODE symb_merge(NODE m1,NODE m2,int n)
                 prev = top; cur = NEXT(top);                  prev = top; cur = NEXT(top);
                 /* BDY(prev) > BDY(m) always holds */                  /* BDY(prev) > BDY(m) always holds */
                 while ( cur && m ) {                  while ( cur && m ) {
                           d1 = (DL)BDY(cur);
                           d2 = (DL)BDY(m);
   #if 1
                         switch ( (*cmpdl)(n,(DL)BDY(cur),(DL)BDY(m)) ) {                          switch ( (*cmpdl)(n,(DL)BDY(cur),(DL)BDY(m)) ) {
   #else
                           /* XXX only valid for DRL */
                           if ( d1->td > d2->td )
                                   c = 1;
                           else if ( d1->td < d2->td )
                                   c = -1;
                           else {
                                   for ( i = n-1; i >= 0 && d1->d[i] == d2->d[i]; i-- );
                                   if ( i < 0 )
                                           c = 0;
                                   else if ( d1->d[i] < d2->d[i] )
                                           c = 1;
                                   else
                                           c = -1;
                           }
                           switch ( c ) {
   #endif
                                 case 0:                                  case 0:
                                         m = NEXT(m);                                          m = NEXT(m);
                                         prev = cur; cur = NEXT(cur);                                          prev = cur; cur = NEXT(cur);
Line 1114  int cmpdl_gradlex(int n,DL d1,DL d2)
Line 1136  int cmpdl_gradlex(int n,DL d1,DL d2)
   
 int cmpdl_revgradlex(int n,DL d1,DL d2)  int cmpdl_revgradlex(int n,DL d1,DL d2)
 {  {
         register int i;          register int i,c;
         register int *p1,*p2;          register int *p1,*p2;
   
         if ( d1->td > d2->td )          if ( d1->td > d2->td )
Line 1122  int cmpdl_revgradlex(int n,DL d1,DL d2)
Line 1144  int cmpdl_revgradlex(int n,DL d1,DL d2)
         else if ( d1->td < d2->td )          else if ( d1->td < d2->td )
                 return -1;                  return -1;
         else {          else {
                 for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1;                  i = n-1;
                         i >= 0 && *p1 == *p2; i--, p1--, p2-- );                  p1 = d1->d+n-1;
                 return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1);                  p2 = d2->d+n-1;
                   while ( i >= 7 ) {
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           c = (*p1--) - (*p2--); if ( c ) goto LAST;
                           i -= 8;
                   }
                   switch ( i ) {
                           case 6:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 5:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 4:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 3:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 2:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 1:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           case 0:
                                   c = (*p1--) - (*p2--); if ( c ) goto LAST;
                                   return 0;
                           default:
                                   return 0;
                   }
   LAST:
                   if ( c > 0 ) return -1;
                   else return 1;
         }          }
 }  }
   
Line 1385  int cmpdl_order_pair(int n,DL d1,DL d2)
Line 1467  int cmpdl_order_pair(int n,DL d1,DL d2)
         int len,head;          int len,head;
         struct order_pair *pair;          struct order_pair *pair;
   
         len = dp_current_spec.ord.block.length;          len = dp_current_spec->ord.block.length;
         pair = dp_current_spec.ord.block.order_pair;          pair = dp_current_spec->ord.block.order_pair;
   
         head = 0;          head = 0;
         for ( i = 0, t1 = d1->d, t2 = d2->d; i < len; i++ ) {          for ( i = 0, t1 = d1->d, t2 = d2->d; i < len; i++ ) {
Line 1443  int cmpdl_matrix(int n,DL d1,DL d2)
Line 1525  int cmpdl_matrix(int n,DL d1,DL d2)
   
         for ( i = 0, t1 = d1->d, t2 = d2->d, w = dp_dl_work; i < n; i++ )          for ( i = 0, t1 = d1->d, t2 = d2->d, w = dp_dl_work; i < n; i++ )
                 w[i] = t1[i]-t2[i];                  w[i] = t1[i]-t2[i];
         len = dp_current_spec.ord.matrix.row;          len = dp_current_spec->ord.matrix.row;
         matrix = dp_current_spec.ord.matrix.matrix;          matrix = dp_current_spec->ord.matrix.matrix;
         for ( j = 0; j < len; j++ ) {          for ( j = 0; j < len; j++ ) {
                 v = matrix[j];                  v = matrix[j];
                 for ( i = 0, s = 0; i < n; i++ )                  for ( i = 0, s = 0; i < n; i++ )
Line 1455  int cmpdl_matrix(int n,DL d1,DL d2)
Line 1537  int cmpdl_matrix(int n,DL d1,DL d2)
                         return -1;                          return -1;
         }          }
         return 0;          return 0;
   }
   
   GeoBucket create_bucket()
   {
           GeoBucket g;
   
           g = CALLOC(1,sizeof(struct oGeoBucket));
           g->m = 32;
           return g;
   }
   
   void add_bucket(GeoBucket g,NODE d,int nv)
   {
           int l,k,m;
   
           l = length(d);
           for ( k = 0, m = 1; l > m; k++, m <<= 1 );
           /* 2^(k-1) < l <= 2^k */
           d = symb_merge(g->body[k],d,nv);
           for ( ; length(d) > (1<<(k)); k++ ) {
                   g->body[k] = 0;
                   d = symb_merge(g->body[k+1],d,nv);
           }
           g->body[k] = d;
           g->m = MAX(g->m,k);
   }
   
   DL remove_head_bucket(GeoBucket g,int nv)
   {
           int j,i,c,m;
           DL d;
   
           j = -1;
           m = g->m;
           for ( i = 0; i <= m; i++ ) {
                   if ( !g->body[i] )
                           continue;
                   if ( j < 0 ) j = i;
                   else {
                           c = (*cmpdl)(nv,g->body[i]->body,g->body[j]->body);
                           if ( c > 0 )
                                   j = i;
                           else if ( c == 0 )
                                   g->body[i] = NEXT(g->body[i]);
                   }
           }
           if ( j < 0 )
                   return 0;
           else {
                   d = g->body[j]->body;
                   g->body[j] = NEXT(g->body[j]);
                   return d;
           }
 }  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.27

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>