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

Diff for /OpenXM_contrib2/asir2000/builtin/gr.c between version 1.17 and 1.36

version 1.17, 2000/12/11 02:00:40 version 1.36, 2001/10/01 01:58:02
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/builtin/gr.c,v 1.16 2000/12/08 06:43:09 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.35 2001/09/18 00:56:05 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #include "base.h"  #include "base.h"
 #include "ox.h"  #include "ox.h"
   
 #define ITOS(p) (((unsigned int)(p))&0x7fffffff)  #if defined(__GNUC__)
 #define STOI(i) ((P)((unsigned int)(i)|0x80000000))  #define INLINE inline
   #elif defined(VISUAL)
   #define INLINE __inline
   #else
   #define INLINE
   #endif
   
 #define NEXTVL(r,c) \  #define NEXTVL(r,c) \
 if(!(r)){NEWVL(r);(c)=(r);}else{NEWVL(NEXT(c));(c)=NEXT(c);}  if(!(r)){NEWVL(r);(c)=(r);}else{NEWVL(NEXT(c));(c)=NEXT(c);}
Line 85  extern int do_weyl;
Line 90  extern int do_weyl;
   
 extern DP_Print;  extern DP_Print;
   
   void dptoca(DP,unsigned int **);
   void _tf_to_vect_compress(NODE,DL *,CDP *);
   NODE mul_dllist(DL,DP);
 void dp_imul_d(DP,Q,DP *);  void dp_imul_d(DP,Q,DP *);
 void print_stat(void);  void print_stat(void);
 void init_stat(void);  void init_stat(void);
Line 106  DP_pairs criterion_B(DP_pairs,int);
Line 114  DP_pairs criterion_B(DP_pairs,int);
 DP_pairs newpairs(NODE,int);  DP_pairs newpairs(NODE,int);
 DP_pairs updpairs(DP_pairs,NODE,int);  DP_pairs updpairs(DP_pairs,NODE,int);
 void _dp_nf(NODE,DP,DP *,int,DP *);  void _dp_nf(NODE,DP,DP *,int,DP *);
 void _dp_nf_ptozp(NODE,DP,DP *,int,int,DP *);  void _dp_nf_z(NODE,DP,DP *,int,int,DP *);
 NODE gb_mod(NODE,int);  NODE gb_mod(NODE,int);
 NODE gbd(NODE,int,NODE,NODE);  NODE gbd(NODE,int,NODE,NODE);
 NODE gb(NODE,int,NODE);  NODE gb(NODE,int,NODE);
 NODE gb_f4(NODE);  NODE gb_f4(NODE);
 NODE gb_f4_mod(NODE,int);  NODE gb_f4_mod(NODE,int);
   NODE gb_f4_mod_old(NODE,int);
 DP_pairs minp(DP_pairs, DP_pairs *);  DP_pairs minp(DP_pairs, DP_pairs *);
 void minsugar(DP_pairs,DP_pairs *,DP_pairs *);  void minsugar(DP_pairs,DP_pairs *,DP_pairs *);
 NODE append_one(NODE,int);  NODE append_one(NODE,int);
Line 135  void pltovl(LIST,VL *);
Line 144  void pltovl(LIST,VL *);
 void printdl(DL);  void printdl(DL);
 int DPPlength(DP_pairs);  int DPPlength(DP_pairs);
 void dp_gr_mod_main(LIST,LIST,Num,int,struct order_spec *,LIST *);  void dp_gr_mod_main(LIST,LIST,Num,int,struct order_spec *,LIST *);
 void dp_gr_main(LIST,LIST,Num,int,struct order_spec *,LIST *);  void dp_gr_main(LIST,LIST,Num,int,int,struct order_spec *,LIST *);
 void dp_f4_main(LIST,LIST,struct order_spec *,LIST *);  void dp_f4_main(LIST,LIST,struct order_spec *,LIST *);
 void dp_f4_mod_main(LIST,LIST,int,struct order_spec *,LIST *);  void dp_f4_mod_main(LIST,LIST,int,struct order_spec *,LIST *);
 double get_rtime();  double get_rtime();
