[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.25 and 1.28

version 1.25, 2001/09/10 05:55:14 version 1.28, 2001/09/13 03:04:27
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.24 2001/09/07 08:54:57 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.27 2001/09/11 08:56:47 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"
   
   #if defined(__GNUC__)
   #define INLINE inline
   #elif defined(VISUAL)
   #define INLINE __inline
   #else
   #define INLINE
   #endif
   
 #define ITOS(p) (((unsigned int)(p))&0x7fffffff)  #define ITOS(p) (((unsigned int)(p))&0x7fffffff)
 #define STOI(i) ((P)((unsigned int)(i)|0x80000000))  #define STOI(i) ((P)((unsigned int)(i)|0x80000000))
   
Line 142  double get_rtime();
Line 150  double get_rtime();
 void _dpmod_to_vect(DP,DL *,int *);  void _dpmod_to_vect(DP,DL *,int *);
 void dp_to_vect(DP,DL *,Q *);  void dp_to_vect(DP,DL *,Q *);
 NODE dp_dllist(DP f);  NODE dp_dllist(DP f);
   DLBUCKET dp_dllist_bucket(DP f);
 NODE symb_merge(NODE,NODE,int),_symb_merge(NODE,NODE,int);  NODE symb_merge(NODE,NODE,int),_symb_merge(NODE,NODE,int);
   DLBUCKET symb_merge_bucket(DLBUCKET,DLBUCKET,int);
 extern int dp_nelim;  extern int dp_nelim;
 extern int dp_fcoeffs;  extern int dp_fcoeffs;
 static DP *ps,*psm;  static DP *ps,*psm;
Line 182  int doing_f4;
Line 192  int doing_f4;
 NODE TraceList;  NODE TraceList;
 NODE AllTraceList;  NODE AllTraceList;
   
 int eqdl(nv,dl1,dl2)  INLINE int eqdl(nv,dl1,dl2)
 int nv;  int nv;
 DL dl1,dl2;  DL dl1,dl2;
 {  {
Line 232  CDP *b;
Line 242  CDP *b;
         for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ );          for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ );
         r = (CDP)MALLOC(sizeof(struct oCDP));          r = (CDP)MALLOC(sizeof(struct oCDP));
         r->len = len;          r->len = len;
         r->body = (CMP)MALLOC(sizeof(struct oCMP)*len);          r->body = (CM)MALLOC(sizeof(struct oCM)*len);
   
         for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) {          for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) {
                 for ( ; !eqdl(nv,m->dl,at[i]); i++ );                  for ( ; !eqdl(nv,m->dl,at[i]); i++ );
Line 255  CDP *rp;
Line 265  CDP *rp;
                 if ( a[i] ) nz++;                  if ( a[i] ) nz++;
         *rp = r = (CDP)MALLOC(sizeof(struct oCDP));          *rp = r = (CDP)MALLOC(sizeof(struct oCDP));
         r->len = nz;          r->len = nz;
         r->body = (CMP)MALLOC(sizeof(struct oCMP)*nz);          r->body = (CM)MALLOC(sizeof(struct oCM)*nz);
         for ( i = 0, j = 0; i < n; i++ ) {          for ( i = 0, j = 0; i < n; i++ ) {
                 if ( a[i] ) {                  if ( a[i] ) {
                         r->body[j].index = i;                          r->body[j].index = i;
Line 296  DP f;
Line 306  DP f;
         return mp0;          return mp0;
 }  }
   
   void print_dlbucket(d,nv)
   DLBUCKET d;
   int nv;
   {
           int i;
           NODE n;
   
           for ( ; d; d = NEXT(d) ) {
                   fprintf(stderr,"td = %d\n",d->td);
                   for ( n = BDY(d); n; n = NEXT(n) ) {
                           fprintf(stderr,"<");
                           for ( i = 0; i < nv; i++ ) {
                                   fprintf(stderr,"%d",((DL)BDY(n))->d[i]);
                                   if ( i != nv-1 )
                                           fprintf(stderr," ");
                           }
                           fprintf(stderr,">");
                   }
                   fprintf(stderr,"\n");
           }
   }
   
   DLBUCKET dp_dllist_bucket(f)
   DP f;
   {
           MP m;
           NODE n,n0;
           DLBUCKET d,d0;
           int td;
   
           if ( !f )
                   return 0;
           d0 = 0;
           m = BDY(f);
           do {
                   NEXTDLBUCKET(d0,d);
                   n0 = 0;
                   d->td = td = m->dl->td;
                   do {
                           NEXTNODE(n0,n);
                           BDY(n) = (pointer)m->dl;
                           m = NEXT(m);
                   } while ( m && m->dl->td == td );
                   NEXT(n) = 0;
                   BDY(d) = n0;
           } while ( m );
           NEXT(d) = 0;
           return d0;
   }
   
 void pdl(f)  void pdl(f)
 NODE f;  NODE f;
 {  {
Line 486  LIST f,v;
Line 546  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 498  LIST *rp;
Line 558  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 519  int m;
Line 583  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 532  LIST *rp;
Line 596  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 543  LIST *rp;
Line 609  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);          x = gb_f4_mod(s,m);
         reduceall_mod(x,m,&xx); x = xx;          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));
         }          }
