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

Diff for /OpenXM_contrib2/asir2000/engine/nd.c between version 1.34 and 1.39

version 1.34, 2003/08/20 06:06:07 version 1.39, 2003/08/21 03:13:01
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.33 2003/08/19 05:29:11 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.38 2003/08/20 08:56:29 noro Exp $ */
   
 #include "ca.h"  #include "ca.h"
 #include "inline.h"  #include "inline.h"
Line 165  void removecont_array(Q *c,int n);
Line 165  void removecont_array(Q *c,int n);
 ND_pairs crit_B( ND_pairs d, int s );  ND_pairs crit_B( ND_pairs d, int s );
 void nd_gr(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp);  void nd_gr(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp);
 void nd_gr_trace(LIST f,LIST v,int m,int homo,struct order_spec *ord,LIST *rp);  void nd_gr_trace(LIST f,LIST v,int m,int homo,struct order_spec *ord,LIST *rp);
 void nd_setup(int mod,NODE f);  void nd_setup(int mod,int trace,NODE f);
 void nd_setup_trace(int mod,NODE f);  int nd_newps(int mod,ND a,ND aq);
 int nd_newps(int mod,ND a);  
 int nd_newps_trace(int mod,ND nf,ND nfq);  
 ND_pairs nd_minp( ND_pairs d, ND_pairs *prest );  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest );
 NODE update_base(NODE nd,int ndp);  NODE update_base(NODE nd,int ndp);
 static ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *prest );  static ND_pairs equivalent_pairs( ND_pairs d1, ND_pairs *prest );
Line 182  NODE nd_gb_trace(int m);
Line 180  NODE nd_gb_trace(int m);
 void nd_free_private_storage();  void nd_free_private_storage();
 void _NM_alloc();  void _NM_alloc();
 void _ND_alloc();  void _ND_alloc();
 int ndl_td(unsigned int *d);  int ndl_weight(unsigned int *d);
 void ndl_dehomogenize(unsigned int *p);  void ndl_dehomogenize(unsigned int *p);
 ND nd_add(int mod,ND p1,ND p2);  ND nd_add(int mod,ND p1,ND p2);
 ND nd_add_q(ND p1,ND p2);  ND nd_add_q(ND p1,ND p2);
Line 288  INLINE int nd_length(ND p)
Line 286  INLINE int nd_length(ND p)
         }          }
 }  }
   
 int ndl_reducible(unsigned int *d1,unsigned int *d2)  INLINE int ndl_reducible(unsigned int *d1,unsigned int *d2)
 {  {
         unsigned int u1,u2;          unsigned int u1,u2;
         int i,j;          int i,j;
Line 372  void ndl_dehomogenize(unsigned int *d)
Line 370  void ndl_dehomogenize(unsigned int *d)
                         h = (d[1]>>((nd_epw-1)*nd_bpe))&nd_mask0;                          h = (d[1]>>((nd_epw-1)*nd_bpe))&nd_mask0;
                         for ( i = 1; i <= nd_wpd; i++ )                          for ( i = 1; i <= nd_wpd; i++ )
                                 d[i] = ((d[i]<<nd_bpe)&mask)                                  d[i] = ((d[i]<<nd_bpe)&mask)
                                         |(i+1<nd_wpd?((d[i+1]>>((nd_epw-1)*nd_bpe))&nd_mask0):0);                                          |(i+1<=nd_wpd?((d[i+1]>>((nd_epw-1)*nd_bpe))&nd_mask0):0);
                         TD(d) -= h;                          TD(d) -= h;
                 }                  }
         } else          } else