Line 180  static int PtozpRA = 0;
Line 189  static int PtozpRA = 0;
   
 int doing_f4;  int doing_f4;
 NODE TraceList;  NODE TraceList;
   NODE AllTraceList;
   
 int eqdl(nv,dl1,dl2)  INLINE int eqdl(nv,dl1,dl2)
 int nv;  int nv;
 DL dl1,dl2;  DL dl1,dl2;
 {  {
Line 216  int *b;
Line 226  int *b;
         }          }
 }  }
   
   /* [t,findex] -> tf -> compressed vector */
   
   void _tf_to_vect_compress(tf,at,b)
   NODE tf;
   DL *at;
   CDP *b;
   {
           int i,j,k,nv,len;
           DL t,s,d1;
           DP f;
           MP m;
           CDP r;
   
           t = (DL)BDY(tf);
           f = ps[(int)BDY(NEXT(tf))];
   
           nv = f->nv;
           for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ );
           r = (CDP)MALLOC(sizeof(struct oCDP));
           r->len = len;
           r->psindex = (int)BDY(NEXT(tf));
           r->body = (unsigned int *)MALLOC_ATOMIC(sizeof(unsigned int)*len);
   
           NEWDL_NOINIT(s,nv);
           for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) {
                   d1 = m->dl;
                   s->td = t->td+d1->td;
                   for ( k = 0; k < nv; k++ )
                           s->d[k] = t->d[k]+d1->d[k];
                   for ( ; !eqdl(nv,s,at[i]); i++ );
                   r->body[j] = i;
           }
           *b = r;
   }
   
 void dp_to_vect(f,at,b)  void dp_to_vect(f,at,b)
 DP f;  DP f;
 DL *at;  DL *at;
Line 247  DP f;
Line 292  DP f;
         return mp0;          return mp0;
 }  }
   
   NODE mul_dllist(d,f)
   DL d;
   DP f;
   {
           MP m;
           NODE mp,mp0;
           DL t,d1;
           int i,nv;
   
           if ( !f )
                   return 0;
           nv = NV(f);
           mp0 = 0;
           for ( m = BDY(f); m; m = NEXT(m) ) {
                   NEXTNODE(mp0,mp);
                   NEWDL_NOINIT(t,nv);
                   d1 = m->dl;
                   t->td = d->td+d1->td;
                   for ( i = 0; i < nv; i++ )
                           t->d[i] = d->d[i]+d1->d[i];
                   BDY(mp) = (pointer)t;
           }
           NEXT(mp) = 0;
           return mp0;
   }
   
 void pdl(f)  void pdl(f)
 NODE f;  NODE f;
 {  {
Line 257  NODE f;
Line 328  NODE f;
         printf("\n");          printf("\n");
 }  }
   
 void dp_gr_main(f,v,homo,modular,ord,rp)  void dp_gr_main(f,v,homo,modular,field,ord,rp)
 LIST f,v;  LIST f,v;
 Num homo;  Num homo;
 int modular;  int modular,field;
 struct order_spec *ord;  struct order_spec *ord;
 LIST *rp;  LIST *rp;
 {  {
         int i,mindex,m,nochk;          int i,mindex,m,nochk;
         struct order_spec ord1;          struct order_spec ord1;
           Q q;
         VL fv,vv,vc;          VL fv,vv,vc;
         NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx;          NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx;
           NODE ind,ind0;
           LIST trace,gbindex;
   
         mindex = 0; nochk = 0; dp_fcoeffs = 0;          mindex = 0; nochk = 0; dp_fcoeffs = field;
         get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc);          get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc);
         NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc;          NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc;
         CNVars = homo ? NVars+1 : NVars;          CNVars = homo ? NVars+1 : NVars;
