[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.71 and 1.73

version 1.71, 2003/09/17 07:16:53 version 1.73, 2003/09/17 08:37:49
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.70 2003/09/15 10:51:45 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.72 2003/09/17 08:14:26 noro Exp $ */
   
 #include "ca.h"  #include "ca.h"
 #include "inline.h"  #include "inline.h"
Line 2240  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
Line 2240  void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe
         int e,max,nvar;          int e,max,nvar;
         NDV b;          NDV b;
   
         nd_free_private_storage();  
         get_vars((Obj)f,&fv); pltovl(v,&vv);          get_vars((Obj)f,&fv); pltovl(v,&vv);
         nvar = length(vv);          nvar = length(vv);
         nd_init_ord(ord);          nd_init_ord(ord);
Line 2285  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
Line 2284  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
         nocheck = 0;          nocheck = 0;
         mindex = 0;          mindex = 0;
   
         nd_free_private_storage();  
         /* setup modulus */          /* setup modulus */
         if ( trace < 0 ) {          if ( trace < 0 ) {
                 trace = -trace;                  trace = -trace;
Line 2362  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
Line 2360  void nd_gr_trace(LIST f,LIST v,int trace,int homo,stru
         }          }
         /* dp->p */          /* dp->p */
         nd_bpe = cbpe;          nd_bpe = cbpe;
         nd_setup_parameters(0,0);          nd_setup_parameters(nd_nvar,0);
         for ( r = cand; r; r = NEXT(r) ) BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r));          for ( r = cand; r; r = NEXT(r) ) BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r));
         MKLIST(*rp,cand);          MKLIST(*rp,cand);
 }  }
Line 2744  int nd_get_exporigin(struct order_spec *ord)
Line 2742  int nd_get_exporigin(struct order_spec *ord)
 void nd_setup_parameters(int nvar,int max) {  void nd_setup_parameters(int nvar,int max) {
         int i,j,n,elen,ord_o,ord_l,l,s;          int i,j,n,elen,ord_o,ord_l,l,s;
         struct order_pair *op;          struct order_pair *op;
           int bpe;
   
         /* if max == 0, don't touch nd_bpe */          if ( !max ) bpe = nd_bpe;
         if ( max > 0 ) {          else if ( max < 2 ) bpe = 1;
                 if ( max < 2 ) nd_bpe = 1;          else if ( max < 4 ) bpe = 2;
                 if ( max < 4 ) nd_bpe = 2;          else if ( max < 8 ) bpe = 3;
                 else if ( max < 8 ) nd_bpe = 3;          else if ( max < 16 ) bpe = 4;
                 else if ( max < 16 ) nd_bpe = 4;          else if ( max < 32 ) bpe = 5;
                 else if ( max < 32 ) nd_bpe = 5;          else if ( max < 64 ) bpe = 6;
                 else if ( max < 64 ) nd_bpe = 6;          else if ( max < 256 ) bpe = 8;
                 else if ( max < 256 ) nd_bpe = 8;          else if ( max < 1024 ) bpe = 10;
                 else if ( max < 1024 ) nd_bpe = 10;          else if ( max < 65536 ) bpe = 16;
                 else if ( max < 65536 ) nd_bpe = 16;          else bpe = 32;
                 else nd_bpe = 32;          if ( bpe != nd_bpe || nvar != nd_nvar )
         }                  nd_free_private_storage();
         /* nvar == 0, don't touch nd_nvar */          nd_bpe = bpe;
         if ( nvar > 0 ) nd_nvar = nvar;          nd_nvar = nvar;
   
         nd_epw = (sizeof(UINT)*8)/nd_bpe;          nd_epw = (sizeof(UINT)*8)/nd_bpe;
         elen = nd_nvar/nd_epw+(nd_nvar%nd_epw?1:0);          elen = nd_nvar/nd_epw+(nd_nvar%nd_epw?1:0);
   
Line 2809  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
Line 2807  ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d)
         else if ( obpe < 32 ) nd_bpe = 32;          else if ( obpe < 32 ) nd_bpe = 32;
         else error("nd_reconstruct : exponent too large");          else error("nd_reconstruct : exponent too large");
   
         nd_setup_parameters(0,0);          nd_setup_parameters(nd_nvar,0);
         prev_nm_free_list = _nm_free_list;          prev_nm_free_list = _nm_free_list;
         prev_ndp_free_list = _ndp_free_list;          prev_ndp_free_list = _ndp_free_list;
         _nm_free_list = 0;          _nm_free_list = 0;
Line 3806  void ndv_reduce_vect(int m,UINT *svect,int col,IndArra
Line 3804  void ndv_reduce_vect(int m,UINT *svect,int col,IndArra
                 if ( svect[i] >= (UINT)m ) svect[i] %= m;                  if ( svect[i] >= (UINT)m ) svect[i] %= m;
 }  }
   
   void ndv_reduce_vect_sf(int m,UINT *svect,int col,IndArray *imat,NODE rp0)
   {
           int i,j,k,len,pos,prev;
           UINT c,c1,c2,c3,up,lo,dmy;
           IndArray ivect;
           unsigned char *ivc;
           unsigned short *ivs;
           unsigned int *ivi;
           NDV redv;
           NMV mr;
           NODE rp;
   
           for ( rp = rp0, i = 0; rp; i++, rp = NEXT(rp) ) {
                   ivect = imat[i];
                   k = ivect->head; svect[k] %= m;
                   if ( c = svect[k] ) {
                           c = _chsgnsf(c); redv = nd_ps[((NM_ind_pair)BDY(rp))->index];
                           len = LEN(redv); mr = BDY(redv);
                           svect[k] = 0; prev = k;
                           switch ( ivect->width ) {
                                   case 1:
                                           ivc = ivect->index.c;
                                           for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) {
                                                   pos = prev+ivc[j]; prev = pos;
                                                   svect[pos] = _addsf(_mulsf(CM(mr),c),svect[pos]);
                                           }
                                           break;
                                   case 2:
                                           ivs = ivect->index.s;
                                           for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) {
                                                   pos = prev+ivs[j]; prev = pos;
                                                   svect[pos] = _addsf(_mulsf(CM(mr),c),svect[pos]);
                                           }
                                           break;
                                   case 4:
                                           ivi = ivect->index.i;
                                           for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) {
                                                   pos = prev+ivi[j]; prev = pos;
                                                   svect[pos] = _addsf(_mulsf(CM(mr),c),svect[pos]);
                                           }
                                           break;
                           }
                   }
           }
   }
   
 NDV vect_to_ndv(UINT *vect,int spcol,int col,int *rhead,UINT *s0vect)  NDV vect_to_ndv(UINT *vect,int spcol,int col,int *rhead,UINT *s0vect)
 {  {
         int j,k,len;          int j,k,len;
Line 3881  int nd_symbolic_preproc(PGeoBucket bucket,UINT **s0vec
Line 3925  int nd_symbolic_preproc(PGeoBucket bucket,UINT **s0vec
                 }                  }
                 col++;                  col++;
         }          }
         NEXT(rp) = 0; NEXT(s) = 0;          if ( rp0 ) NEXT(rp) = 0;
           NEXT(s) = 0;
         s0v = (UINT *)MALLOC_ATOMIC(col*nd_wpd*sizeof(UINT));          s0v = (UINT *)MALLOC_ATOMIC(col*nd_wpd*sizeof(UINT));
         for ( i = 0, p = s0v, s = s0; i < col;          for ( i = 0, p = s0v, s = s0; i < col;
                 i++, p += nd_wpd, s = NEXT(s) ) ndl_copy(DL(s),p);                  i++, p += nd_wpd, s = NEXT(s) ) ndl_copy(DL(s),p);
