[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.65 and 1.66

version 1.65, 2003/09/12 08:01:51 version 1.66, 2003/09/12 08:26:19
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.64 2003/09/12 01:12:40 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.65 2003/09/12 08:01:51 noro Exp $ */
   
 #include "ca.h"  #include "ca.h"
 #include "inline.h"  #include "inline.h"
Line 3787  int nm_ind_pair_to_vect(int mod,UINT *s0,int n,NM_ind_
Line 3787  int nm_ind_pair_to_vect(int mod,UINT *s0,int n,NM_ind_
         return i;          return i;
 }  }
   
 void nm_ind_pair_to_vect_compress(int mod,UINT *s0,int n,NM_ind_pair pair,int *ind)  void nm_ind_pair_to_vect_compress(int mod,UINT *s0,int n,
           NM_ind_pair pair,int *ind)
 {  {
         NM m;          NM m;
         NMV mr;          NMV mr;
Line 3808  void nm_ind_pair_to_vect_compress(int mod,UINT *s0,int
Line 3809  void nm_ind_pair_to_vect_compress(int mod,UINT *s0,int
 }  }
   
   
 void ndv_reduce_vect(int m,UINT *svect,int **imat,NODE rp0)  void ndv_reduce_vect(int m,UINT *svect,int col,int **imat,NODE rp0)
 {  {
         int i,j,k,len,pos;          int i,j,k,len,pos;
         UINT c,c1,c2,c3;          UINT c,c1,c2,c3,up,lo,dmy;
         UINT *ivect;          UINT *ivect;
         NDV redv;          NDV redv;
         NMV mr0,mr;          NMV mr0,mr;
Line 3820  void ndv_reduce_vect(int m,UINT *svect,int **imat,NODE
Line 3821  void ndv_reduce_vect(int m,UINT *svect,int **imat,NODE
         for ( rp = rp0, i = 0; rp; i++, rp = NEXT(rp) ) {          for ( rp = rp0, i = 0; rp; i++, rp = NEXT(rp) ) {
                 ivect = imat[i];                  ivect = imat[i];
                 k = ivect[0];                  k = ivect[0];
                   svect[k] %= m;
                 if ( c = svect[k] ) {                  if ( c = svect[k] ) {
                         c = m-c;                          c = m-c;
                         redv = nd_ps[((NM_ind_pair)BDY(rp))->index];                          redv = nd_ps[((NM_ind_pair)BDY(rp))->index];
Line 3828  void ndv_reduce_vect(int m,UINT *svect,int **imat,NODE
Line 3830  void ndv_reduce_vect(int m,UINT *svect,int **imat,NODE
                         for ( j = 0, mr = mr0; j < len; j++, NMV_ADV(mr) ) {                          for ( j = 0, mr = mr0; j < len; j++, NMV_ADV(mr) ) {
                                 pos = ivect[j];                                  pos = ivect[j];
                                 c1 = CM(mr);                                  c1 = CM(mr);
                                 c2 = svect[pos]; DMAR(c1,c,c2,m,c3);                                  c2 = svect[pos];
                                 svect[pos] = c3;                                  DMA(c1,c,c2,up,lo);
                                   if ( up ) {
                                           DSAB(m,up,lo,dmy,c3); svect[pos] = c3;
                                   } else
                                           svect[pos] = lo;
                         }                          }
                 }                  }
         }          }
           for ( i = 0; i < col; i++ )
                   if ( svect[i] >= (UINT)m ) svect[i] %= m;
 }  }
   
 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)
Line 3937  NODE nd_f4(int m)
Line 3945  NODE nd_f4(int m)
         int spcol,sprow;          int spcol,sprow;
         int sugar;          int sugar;
         PGeoBucket bucket;          PGeoBucket bucket;
           struct oEGT eg0,eg1,eg_f4;
   
         if ( !m )          if ( !m )
                 error("nd_f4 : not implemented");                  error("nd_f4 : not implemented");
Line 3947  NODE nd_f4(int m)
Line 3956  NODE nd_f4(int m)
                 g = update_base(g,i);                  g = update_base(g,i);
         }          }
         while ( d ) {          while ( d ) {
                   get_eg(&eg0);
                 l = nd_minsugarp(d,&d);                  l = nd_minsugarp(d,&d);
                 sugar = SG(l);                  sugar = SG(l);
                 bucket = create_pbucket();                  bucket = create_pbucket();
Line 3977  NODE nd_f4(int m)
Line 3987  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,imat,rp0);                          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 3993  NODE nd_f4(int m)
Line 4003  NODE nd_f4(int m)
                 colstat = (int *)ALLOCA(spcol*sizeof(int));                  colstat = (int *)ALLOCA(spcol*sizeof(int));
                 rank = generic_gauss_elim_mod(spmat,sprow,spcol,m,colstat);                  rank = generic_gauss_elim_mod(spmat,sprow,spcol,m,colstat);
   
                 fprintf(asir_out,"sugar=%d,rank=%d\n",sugar,rank); fflush(asir_out);                  get_eg(&eg1); init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg1);
                   fprintf(asir_out,"sugar=%d,nsp=%d,nred=%d,spmat=(%d,%d),rank=%d  ",
                           sugar,nsp,nred,sprow,spcol,rank);
                   fprintf(asir_out,"%fsec\n",eg_f4.exectime+eg_f4.gctime);
   
                 /* adding new bases */                  /* adding new bases */
                 for ( i = sprow-1; i >= rank; i-- ) GC_free(spmat[i]);                  for ( i = 0; i < rank; i++ ) {
                 for ( ; i >= 0; i-- ) {  
                         nf = vect_to_ndv(spmat[i],spcol,col,rhead,s0vect);                          nf = vect_to_ndv(spmat[i],spcol,col,rhead,s0vect);
                         SG(nf) = sugar;                          SG(nf) = sugar;
                         ndv_removecont(m,nf);                          ndv_removecont(m,nf);
Line 4006  NODE nd_f4(int m)
Line 4018  NODE nd_f4(int m)
                         g = update_base(g,nh);                          g = update_base(g,nh);
                         GC_free(spmat[i]);                          GC_free(spmat[i]);
                 }                  }
                   for ( ; i < sprow; i++ ) GC_free(spmat[i]);
         }          }
         for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps[(int)BDY(r)];          for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps[(int)BDY(r)];
         return g;          return g;

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66

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