Line 296  LIST *rp;
Line 370  LIST *rp;
                 modular = -modular; nochk = 1;                  modular = -modular; nochk = 1;
         }          }
         if ( modular )          if ( modular )
                 m = modular > 1 ? modular : lprime[mindex];                  m = modular > 1 ? modular : get_lprime(mindex);
         else          else
                 m = 0;                  m = 0;
         makesubst(vc,&subst);          makesubst(vc,&subst);
Line 326  LIST *rp;
Line 400  LIST *rp;
                         if ( modular > 1 ) {                          if ( modular > 1 ) {
                                 *rp = 0; return;                                  *rp = 0; return;
                         } else                          } else
                                 m = lprime[++mindex];                                  m = get_lprime(++mindex);
                 makesubst(vc,&subst);                  makesubst(vc,&subst);
                 psn = length(s);                  psn = length(s);
                 for ( i = psn; i < pslen; i++ ) {                  for ( i = psn; i < pslen; i++ ) {
                         pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0;                          pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0;
                 }                  }
         }          }
         for ( r0 = 0; x; x = NEXT(x) ) {          for ( r0 = 0, ind0 = 0; x; x = NEXT(x) ) {
                 NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]);                  NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]);
                 dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));                  dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));
                   NEXTNODE(ind0,ind);
                   STOQ((int)BDY(x),q); BDY(ind) = q;
         }          }
         if ( r0 ) NEXT(r) = 0;          if ( r0 ) NEXT(r) = 0;
           if ( ind0 ) NEXT(ind) = 0;
         MKLIST(*rp,r0);          MKLIST(*rp,r0);
           MKLIST(gbindex,ind0);
   
           if ( GenTrace && OXCheck < 0 ) {
   
                   x = AllTraceList;
                   for ( r = 0; x; x = NEXT(x) ) {
                           MKNODE(r0,BDY(x),r); r = r0;
                   }
                   MKLIST(trace,r);
                   r0 = mknode(3,*rp,gbindex,trace);
                   MKLIST(*rp,r0);
           }
         print_stat();          print_stat();
         if ( ShowMag )          if ( ShowMag )
                 fprintf(asir_out,"\nMax_mag=%d\n",Max_mag);                  fprintf(asir_out,"\nMax_mag=%d\n",Max_mag);
Line 419  LIST f,v;
Line 508  LIST f,v;
 struct order_spec *ord;  struct order_spec *ord;
 LIST *rp;  LIST *rp;
 {  {
         int i,mindex,m,nochk;          int i,mindex,m,nochk,homogen;
         struct order_spec ord1;          struct order_spec ord1;
         VL fv,vv,vc;          VL fv,vv,vc;
         NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx;          NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx;
Line 431  LIST *rp;
Line 520  LIST *rp;
         if ( ord->id && NVars != ord->nv )          if ( ord->id && NVars != ord->nv )
                 error("dp_f4_main : invalid order specification");                  error("dp_f4_main : invalid order specification");
         initd(ord);          initd(ord);
         for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {          for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) {
                 NEXTNODE(fd0,fd); ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd));                  NEXTNODE(fd0,fd); ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd));
                   if ( homogen )
                           homogen = dp_homogeneous(BDY(fd));
         }          }
         if ( fd0 ) NEXT(fd) = 0;          if ( fd0 ) NEXT(fd) = 0;
         setup_arrays(fd0,0,&s);          setup_arrays(fd0,0,&s);
         x = gb_f4(s);          x = gb_f4(s);
         reduceall(x,&xx); x = xx;          if ( !homogen ) {
                   reduceall(x,&xx); x = xx;
           }
         for ( r0 = 0; x; x = NEXT(x) ) {          for ( r0 = 0; x; x = NEXT(x) ) {
                 NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]);                  NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]);
                 dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));                  dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));