Line 445  void ndl_lcm(unsigned int *d1,unsigned *d2,unsigned in
Line 443  void ndl_lcm(unsigned int *d1,unsigned *d2,unsigned in
                         }                          }
                         break;                          break;
         }          }
         TD(d) = ndl_td(d);          TD(d) = ndl_weight(d);
 }  }
   
 int ndl_td(unsigned int *d)  int ndl_weight(unsigned int *d)
 {  {
         unsigned int t,u;          unsigned int t,u;
         int i,j;          int i,j;
Line 505  INLINE void ndl_copy(unsigned int *d1,unsigned int *d2
Line 503  INLINE void ndl_copy(unsigned int *d1,unsigned int *d2
         }          }
 }  }
   
 /* XXX : TD is not added */  
   
 INLINE void ndl_add(unsigned int *d1,unsigned int *d2,unsigned int *d)  INLINE void ndl_add(unsigned int *d1,unsigned int *d2,unsigned int *d)
 {  {
         int i;          int i;
   
           TD(d) = TD(d1)+TD(d2);
         switch ( nd_wpd ) {          switch ( nd_wpd ) {
                 case 1:                  case 1:
                         d[1] = d1[1]+d2[1];                          d[1] = d1[1]+d2[1];
Line 755  INLINE int nd_find_reducer(ND g)
Line 752  INLINE int nd_find_reducer(ND g)
         int d,k,i;          int d,k,i;
   
         dg = HDL(g);          dg = HDL(g);
   #if 1
         d = ndl_hash_value(HDL(g));          d = ndl_hash_value(HDL(g));
         for ( r = nd_red[d], k = 0; r; r = NEXT(r), k++ ) {          for ( r = nd_red[d], k = 0; r; r = NEXT(r), k++ ) {
                 if ( ndl_equal(dg,DL(r)) ) {                  if ( ndl_equal(dg,DL(r)) ) {
Line 763  INLINE int nd_find_reducer(ND g)
Line 761  INLINE int nd_find_reducer(ND g)
                         return r->index;                          return r->index;
                 }                  }
         }          }
   #endif
         if ( Reverse )          if ( Reverse )
                 for ( i = nd_psn-1; i >= 0; i-- ) {                  for ( i = nd_psn-1; i >= 0; i-- ) {
                         r = nd_psh[i];                          r = nd_psh[i];
Line 1250  int nd_check_candidate(NODE input,NODE cand)
Line 1249  int nd_check_candidate(NODE input,NODE cand)
         ND nf,d;          ND nf,d;
         NODE t;          NODE t;
   
         nd_setup(0,cand);          nd_setup(0,0,cand);
         n = length(cand);          n = length(cand);
   
         /* membercheck : list is a subset of Id(cand) ? */          /* membercheck : list is a subset of Id(cand) ? */
Line 1459  again:
Line 1458  again:
                 } else if ( nf ) {                  } else if ( nf ) {
                         if ( checkonly ) return 0;                          if ( checkonly ) return 0;
                         printf("+"); fflush(stdout);                          printf("+"); fflush(stdout);
                         nh = nd_newps(m,nf);                          nh = m?nd_newps(m,nf,0):nd_newps(m,0,nf);
                         d = update_pairs(d,g,nh);                          d = update_pairs(d,g,nh);
                         g = update_base(g,nh);                          g = update_base(g,nh);
                         FREENDP(l);                          FREENDP(l);
Line 1513  again:
Line 1512  again:
                         nd_nf(0,h,!Top,&nfq);                          nd_nf(0,h,!Top,&nfq);
                         if ( nfq ) {                          if ( nfq ) {
                                 printf("+"); fflush(stdout);                                  printf("+"); fflush(stdout);
                                 nh = nd_newps_trace(m,nf,nfq);                                  nh = nd_newps(m,nf,nfq);
                                 /* failure; m|HC(nfq) */                                  /* failure; m|HC(nfq) */
                                 if ( nf < 0 ) return 0;                                  if ( nh < 0 ) return 0;
                                 d = update_pairs(d,g,nh);                                  d = update_pairs(d,g,nh);
                                 g = update_base(g,nh);                                  g = update_base(g,nh);
                         } else {                          } else {
Line 1763  static ND_pairs equivalent_pairs( ND_pairs d1, ND_pair
Line 1762  static ND_pairs equivalent_pairs( ND_pairs d1, ND_pair
         for ( r = 0; s; s = p ) {          for ( r = 0; s; s = p ) {
                 p = NEXT(s);                  p = NEXT(s);
                 if ( ndl_equal(d,LCM(s)) ) {                  if ( ndl_equal(d,LCM(s)) ) {
                         NEXT(s) = w;                          NEXT(s) = w; w = s;
                         w = s;  
                 } else {                  } else {
                         NEXT(s) = r;                          NEXT(s) = r; r = s;
                         r = s;  
                 }                  }
         }          }
         *prest = r;          *prest = r;
Line 1809  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest )
Line 1806  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest )
         for ( ml = 0, l = m; p; p = NEXT(l = p) )          for ( ml = 0, l = m; p; p = NEXT(l = p) )
                 if ( (SG(p) < s)                  if ( (SG(p) < s)
                         || ((SG(p) == s) && (DL_COMPARE(LCM(p),LCM(m)) < 0)) ) {                          || ((SG(p) == s) && (DL_COMPARE(LCM(p),LCM(m)) < 0)) ) {
                         ml = l;                          ml = l; m = p; s = SG(m);
                         m = p;  
                         s = SG(m);  
                 }                  }
         if ( !ml ) *prest = NEXT(m);          if ( !ml ) *prest = NEXT(m);
         else {          else {
Line 1822  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest )
Line 1817  ND_pairs nd_minp( ND_pairs d, ND_pairs *prest )
         return m;          return m;
 }  }
   
 int nd_newps(int mod,ND a)  int nd_newps(int mod,ND a,ND aq)
 {  {
         int len;          int len;
         RHist r;          RHist r;
Line 1836  int nd_newps(int mod,ND a)
Line 1831  int nd_newps(int mod,ND a)
                 nd_bound = (unsigned int **)                  nd_bound = (unsigned int **)
                         REALLOC((char *)nd_bound,nd_pslen*sizeof(unsigned int *));                          REALLOC((char *)nd_bound,nd_pslen*sizeof(unsigned int *));
         }          }
         nd_removecont(mod,a);          if ( a && aq ) {
         nd_bound[nd_psn] = nd_compute_bound(a);                  /* trace lifting */
         NEWRHist(r); SG(r) = SG(a); ndl_copy(HDL(a),DL(r));                  if ( !rem(NM(HCQ(aq)),mod) ) return -1;
         nd_psh[nd_psn] = r;  
         b = ndtondv(mod,a);  
         len = LEN(b);  
         if ( mod )  
                 nd_ps[nd_psn] = b;  
         else  
                 nd_psq[nd_psn] = b;  
         nd_free(a);  
         return nd_psn++;  
 }  
   
 int nd_newps_trace(int mod,ND nf,ND nfq)  
 {  
         int len;  
         RHist r;  
         NDV b;  
   
         if ( nd_psn == nd_pslen ) {  
                 nd_pslen *= 2;  
                 nd_ps = (NDV *)REALLOC((char *)nd_ps,nd_pslen*sizeof(NDV));  
                 nd_psq = (NDV *)REALLOC((char *)nd_psq,nd_pslen*sizeof(NDV));  
                 nd_psh = (RHist *)REALLOC((char *)nd_psh,nd_pslen*sizeof(RHist));  
                 nd_bound = (unsigned int **)  
                         REALLOC((char *)nd_bound,nd_pslen*sizeof(unsigned int *));  
         }          }
         if ( !rem(NM(HCQ(nfq)),mod) ) return -1;          NEWRHist(r); nd_psh[nd_psn] = r;
         nd_removecont(mod,nf);          if ( aq ) {
         nd_ps[nd_psn] = ndtondv(mod,nf);                  nd_removecont(0,aq);
                   nd_psq[nd_psn] = ndtondv(0,aq);
         nd_removecont(0,nfq);                  nd_bound[nd_psn] = nd_compute_bound(aq);
         nd_psq[nd_psn] = ndtondv(0,nfq);                  SG(r) = SG(aq); ndl_copy(HDL(aq),DL(r));
   
         nd_bound[nd_psn] = nd_compute_bound(nfq);  
         NEWRHist(r); SG(r) = SG(nf); ndl_copy(HDL(nf),DL(r));  
         nd_psh[nd_psn] = r;  
         nd_free(nf); nd_free(nfq);  
         return nd_psn++;  
 }  
   
 void nd_setup(int mod,NODE f)  
 {  
         int i,j,td,len,max;  
         NODE s,s0,f0;  
         unsigned int *d;  
         RHist r;  
         NDV a;  
   
         nd_found = 0; nd_notfirst = 0; nd_create = 0;  
   
         nd_psn = length(f); nd_pslen = 2*nd_psn;  
         nd_ps = (NDV *)MALLOC(nd_pslen*sizeof(NDV));  
         nd_psq = (NDV *)MALLOC(nd_pslen*sizeof(NDV));  
         nd_psh = (RHist *)MALLOC(nd_pslen*sizeof(RHist));  
         nd_bound = (unsigned int **)MALLOC(nd_pslen*sizeof(unsigned int *));  
         for ( max = 0, i = 0, s = f; i < nd_psn; i++, s = NEXT(s) ) {  
                 nd_bound[i] = d = dp_compute_bound((DP)BDY(s));  
                 for ( j = 0; j < nd_nvar; j++ )  
                         max = MAX(d[j],max);  
         }          }
         if ( !nd_red )          if ( a ) {
                 nd_red = (RHist *)MALLOC(REDTAB_LEN*sizeof(RHist));                  nd_removecont(mod,a);
         bzero(nd_red,REDTAB_LEN*sizeof(RHist));                  nd_ps[nd_psn] = ndtondv(mod,a);
                   if ( !aq ) {
         if ( max < 2 ) nd_bpe = 2;                          nd_bound[nd_psn] = nd_compute_bound(a);
         else if ( max < 4 ) nd_bpe = 4;                          SG(r) = SG(a); ndl_copy(HDL(a),DL(r));
         else if ( max < 64 ) nd_bpe = 6;                  }
         else if ( max < 256 ) nd_bpe = 8;  
         else if ( max < 65536 ) nd_bpe = 16;  
         else nd_bpe = 32;  
   
         nd_setup_parameters();  
         nd_free_private_storage();  
         len = 0;  
         for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) {  
                 NEWRHist(r);  
                 a = dptondv(mod,(DP)BDY(f));  
                 ndv_removecont(mod,a);  
                 len = MAX(len,LEN(a));  
                 SG(r) = HTD(a); ndl_copy(HDL(a),DL(r));  
                 if ( mod ) nd_ps[i] = a;  
                 else nd_psq[i] = a;  
                 nd_psh[i] = r;  
         }          }
           nd_free(a); nd_free(aq);
           return nd_psn++;
 }  }
   
 void nd_setup_trace(int mod,NODE f)  void nd_setup(int mod,int trace,NODE f)
 {  {
         int i,j,td,len,max;          int i,j,td,len,max;
         NODE s,s0,f0;          NODE s,s0,f0;
Line 1957  void nd_setup_trace(int mod,NODE f)
Line 1887  void nd_setup_trace(int mod,NODE f)
   
         nd_setup_parameters();          nd_setup_parameters();
         nd_free_private_storage();          nd_free_private_storage();
         len = 0;  
         for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) {          for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) {
                 a = dptondv(mod,(DP)BDY(f)); ndv_removecont(mod,a); nd_ps[i] = a;  
                 a = dptondv(0,(DP)BDY(f)); ndv_removecont(0,a); nd_psq[i] = a;  
                 NEWRHist(r);                  NEWRHist(r);
                 len = MAX(len,LEN(a));                  a = dptondv(mod,(DP)BDY(f)); ndv_removecont(mod,a);
                 SG(r) = HTD(a); ndl_copy(HDL(a),DL(r));                  SG(r) = HTD(a); ndl_copy(HDL(a),DL(r));
   
                   if ( trace ) {
                           nd_ps[i] = a;
                           a = dptondv(0,(DP)BDY(f)); ndv_removecont(0,a);
                           nd_psq[i] = a;
                   } else {
                           if ( mod ) nd_ps[i] = a;
                           else nd_psq[i] = a;
                   }
                 nd_psh[i] = r;                  nd_psh[i] = r;
         }          }
 }  }
Line 1985  void nd_gr(LIST f,LIST v,int m,struct order_spec *ord,
Line 1921  void nd_gr(LIST f,LIST v,int m,struct order_spec *ord,
                 NEXTNODE(fd0,fd); BDY(fd) = (pointer)b;                  NEXTNODE(fd0,fd); BDY(fd) = (pointer)b;
         }          }
         if ( fd0 ) NEXT(fd) = 0;          if ( fd0 ) NEXT(fd) = 0;
         nd_setup(m,fd0);          nd_setup(m,0,fd0);
         x = nd_gb(m,0);          x = nd_gb(m,0);
         fprintf(asir_out,"found=%d,notfirst=%d,create=%d\n",          fprintf(asir_out,"found=%d,notfirst=%d,create=%d\n",
                 nd_found,nd_notfirst,nd_create);                  nd_found,nd_notfirst,nd_create);
Line 2041  void nd_gr_trace(LIST f,LIST v,int m,int homo,struct o
Line 1977  void nd_gr_trace(LIST f,LIST v,int m,int homo,struct o
                 nd_init_ord(ord);                  nd_init_ord(ord);
         }          }
         do {          do {
                 nd_setup_trace(m,fd0);                  nd_setup(m,1,fd0);
                 cand = nd_gb_trace(m);                  cand = nd_gb_trace(m);
                 if ( !cand ) continue;                  if ( !cand ) continue;
                 if ( homo ) {                  if ( homo ) {
Line 2078  void dltondl(int n,DL dl,unsigned int *r)
Line 2014  void dltondl(int n,DL dl,unsigned int *r)
         int i;          int i;
   
         d = dl->d;          d = dl->d;
         bzero(r,(nd_wpd+1)*sizeof(unsigned int));          for ( i = 0; i <= nd_wpd; i++ ) r[i] = 0;
         if ( nd_isrlex )          if ( nd_isrlex )
                 for ( i = 0; i < n; i++ )                  for ( i = 0; i < n; i++ )
                         r[(n-1-i)/nd_epw+1] |= (d[i]<<((nd_epw-((n-1-i)%nd_epw)-1)*nd_bpe));                          r[(n-1-i)/nd_epw+1] |= (d[i]<<((nd_epw-((n-1-i)%nd_epw)-1)*nd_bpe));
         else          else
                 for ( i = 0; i < n; i++ )                  for ( i = 0; i < n; i++ )
                         r[i/nd_epw+1] |= d[i]<<((nd_epw-(i%nd_epw)-1)*nd_bpe);                          r[i/nd_epw+1] |= d[i]<<((nd_epw-(i%nd_epw)-1)*nd_bpe);
         TD(r) = ndl_td(r);          TD(r) = ndl_weight(r);
 }  }
   
 DL ndltodl(int n,unsigned int *ndl)  DL ndltodl(int n,unsigned int *ndl)
Line 2409  unsigned int *dp_compute_bound(DP p)
Line 2345  unsigned int *dp_compute_bound(DP p)
         d1 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int));          d1 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int));
         d2 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int));          d2 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int));
         m = BDY(p);          m = BDY(p);
         bcopy(DL(m)->d,d1,nd_nvar*sizeof(unsigned int));          d = DL(m)->d;
           for ( i = 0; i < nd_nvar; i++ ) d1[i] = d[i];
         for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) {          for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) {
                 d = DL(m)->d;                  d = DL(m)->d;
                 for ( i = 0; i < nd_nvar; i++ )                  for ( i = 0; i < nd_nvar; i++ )
Line 2418  unsigned int *dp_compute_bound(DP p)
Line 2355  unsigned int *dp_compute_bound(DP p)
         }          }
         l = (nd_nvar+31);          l = (nd_nvar+31);
         t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int));          t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int));
         bzero(t,l*sizeof(unsigned int));          for ( i = 0; i < nd_nvar; i++ ) t[i] = d1[i];
         bcopy(d1,t,nd_nvar*sizeof(unsigned int));          for ( ; i < l; i++ ) t[i] = 0;
         return t;          return t;
 }  }
   