Line 678  int m;
Line 746  int m;
 {  {
         int i,j,k,nh,row,col,nv;          int i,j,k,nh,row,col,nv;
         NODE r,g,gall;          NODE r,g,gall;
         NODE s,s0;          NODE sb;
           DLBUCKET s,s0,s1;
         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;
Line 713  int m;
Line 782  int m;
                         _dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp);                          _dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp);
                         if ( sp ) {                          if ( sp ) {
                                 MKNODE(bt,sp,blist); blist = bt;                                  MKNODE(bt,sp,blist); blist = bt;
                                 s0 = symb_merge(s0,dp_dllist(sp),nv);                                  s0 = symb_merge_bucket(s0,dp_dllist_bucket(sp),nv);
   /*                              print_dlbucket(s0,nv); */
                         }                          }
                 }                  }
                 /* s0 : all the terms appeared in symbolic reduction */                  /* s0 : all the terms appeared in symbolic reduction */
 #if 0  #if 0
                 for ( s = s0, nred = 0; s; s = NEXT(s) ) {                  for ( s = s0, nred = 0; s; s = NEXT(s) ) {
                         for ( j = psn-1; j >= 0; j-- )                          sb = BDY(s);
                                 if ( _dl_redble(BDY(ps[j])->dl,BDY(s),nv) )                          for ( ; sb; sb = NEXT(sb) ) {
                                         break;                                  for ( j = psn-1; j >= 0; j-- )
                         if ( j >= 0 ) {                                          if ( _dl_redble(BDY(ps[j])->dl,BDY(sb),nv) )
                                 dltod(BDY(s),nv,&tdp);                                                  break;
                                 dp_subd(tdp,ps[j],&sd);                                  if ( j >= 0 ) {
                                 for ( k = 0, i = 0; k < nv; k++ )                                          dltod(BDY(sb),nv,&tdp);
                                         if ( BDY(sd)->dl->d[k] )                                          dp_subd(tdp,ps[j],&sd);
                                                 i++;                                          for ( k = 0, i = 0; k < nv; k++ )
                                 fprintf(stderr,"%c ",i<=1 ? 'o' : 'x');                                                  if ( BDY(sd)->dl->d[k] )
                                 _dp_mod(sd,m,0,&sdm);                                                          i++;
                                 mulmd_dup(m,sdm,ps[j],&f2);                                          fprintf(stderr,"%c ",i<=1 ? 'o' : 'x');
                                 MKNODE(bt,f2,blist); blist = bt;                                          _dp_mod(sd,m,0,&sdm);
                                 s = symb_merge(s,dp_dllist(f2),nv);                                          mulmd_dup(m,sdm,ps[j],&f2);
                                 nred++;                                          MKNODE(bt,f2,blist); blist = bt;
                                           /* merge the highest degree part into sb */
                                           s1 = dp_dllist_bucket(f2);
                                           symb_merge(sb,BDY(s1),nv);
                                           /* merge the rest into s */
                                           symb_merge_bucket(s,NEXT(s1),nv);
                                           nred++;
                                   }
                         }                          }
                 }                  }
 #else  #else
                 for ( s = s0, nred = 0; s; s = NEXT(s) ) {                  for ( s = s0, nred = 0; s; s = NEXT(s) ) {
                         for ( r = gall; r; r = NEXT(r) )                          sb = BDY(s);
                                 if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) )                          for ( ; sb; sb = NEXT(sb) ) {
                                         break;                                  for ( r = gall; r; r = NEXT(r) )
                         if ( r ) {                                          if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(sb),nv) )
                                 dltod(BDY(s),nv,&tdp);                                                  break;
                                 dp_subd(tdp,ps[(int)BDY(r)],&sd);                                  if ( r ) {
                                 _dp_mod(sd,m,0,&sdm);                                          dltod(BDY(sb),nv,&tdp);
                                 mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2);                                          dp_subd(tdp,ps[(int)BDY(r)],&sd);
                                 MKNODE(bt,f2,blist); blist = bt;                                          _dp_mod(sd,m,0,&sdm);
                                 s = symb_merge(s,dp_dllist(f2),nv);                                          mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2);
                                 nred++;                                          MKNODE(bt,f2,blist); blist = bt;
                                           /* merge the highest degree part into sb */
                                           s1 = dp_dllist_bucket(f2);
                                           symb_merge(sb,BDY(s1),nv);
                                           /* merge the rest into s */
                                           symb_merge_bucket(s,NEXT(s1),nv);
                                           nred++;
                                   }
                         }                          }
                 }                  }
 #endif  #endif
                 fprintf(stderr,"\n");  
   
                 get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1);                  get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1);
                 init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1);                  init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1);
   
Line 767  int m;
Line 849  int m;
                         ht[i] = BDY((DP)BDY(r))->dl;                          ht[i] = BDY((DP)BDY(r))->dl;
   
                 /* col = number of all terms */                  /* col = number of all terms */
                 for ( s = s0, col = 0; s; s = NEXT(s), col++ );                  for ( s = s0, col = 0; s; s = NEXT(s) )
                           for ( sb = BDY(s); sb; sb = NEXT(sb) )
                                   col++;
   
                 /* head terms of all terms */                  /* head terms of all terms */
                 at = (DL *)MALLOC(col*sizeof(DL));                  at = (DL *)MALLOC(col*sizeof(DL));
                 for ( s = s0, i = 0; i < col; s = NEXT(s), i++ )                  for ( s = s0, i = 0; i < col; s = NEXT(s) )
                         at[i] = (DL)BDY(s);                          for ( sb = BDY(s); sb; sb = NEXT(sb), i++ )
                                   at[i] = (DL)BDY(sb);
   
                 /* store coefficients separately in spmat and redmat */                  /* store coefficients separately in spmat and redmat */
                 nsp = row-nred;                  nsp = row-nred;

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.28

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