Line 452  int m;
Line 545  int m;
 struct order_spec *ord;  struct order_spec *ord;
 LIST *rp;  LIST *rp;
 {  {
         int i;          int i,homogen;
         struct order_spec ord1;          struct order_spec ord1;
         VL fv,vv,vc;          VL fv,vv,vc;
         DP b,c,c1;          DP b,c,c1;
Line 465  LIST *rp;
Line 558  LIST *rp;
         if ( ord->id && NVars != ord->nv )          if ( ord->id && NVars != ord->nv )
                 error("dp_f4_mod_main : invalid order specification");                  error("dp_f4_mod_main : invalid order specification");
         initd(ord);          initd(ord);
         for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {          for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) {
                 ptod(CO,vv,(P)BDY(t),&b);                  ptod(CO,vv,(P)BDY(t),&b);
                   if ( homogen )
                           homogen = dp_homogeneous(b);
                 _dp_mod(b,m,0,&c);                  _dp_mod(b,m,0,&c);
                 _dp_monic(c,m,&c1);                  _dp_monic(c,m,&c1);
                 if ( c ) {                  if ( c ) {
Line 475  LIST *rp;
Line 570  LIST *rp;
         }          }
         if ( fd0 ) NEXT(fd) = 0;          if ( fd0 ) NEXT(fd) = 0;
         setup_arrays(fd0,m,&s);          setup_arrays(fd0,m,&s);
         x = gb_f4_mod(s,m);          init_stat();
         reduceall_mod(x,m,&xx); x = xx;          if ( do_weyl )
                   x = gb_f4_mod_old(s,m);
           else
                   x = gb_f4_mod(s,m);
           if ( !homogen ) {
                   reduceall_mod(x,m,&xx); x = xx;
           }
         for ( r0 = 0; x; x = NEXT(x) ) {          for ( r0 = 0; x; x = NEXT(x) ) {
                 NEXTNODE(r0,r); _dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));                  NEXTNODE(r0,r); _dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r));
         }          }
         if ( r0 ) NEXT(r) = 0;          if ( r0 ) NEXT(r) = 0;
         MKLIST(*rp,r0);          MKLIST(*rp,r0);
           print_stat();
 }  }
   
 NODE gb_f4(f)  NODE gb_f4(f)
Line 605  NODE f;
Line 707  NODE f;
   
 /* initial bases are monic */  /* initial bases are monic */
   
   unsigned int **psca;
   
 NODE gb_f4_mod(f,m)  NODE gb_f4_mod(f,m)
 NODE f;  NODE f;
 int m;  int m;