Line 2433  unsigned int *nd_compute_bound(ND p)
Line 2370  unsigned int *nd_compute_bound(ND p)
                 return 0;                  return 0;
         d1 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int));          d1 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int));
         d2 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int));          d2 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int));
         bcopy(HDL(p),d1,nd_wpd*sizeof(unsigned int));          ndl_copy(HDL(p),d1);
         for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) {          for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) {
                 ndl_lcm(DL(m),d1,d2);                  ndl_lcm(DL(m),d1,d2);
                 t = d1; d1 = d2; d2 = t;                  t = d1; d1 = d2; d2 = t;
         }          }
         l = nd_nvar+31;          l = nd_nvar+31;
         t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int));          t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int));
         bzero(t,l*sizeof(unsigned int));          for ( i = 0; i < l; i++ ) t[i] = 0;
         for ( i = 0; i < nd_nvar; i++ )          for ( i = 0; i < nd_nvar; i++ )
                 t[i] = (d1[i/nd_epw+1]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0;                  t[i] = (d1[i/nd_epw+1]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0;
           for ( ; i < l; i++ ) t[i] = 0;
         return t;          return t;
 }  }
   
Line 2470  void nd_setup_parameters() {
Line 2408  void nd_setup_parameters() {
   
 ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
 {  {
         int i,obpe,oadv;          int i,obpe,oadv,h;
         NM prev_nm_free_list;          NM prev_nm_free_list;
         RHist mr0,mr;          RHist mr0,mr;
         RHist r;          RHist r;
           RHist *old_red;
         ND_pairs s0,s,t,prev_ndp_free_list;          ND_pairs s0,s,t,prev_ndp_free_list;
   
         obpe = nd_bpe;          obpe = nd_bpe;
Line 2502  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
Line 2441  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
                 SG(s) = SG(t);                  SG(s) = SG(t);
                 ndl_dup(obpe,LCM(t),LCM(s));                  ndl_dup(obpe,LCM(t),LCM(s));
         }          }
   
           old_red = (RHist *)ALLOCA(REDTAB_LEN*sizeof(RHist));
         for ( i = 0; i < REDTAB_LEN; i++ ) {          for ( i = 0; i < REDTAB_LEN; i++ ) {
                 for ( mr0 = 0, r = nd_red[i]; r; r = NEXT(r) ) {                  old_red[i] = nd_red[i];
                         NEXTRHist(mr0,mr);                  nd_red[i] = 0;
           }
           for ( i = 0; i < REDTAB_LEN; i++ )
                   for ( r = old_red[i]; r; r = NEXT(r) ) {
                           NEWRHist(mr);
                         mr->index = r->index;                          mr->index = r->index;
                         SG(mr) = SG(r);                          SG(mr) = SG(r);
                         ndl_dup(obpe,DL(r),DL(mr));                          ndl_dup(obpe,DL(r),DL(mr));
                           h = ndl_hash_value(DL(mr));
                           NEXT(mr) = nd_red[h];
                           nd_red[h] = mr;
                 }                  }
                 if ( mr0 ) NEXT(mr) = 0;          for ( i = 0; i < REDTAB_LEN; i++ ) old_red[i] = 0;
                 nd_red[i] = mr0;          old_red = 0;
         }  
         for ( i = 0; i < nd_psn; i++ ) {          for ( i = 0; i < nd_psn; i++ ) {
                 NEWRHist(r); SG(r) = SG(nd_psh[i]);                  NEWRHist(r); SG(r) = SG(nd_psh[i]);
                 ndl_dup(obpe,DL(nd_psh[i]),DL(r));                  ndl_dup(obpe,DL(nd_psh[i]),DL(r));
Line 2526  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
Line 2473  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
   
 void nd_reconstruct_direct(int mod,NDV *ps,int len)  void nd_reconstruct_direct(int mod,NDV *ps,int len)
 {  {
         int i,obpe,oadv;          int i,obpe,oadv,h;
         NM prev_nm_free_list;          NM prev_nm_free_list;
         RHist mr0,mr;          RHist mr0,mr;
         RHist r;          RHist r;
           RHist *old_red;
         ND_pairs s0,s,t,prev_ndp_free_list;          ND_pairs s0,s,t,prev_ndp_free_list;
   
         obpe = nd_bpe;          obpe = nd_bpe;
Line 2547  void nd_reconstruct_direct(int mod,NDV *ps,int len)
Line 2495  void nd_reconstruct_direct(int mod,NDV *ps,int len)
         _nm_free_list = 0; _ndp_free_list = 0;          _nm_free_list = 0; _ndp_free_list = 0;
         if ( mod != 0 )          if ( mod != 0 )
                 for ( i = len-1; i >= 0; i-- ) ndv_realloc(ps[i],obpe,oadv);                  for ( i = len-1; i >= 0; i-- ) ndv_realloc(ps[i],obpe,oadv);
           old_red = (RHist *)ALLOCA(REDTAB_LEN*sizeof(RHist));
         for ( i = 0; i < REDTAB_LEN; i++ ) {          for ( i = 0; i < REDTAB_LEN; i++ ) {
                 for ( mr0 = 0, r = nd_red[i]; r; r = NEXT(r) ) {                  old_red[i] = nd_red[i];
                         NEXTRHist(mr0,mr);                  nd_red[i] = 0;
           }
           for ( i = 0; i < REDTAB_LEN; i++ )
                   for ( r = old_red[i]; r; r = NEXT(r) ) {
                           NEWRHist(mr);
                         mr->index = r->index;                          mr->index = r->index;
                         SG(mr) = SG(r);                          SG(mr) = SG(r);
                         ndl_dup(obpe,DL(r),DL(mr));                          ndl_dup(obpe,DL(r),DL(mr));
                           h = ndl_hash_value(DL(mr));
                           NEXT(mr) = nd_red[h];
                           nd_red[h] = mr;
                 }                  }
                 if ( mr0 ) NEXT(mr) = 0;          for ( i = 0; i < REDTAB_LEN; i++ ) old_red[i] = 0;
                 nd_red[i] = mr0;          old_red = 0;
         }  
         prev_nm_free_list = 0;          prev_nm_free_list = 0;
         prev_ndp_free_list = 0;          prev_ndp_free_list = 0;
         GC_gcollect();          GC_gcollect();
Line 2704  ND ndv_mul_nm(int mod,NDV p,NM m0)
Line 2659  ND ndv_mul_nm(int mod,NDV p,NM m0)
                                 c1 = CM(m);                                  c1 = CM(m);
                                 DMAR(c1,c,0,mod,c2);                                  DMAR(c1,c,0,mod,c2);
                                 CM(mr) = c2;                                  CM(mr) = c2;
                                 TD(DL(mr)) = TD(DL(m))+td;  
                                 ndl_add(DL(m),d,DL(mr));                                  ndl_add(DL(m),d,DL(mr));
                         }                          }
                 } else {                  } else {
Line 2712  ND ndv_mul_nm(int mod,NDV p,NM m0)
Line 2666  ND ndv_mul_nm(int mod,NDV p,NM m0)
                         for ( i = 0; i < len; i++, NMV_ADV(m) ) {                          for ( i = 0; i < len; i++, NMV_ADV(m) ) {
                                 NEXTNM(mr0,mr);                                  NEXTNM(mr0,mr);
                                 mulq(CQ(m),q,&CQ(mr));                                  mulq(CQ(m),q,&CQ(mr));
                                 TD(DL(mr)) = TD(DL(m))+td;  
                                 ndl_add(DL(m),d,DL(mr));                                  ndl_add(DL(m),d,DL(mr));
                         }                          }
                 }                  }

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.39

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