Line 4073  NODE nd_f4(int m)
Line 4118  NODE nd_f4(int m)
                 svect = (UINT *)MALLOC_ATOMIC(col*sizeof(UINT));                  svect = (UINT *)MALLOC_ATOMIC(col*sizeof(UINT));
                 for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) {                  for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) {
                         nd_to_vect(m,s0vect,col,BDY(sp),svect);                          nd_to_vect(m,s0vect,col,BDY(sp),svect);
                         ndv_reduce_vect(m,svect,col,imat,rp0);                          if ( m == -1 ) ndv_reduce_vect_sf(m,svect,col,imat,rp0);
                           else ndv_reduce_vect(m,svect,col,imat,rp0);
                         for ( i = 0; i < col; i++ ) if ( svect[i] ) break;                          for ( i = 0; i < col; i++ ) if ( svect[i] ) break;
                         if ( i < col ) {                          if ( i < col ) {
                                 spmat[sprow] = v = (UINT *)MALLOC_ATOMIC(spcol*sizeof(UINT));                                  spmat[sprow] = v = (UINT *)MALLOC_ATOMIC(spcol*sizeof(UINT));
Line 4087  NODE nd_f4(int m)
Line 4133  NODE nd_f4(int m)
   
                 /* elimination (2nd step) */                  /* elimination (2nd step) */
                 colstat = (int *)ALLOCA(spcol*sizeof(int));                  colstat = (int *)ALLOCA(spcol*sizeof(int));
                 rank = generic_gauss_elim_mod(spmat,sprow,spcol,m,colstat);                  if ( m == -1 )
                           rank = generic_gauss_elim_sf(spmat,sprow,spcol,m,colstat);
                   else
                           rank = generic_gauss_elim_mod(spmat,sprow,spcol,m,colstat);
   
                 get_eg(&eg1); init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg1);                  get_eg(&eg1); init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg1);
                 if ( DP_Print ) {                  if ( DP_Print ) {

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.73

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