=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/array.c,v retrieving revision 1.10 retrieving revision 1.15 diff -u -p -r1.10 -r1.15 --- OpenXM_contrib2/asir2000/builtin/array.c 2000/11/13 01:48:12 1.10 +++ OpenXM_contrib2/asir2000/builtin/array.c 2001/09/07 08:54:57 1.15 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.9 2000/11/08 08:02:49 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.14 2001/09/04 05:14:03 noro Exp $ */ #include "ca.h" #include "base.h" @@ -57,7 +57,7 @@ #define DMAR(a1,a2,a3,d,r) (r)=dmar(a1,a2,a3,d); #endif -extern int Print; /* XXX */ +extern int DP_Print; /* XXX */ void inner_product_mat_int_mod(Q **,int **,int,int,int,Q *); void solve_by_lu_mod(int **,int,int,int **,int); @@ -90,6 +90,7 @@ void Px962_irredpoly_up2(); void Pirredpoly_up2(); void Pnbpoly_up2(); void Pqsort(); +void Pexponent_vector(); struct ftab array_tab[] = { {"solve_by_lu_gfmmat",Psolve_by_lu_gfmmat,4}, @@ -97,7 +98,10 @@ struct ftab array_tab[] = { {"mat_to_gfmmat",Pmat_to_gfmmat,2}, {"generic_gauss_elim_mod",Pgeneric_gauss_elim_mod,2}, {"newvect",Pnewvect,-2}, + {"vector",Pnewvect,-2}, + {"exponent_vector",Pexponent_vector,-99999999}, {"newmat",Pnewmat,-3}, + {"matrix",Pnewmat,-3}, {"newbytearray",Pnewbytearray,-2}, {"sepmat_destructive",Psepmat_destructive,2}, {"sepvect",Psepvect,2}, @@ -376,6 +380,13 @@ VECT *rp; *rp = vect; } +void Pexponent_vector(arg,rp) +NODE arg; +DP *rp; +{ + nodetod(arg,rp); +} + void Pnewbytearray(arg,rp) NODE arg; BYTEARRAY *rp; @@ -805,10 +816,10 @@ int **rindp,**cindp; colstat = (int *)MALLOC_ATOMIC(col*sizeof(int)); wcolstat = (int *)MALLOC_ATOMIC(col*sizeof(int)); for ( ind = 0; ; ind++ ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"."); fflush(asir_out); } - md = lprime[ind]; + md = get_lprime(ind); get_eg(&tmp0); for ( i = 0; i < row; i++ ) for ( j = 0, bmi = bmat[i], wmi = wmat[i]; j < col; j++ ) @@ -842,13 +853,13 @@ RESET: } } else { if ( rank < rank0 ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"lower rank matrix; continuing...\n"); fflush(asir_out); } continue; } else if ( rank > rank0 ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"higher rank matrix; resetting...\n"); fflush(asir_out); } @@ -856,7 +867,7 @@ RESET: } else { for ( j = 0; (jrow; col = mat->col; w = (int **)almat(row,col); for ( ind = 0; ; ind++ ) { - md = lprime[ind]; + md = get_lprime(ind); STOQ(md,mdq); for ( i = 0; i < row; i++ ) for ( j = 0, ai = a0[i], wi = w[i]; j < col; j++ ) @@ -1035,7 +1049,7 @@ int **rindp,**cindp; add_eg(&eg_mul,&tmp0,&tmp1); /* q = q*md */ mulq(q,mdq,&u); q = u; - if ( !(count % 2) && intmtoratm_q(xmat,NM(q),*nmmat,dn) ) { + if ( !(count % 16) && intmtoratm_q(xmat,NM(q),*nmmat,dn) ) { for ( j = k = l = 0; j < col; j++ ) if ( cinfo[j] ) rind[k++] = j; @@ -1378,6 +1392,44 @@ int md; tj = sp+j; for ( k = col-j; k >= 0; k-- ) { if ( zzz = *s ) { DMAR(zzz,hc,*tj,md,*tj) } tj++; s++; + } + } + } +} + +/* + mat[i] : compressed reducers (i=0,...,nred-1) + mat[0] < mat[1] < ... < mat[nred-1] w.r.t the term order +*/ + +void reduce_sp_by_red_mod_compress (sp,redmat,ind,nred,col,md) +int *sp; +CDP *redmat; +int *ind; +int nred,col; +int md; +{ + int i,j,k,hc,c,len; + int *tj; + CDP ri; + + /* reduce the spolys by redmat */ + for ( i = nred-1; i >= 0; i-- ) { + /* reduce sp by redmat[i] */ + if ( hc = sp[ind[i]] ) { + /* sp = sp-hc*redmat[i] */ + hc = md-hc; + ri = redmat[i]; + len = ri->len; + for ( k = 0; k < len; k++ ) { + j = ri->body[k].index; + c = ri->body[k].c; + tj = sp+j; +#if 1 + DMAR(c,hc,*tj,md,*tj); +#else + *tj = ((hc*c)+(*tj))%md; +#endif } } }