Line 615  int m;
Line 719  int m;
         DP_pairs d,dm,dr,t;          DP_pairs d,dm,dr,t;
         DP h,nf,f1,f2,f21,f21r,sp,sp1,sd,sdm,tdp;          DP h,nf,f1,f2,f21,f21r,sp,sp1,sd,sdm,tdp;
         MP mp,mp0;          MP mp,mp0;
           NODE blist,bt,nt,bt1,dt,rhtlist;
           DL *ht,*at,*st;
           int **spmat;
           CDP *redmat;
           int *colstat,*w,*w1;
           int rank,nred,nsp,nsp0,nonzero,spcol;
           int *indred,*isred;
           CDP ri;
           int pscalen;
           struct oEGT tmp0,tmp1,tmp2,eg_split_symb,eg_split_elim1,eg_split_elim2;
           extern struct oEGT eg_symb,eg_elim1,eg_elim2;
   
           /* initialize coeffcient array list of ps[] */
           pscalen = pslen;
           psca = (unsigned int **)MALLOC(pscalen*sizeof(unsigned int *));
   
           init_eg(&eg_symb); init_eg(&eg_elim1); init_eg(&eg_elim2);
           for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) {
                   i = (int)BDY(r);
                   d = updpairs(d,g,i);
                   g = updbase(g,i);
                   gall = append_one(gall,i);
                   dptoca(ps[i],&psca[i]);
           }
           if ( gall )
                   nv = ((DP)ps[(int)BDY(gall)])->nv;
           while ( d ) {
                   get_eg(&tmp0);
                   minsugar(d,&dm,&dr); d = dr;
                   if ( DP_Print )
                           fprintf(asir_out,"sugar=%d\n",dm->sugar);
                   blist = 0; s0 = 0;
                   /* asph : sum of all head terms of spoly */
                   for ( t = dm; t; t = NEXT(t) ) {
                           _dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp);
   /*                      fprintf(stderr,"splen=%d-",dp_nt(sp)); */
                           if ( sp ) {
                                   MKNODE(bt,sp,blist); blist = bt;
                                   s0 = symb_merge(s0,dp_dllist(sp),nv);
   /*                              fprintf(stderr,"%d-",length(s0)); */
                           }
                   }
                   if ( DP_Print )
                           fprintf(asir_out,"initial spmat : %d x %d ",length(blist),length(s0));
                   /* s0 : all the terms appeared in symbolic reduction */
                   for ( s = s0, nred = 0; s; s = NEXT(s) ) {
                           for ( r = gall; r; r = NEXT(r) )
                                   if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) )
                                           break;
                           if ( r ) {
                                   dltod(BDY(s),nv,&tdp);
                                   dp_subd(tdp,ps[(int)BDY(r)],&sd);
                                   dt = mul_dllist(BDY(sd)->dl,ps[(int)BDY(r)]);
   /*                              fprintf(stderr,"[%d]",length(dt)); */
                                   /* list of [t,f] */
                                   bt1 = mknode(2,BDY(sd)->dl,BDY(r));
                                   MKNODE(bt,bt1,blist); blist = bt;
                                   symb_merge(s,dt,nv);
   /*                              fprintf(stderr,"%d-",length(s)); */
                                   nred++;
                           }
                   }
   /*              fprintf(stderr,"\n"); */
                   if ( DP_Print )
                           fprintf(asir_out,"number of reducers : %d\n",nred);
   
                   /* the first nred polys in blist are reducers */
                   /* row = the number of all the polys */
                   for ( r = blist, row = 0; r; r = NEXT(r), row++ );
   
                   /* col = number of all terms */
                   for ( s = s0, col = 0; s; s = NEXT(s), col++ );
   
                   /* head terms of all terms */
                   at = (DL *)MALLOC(col*sizeof(DL));
                   for ( s = s0, i = 0; i < col; s = NEXT(s), i++ )
                           at[i] = (DL)BDY(s);
   
                   /* store coefficients separately in spmat and redmat */
                   nsp = row-nred;
   
                   /* reducer matrix */
                   /* indred : register the position of the head term */
                   redmat = (CDP *)MALLOC(nred*sizeof(CDP));
                   for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ )
                           _tf_to_vect_compress(BDY(r),at,&redmat[i]);
   
                   /* register the position of the head term */
                   indred = (int *)MALLOC_ATOMIC(nred*sizeof(int));
                   bzero(indred,nred*sizeof(int));
                   isred = (int *)MALLOC_ATOMIC(col*sizeof(int));
                   bzero(isred,col*sizeof(int));
                   for ( i = 0; i < nred; i++ ) {
                           ri = redmat[i];
                           indred[i] = ri->body[0];
                           isred[indred[i]] = 1;
                   }
   
                   spcol = col-nred;
                   /* head terms not in ht */
                   st = (DL *)MALLOC(spcol*sizeof(DL));
                   for ( j = 0, k = 0; j < col; j++ )
                           if ( !isred[j] )
                                   st[k++] = at[j];
                   get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1);
                   init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1);
   
                   get_eg(&tmp1);
                   /* spoly matrix; stored in reduced form; terms in ht[] are omitted */
                   spmat = (int **)MALLOC(nsp*sizeof(int *));
                   w = (int *)MALLOC_ATOMIC(col*sizeof(int));
   
                   /* skip reducers in blist */
                   for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ );
                   for ( i = 0; r; r = NEXT(r) ) {
                           bzero(w,col*sizeof(int));
                           _dpmod_to_vect(BDY(r),at,w);
                           reduce_sp_by_red_mod_compress(w,redmat,indred,nred,col,m);
                           for ( j = 0; j < col; j++ )
                                   if ( w[j] )
                                           break;
                           if ( j < col ) {
                                   w1 = (int *)MALLOC_ATOMIC(spcol*sizeof(int));
                                   for ( j = 0, k = 0; j < col; j++ )
                                           if ( !isred[j] )
                                                   w1[k++] = w[j];
                                   spmat[i] = w1;
                                   i++;
                           }
                   }
                   /* update nsp */
                   nsp0 = nsp;
                   nsp = i;
   
                   /* XXX free redmat explicitly */
                   for ( k = 0; k < nred; k++ ) {
                           GC_free(BDY(redmat[k]));
                           GC_free(redmat[k]);
                   }
   
                   get_eg(&tmp0); add_eg(&eg_elim1,&tmp1,&tmp0);
                   init_eg(&eg_split_elim1); add_eg(&eg_split_elim1,&tmp1,&tmp0);
   
                   colstat = (int *)MALLOC_ATOMIC(spcol*sizeof(int));
                   bzero(colstat,spcol*sizeof(int));
                   for ( i = 0, nonzero=0; i < nsp; i++ )
                           for ( j = 0; j < spcol; j++ )
                                   if ( spmat[i][j] )
                                           nonzero++;
                   if ( DP_Print && nsp )
                           fprintf(asir_out,"spmat : %d x %d (nonzero=%f%%)...",
                                   nsp,spcol,((double)nonzero*100)/(nsp*spcol));
                   if ( nsp )
                           rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat);
                   else
                           rank = 0;
                   get_eg(&tmp1); add_eg(&eg_elim2,&tmp0,&tmp1);
                   init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1);
   
                   if ( DP_Print ) {
                           fprintf(asir_out,"done rank = %d\n",rank,row,col);
                           print_eg("Symb",&eg_split_symb);
                           print_eg("Elim1",&eg_split_elim1);
                           print_eg("Elim2",&eg_split_elim2);
                           fprintf(asir_out,"\n");
                   }
   
                   NZR += rank;
                   ZR += nsp0-rank;
   
                   if ( !rank )
                           continue;
   
                   for ( j = 0, i = 0; j < spcol; j++ )
                           if ( colstat[j] ) {
                                   mp0 = 0;
                                   NEXTMP(mp0,mp); mp->dl = st[j]; mp->c = STOI(1);
                                   for ( k = j+1; k < spcol; k++ )
                                           if ( !colstat[k] && spmat[i][k] ) {
                                                   NEXTMP(mp0,mp); mp->dl = st[k];
                                                   mp->c = STOI(spmat[i][k]);
                                   }
                                   NEXT(mp) = 0;
                                   MKDP(nv,mp0,nf); nf->sugar = dm->sugar;
                                   nh = newps_mod(nf,m);
                                   if ( nh == pscalen ) {
                                           psca = (unsigned int **)
                                                   REALLOC(psca,2*pscalen*sizeof(unsigned int *));
                                           pscalen *= 2;
                                   }
                                   dptoca(ps[nh],&psca[nh]);
                                   d = updpairs(d,g,nh);
                                   g = updbase(g,nh);
                                   gall = append_one(gall,nh);
                                   i++;
                           }
   
                   /* XXX free spmat[] explicitly */
                   for ( j = 0; j < nsp; j++ ) {
                           GC_free(spmat[j]);
                   }
           }
           if ( DP_Print ) {
                   print_eg("Symb",&eg_symb);
                   print_eg("Elim1",&eg_elim1);
                   print_eg("Elim2",&eg_elim2);
                   fflush(asir_out);
           }
           return g;
   }
   
   NODE gb_f4_mod_old(f,m)
   NODE f;
   int m;
   {
           int i,j,k,nh,row,col,nv;
           NODE r,g,gall;
           NODE s,s0;
           DP_pairs d,dm,dr,t;
           DP h,nf,f1,f2,f21,f21r,sp,sp1,sd,sdm,tdp;
           MP mp,mp0;
         NODE blist,bt,nt;          NODE blist,bt,nt;
         DL *ht,*at,*st;          DL *ht,*at,*st;
         int **spmat,**redmat;          int **spmat,**redmat;
Line 920  int m;
Line 1245  int m;
                 pss[i] = ps[i]->sugar;                  pss[i] = ps[i]->sugar;
                 psc[i] = BDY(ps[i])->c;                  psc[i] = BDY(ps[i])->c;
         }          }
         if ( GenTrace && (OXCheck >= 0) ) {          if ( GenTrace ) {
                 Q q;                  Q q;
                 STRING fname;                  STRING fname;
                 LIST input;                  LIST input;
                 NODE arg;                  NODE arg,t,t1;
                 Obj dmy;                  Obj dmy;
   
                   t = 0;
                   for ( i = psn-1; i >= 0; i-- ) {
                           MKNODE(t1,ps[i],t);
                           t = t1;
                   }
                   MKLIST(input,t);
   
                 STOQ(OXCheck,q);                  if ( OXCheck >= 0 ) {
                 MKSTR(fname,"register_input");                          STOQ(OXCheck,q);
                 MKLIST(input,f0);                          MKSTR(fname,"register_input");
                 arg = mknode(3,q,fname,input);                          arg = mknode(3,q,fname,input);
                 Pox_cmo_rpc(arg,&dmy);                          Pox_cmo_rpc(arg,&dmy);
                   } else if ( OXCheck < 0 ) {
                           MKNODE(AllTraceList,input,0);
                   }
         }          }
         for ( s0 = 0, i = 0; i < psn; i++ ) {          for ( s0 = 0, i = 0; i < psn; i++ ) {
                 NEXTNODE(s0,s); BDY(s) = (pointer)i;                  NEXTNODE(s0,s); BDY(s) = (pointer)i;
Line 959  int m;
Line 1294  int m;
                 else                  else
                         dp_ptozp(f,r);                          dp_ptozp(f,r);
                 if ( GenTrace && TraceList ) {                  if ( GenTrace && TraceList ) {
                           /* adust the denominator according to the final
                              content reduction */
                         divsp(CO,BDY(f)->c,BDY(*r)->c,&d);                          divsp(CO,BDY(f)->c,BDY(*r)->c,&d);
                         mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t);                          mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t);
                         ARG3(BDY((LIST)BDY(TraceList))) = t;                          ARG3(BDY((LIST)BDY(TraceList))) = t;
Line 1166  NODE subst;
Line 1503  NODE subst;
                 _dp_mod(a,m,subst,&psm[psn]);                  _dp_mod(a,m,subst,&psm[psn]);
         if ( GenTrace ) {          if ( GenTrace ) {
                 NODE tn,tr,tr1;                  NODE tn,tr,tr1;
                 LIST trace;                  LIST trace,trace1;
                   NODE arg;
                   Q q1,q2;
                   STRING fname;
                   Obj dmy;
   
                 /* reverse the TraceList */                  /* reverse the TraceList */
                 tn = TraceList;                  tn = TraceList;
Line 1175  NODE subst;
Line 1516  NODE subst;
                 }                  }
                 MKLIST(trace,tr);                  MKLIST(trace,tr);
                 if ( OXCheck >= 0 ) {                  if ( OXCheck >= 0 ) {
                         NODE arg;  
                         Q q1,q2;  
                         STRING fname;  
                         Obj dmy;  
   
                         STOQ(OXCheck,q1);                          STOQ(OXCheck,q1);
                         MKSTR(fname,"check_trace");                          MKSTR(fname,"check_trace");
                         STOQ(psn,q2);                          STOQ(psn,q2);
                         arg = mknode(5,q1,fname,a,q2,trace);                          arg = mknode(5,q1,fname,a,q2,trace);
                         Pox_cmo_rpc(arg,&dmy);                          Pox_cmo_rpc(arg,&dmy);
                   } else if ( OXCheck < 0 ) {
                           STOQ(psn,q1);
                           tn = mknode(2,q1,trace);
                           MKLIST(trace1,tn);
                           MKNODE(tr,trace1,AllTraceList);
                           AllTraceList = tr;
                 } else                  } else
                         dp_save(psn,(Obj)trace,"t");                          dp_save(psn,(Obj)trace,"t");
                 TraceList = 0;                  TraceList = 0;
Line 1416  NODE subst;
Line 1758  NODE subst;
                                 new_sugar = h->sugar;                                  new_sugar = h->sugar;
                         get_eg(&tnf0);                          get_eg(&tnf0);
                         t_0 = get_rtime();                          t_0 = get_rtime();
                         if ( PCoeffs )                          if ( PCoeffs || dp_fcoeffs )
                                 _dp_nf(gall,h,ps,!Top,&nf);                                  _dp_nf(gall,h,ps,!Top,&nf);
                         else                          else
                                 _dp_nf_ptozp(gall,h,ps,!Top,DP_Multiple,&nf);                                  _dp_nf_z(gall,h,ps,!Top,DP_Multiple,&nf);
                         if ( DP_Print )                          if ( DP_Print )
                                 fprintf(asir_out,"(%.3g)",get_rtime()-t_0);                                  fprintf(asir_out,"(%.3g)",get_rtime()-t_0);
                         get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1);                          get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1);
Line 1930  LIST *list;
Line 2272  LIST *list;
         STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1;          STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1;
         STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1;          STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1;
         STOQ(DP_Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1;          STOQ(DP_Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1;
           STOQ(DP_PrintShort,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PrintShort"); MKNODE(n1,name,n); n = n1;
         STOQ(DP_NFStat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NFStat"); MKNODE(n1,name,n); n = n1;          STOQ(DP_NFStat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NFStat"); MKNODE(n1,name,n); n = n1;
         STOQ(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); MKNODE(n1,name,n); n = n1;          STOQ(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); MKNODE(n1,name,n); n = n1;
         STOQ(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1;          STOQ(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1;
Line 2005  void init_stat() {
Line 2348  void init_stat() {
         init_eg(&eg_nf); init_eg(&eg_nfm); init_eg(&eg_znfm);          init_eg(&eg_nf); init_eg(&eg_nfm); init_eg(&eg_znfm);
         init_eg(&eg_pz); init_eg(&eg_np);          init_eg(&eg_pz); init_eg(&eg_np);
         init_eg(&eg_ra); init_eg(&eg_mc); init_eg(&eg_gc);          init_eg(&eg_ra); init_eg(&eg_mc); init_eg(&eg_gc);
         ZR = NZR = TP = NBP = NFP = NDP = 0;          ZR = NZR = TP = NMP = NBP = NFP = NDP = 0;
 }  }
   
 void print_stat() {  void print_stat() {
Line 2107  DP *rp;
Line 2450  DP *rp;
         *rp = d;          *rp = d;
 }  }
   
 void _dp_nf_ptozp(b,g,ps,full,multiple,r)  void _dp_nf_z(b,g,ps,full,multiple,r)
 NODE b;  NODE b;
 DP g;  DP g;
 DP *ps;  DP *ps;
Line 2322  VECT *rp;
Line 2665  VECT *rp;
         MKVECT(r,n); *rp = r;          MKVECT(r,n); *rp = r;
         for ( i = 0; i < n; i++ )          for ( i = 0; i < n; i++ )
                 mulq((Q)BDY(w)[i],(Q)c,(Q *)&BDY(r)[i]);                  mulq((Q)BDY(w)[i],(Q)c,(Q *)&BDY(r)[i]);
   }
   
   void dptoca(p,rp)
   DP p;
   unsigned int **rp;
   {
           int i;
           MP m;
           unsigned int *r;
   
           if ( !p )
                   *rp = 0;
           else {
                   for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ );
                   *rp = r = (unsigned int *)MALLOC_ATOMIC(i*sizeof(unsigned int));
                   for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ )
                           r[i] = ITOS(C(m));
           }
 }  }
   

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.36

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