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

Diff for /OpenXM_contrib2/asir2000/engine/Hgfs.c between version 1.17 and 1.18

version 1.17, 2001/09/03 07:01:06 version 1.18, 2001/10/09 01:36:10
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/Hgfs.c,v 1.16 2001/09/03 01:04:26 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/Hgfs.c,v 1.17 2001/09/03 07:01:06 noro Exp $ */
   
 #include "ca.h"  #include "ca.h"
   
 struct p_pair {  void lnfsf(int n,UM p0,UM p1,struct p_pair *list,UM np0,UM np1);
         UM p0;  
         UM p1;  
         struct p_pair *next;  
 };  
   
 void canzassf(UM,int,UM *);  int comp_dum(DUM a,DUM b)
 void lnfsf(int,UM,UM,struct p_pair *,UM,UM);  
 void minipolysf(UM,UM,UM);  
 void czsfum(UM,UM *);  
 void gensqfrsfum(UM,DUM);  
 void sfbmtop(BM,V,V,P *);  
 void cont_pp_sfp(VL,P,P *,P *);  
 void sfcsump(VL,P,P *);  
 void mulsfbmarray(int,BM,ML,int,int *,V,V,P *);  
 void const_term(P,UM);  
   
 void sfbsqfr(P,V,V,DCP *);  
 void sfusqfr(P,DCP *);  
   
 int comp_dum(a,b)  
 DUM a,b;  
 {  {
         if ( DEG(a->f) > DEG(b->f) )          if ( DEG(a->f) > DEG(b->f) )
                 return -1;                  return -1;
Line 33  DUM a,b;
Line 14  DUM a,b;
                 return 0;                  return 0;
 }  }
   
 void fctrsf(p,dcp)  void fctrsf(P p,DCP *dcp)
 P p;  
 DCP *dcp;  
 {  {
         int n,i,j,k;          int n,i,j,k;
         DCP dc,dc0;          DCP dc,dc0;
         P lc;          P lc;
         P zp;  
         UM mp;          UM mp;
         UM *tl;          UM *tl;
           Obj obj;
         struct oDUM *udc,*udc1;          struct oDUM *udc,*udc1;
   
         simp_ff(p,&zp); p = zp;          simp_ff((Obj)p,&obj); p = (P)obj;
         if ( !p ) {          if ( !p ) {
                 *dcp = 0; return;                  *dcp = 0; return;
         }          }
Line 92  DCP *dcp;
Line 71  DCP *dcp;
         NEXT(dc) = 0; *dcp = dc0;          NEXT(dc) = 0; *dcp = dc0;
 }  }
   
 void gensqfrsfum(p,dc)  void gensqfrsfum(UM p,struct oDUM *dc)
 UM p;  
 struct oDUM *dc;  
 {  {
         int n,i,j,d,mod;          int n,i,j,d,mod;
         UM t,s,g,f,f1,b;          UM t,s,g,f,f1,b;
Line 147  struct oDUM *dc;
Line 124  struct oDUM *dc;
         }          }
 }  }
   
 void randsfum(d,p)  void randsfum(int d,UM p)
 int d;  
 UM p;  
 {  {
         int i;          int i;
   
Line 159  UM p;
Line 134  UM p;
         p->d = i;          p->d = i;
 }  }
   
 void pwrmodsfum(p,e,f,pr)  void pwrmodsfum(UM p,int e,UM f,UM pr)
 int e;  
 UM p,f,pr;  
 {  {
         UM wt,ws,q;          UM wt,ws,q;
   
Line 189  UM p,f,pr;
Line 162  UM p,f,pr;
         }          }
 }  }
   
 void spwrsfum(m,f,e,r)  void spwrsfum(UM m,UM f,N e,UM r)
 UM f,m,r;  
 N e;  
 {  {
         UM t,s,q;          UM t,s,q;
         N e1;          N e1;
Line 213  N e;
Line 184  N e;
         }          }
 }  }
   
 void tracemodsfum(m,f,e,r)  void tracemodsfum(UM m,UM f,int e,UM r)
 UM f,m,r;  
 int e;  
 {  {
         UM t,s,q,u;          UM t,s,q,u;
         int i;          int i;
Line 235  int e;
Line 204  int e;
         cpyum(s,r);          cpyum(s,r);
 }  }
   
 void make_qmatsf(p,tab,mp)  void make_qmatsf(UM p,UM *tab,int ***mp)
 UM p;  
 UM *tab;  
 int ***mp;  
 {  {
         int n,i,j;          int n,i,j;
         int *c;          int *c;
Line 259  int ***mp;
Line 225  int ***mp;
                 mat[i][i] = _subsf(mat[i][i],one);                  mat[i][i] = _subsf(mat[i][i],one);
 }  }
   
 void nullsf(mat,n,ind)  void nullsf(int **mat,int n,int *ind)
 int **mat;  
 int *ind;  
 int n;  
 {  {
         int i,j,l,s,h,inv;          int i,j,l,s,h,inv;
         int *t,*u;          int *t,*u;
Line 294  int n;
Line 257  int n;
         }          }
 }  }
   
 void null_to_solsf(mat,ind,n,r)  void null_to_solsf(int **mat,int *ind,int n,UM *r)
 int **mat;  
 int *ind;  
 int n;  
 UM *r;  
 {  {
         int i,j,k,l;          int i,j,k,l;
         int *c;          int *c;
Line 327  nullsf(mat,n,ind)
Line 286  nullsf(mat,n,ind)
 null_to_solsf(ind,n,r)  null_to_solsf(ind,n,r)
 */  */
   
 void czsfum(f,r)  void czsfum(UM f,UM *r)
 UM f,*r;  
 {  {
         int i,j;          int i,j;
         int d,n,ord;          int d,n,ord;
Line 382  UM f,*r;
Line 340  UM f,*r;
         r[j] = 0;          r[j] = 0;
 }  }
   
 int berlekampsf(p,df,tab,r)  int berlekampsf(UM p,int df,UM *tab,UM *r)
 UM p;  
 int df;  
 UM *tab,*r;  
 {  {
         int n,i,j,k,nf,d,nr;          int n,i,j,k,nf,d,nr;
         int **mat;          int **mat;
Line 431  UM *tab,*r;
Line 386  UM *tab,*r;
                         }                          }
                 }                  }
         }          }
           /* NOT REACHED */
           error("berlekampsf : cannot happen");
           return 0;
 }  }
   
 void minipolysf(f,p,mp)  void minipolysf(UM f,UM p,UM mp)
 UM f,p,mp;  
 {  {
         struct p_pair *list,*l,*l1,*lprev;          struct p_pair *list,*l,*l1,*lprev;
         int n,d;          int n,d;
Line 469  UM f,p,mp;
Line 426  UM f,p,mp;
         }          }
 }  }
   
 void lnfsf(n,p0,p1,list,np0,np1)  void lnfsf(int n,UM p0,UM p1,struct p_pair *list,UM np0,UM np1)
 int n;  
 UM p0,p1;  
 struct p_pair *list;  
 UM np0,np1;  
 {  {
         int inv,h,d1;          int h,d1;
         UM t0,t1,s0,s1;          UM t0,t1,s0,s1;
         struct p_pair *l;          struct p_pair *l;
   
Line 492  UM np0,np1;
Line 445  UM np0,np1;
         }          }
 }  }
   
 int find_rootsf(p,root)  int find_rootsf(UM p,int *root)
 UM p;  
 int *root;  
 {  {
         UM *r;          UM *r;
         int i,j,n;          int i,n;
   
         n = DEG(p);          n = DEG(p);
         r = ALLOCA((DEG(p))*sizeof(UM));          r = ALLOCA((DEG(p))*sizeof(UM));
Line 507  int *root;
Line 458  int *root;
         return n;          return n;
 }  }
   
 void canzassf(f,d,r)  void canzassf(UM f,int d,UM *r)
 UM f,*r;  
 int d;  
 {  {
         UM t,s,u,w,g,o;          UM t,s,u,w,g,o;
         N n1,n2,n3,n4,n5;          N n1,n2,n3,n4,n5;
         UM *b;          UM *b;
         int n,m,i,q,ed;          int n,q,ed;
   
         if ( DEG(f) == d ) {          if ( DEG(f) == d ) {
                 r[0] = UMALLOC(d); cpyum(f,r[0]);                  r[0] = UMALLOC(d); cpyum(f,r[0]);
Line 560  void ptosfbm(int,P,BM);
Line 509  void ptosfbm(int,P,BM);
   
 /* f = f(x,y) */  /* f = f(x,y) */
   
 void sfhensel(count,f,x,evp,sfp,listp)  void sfhensel(int count,P f,V x,GFS *evp,P *sfp,ML *listp)
 int count;  
 P f;  
 V x;  
 GFS *evp;  
 P *sfp;  
 ML *listp;  
 {  {
         int i,j;          int i;
         int fn,n;          int fn;
         ML rlist;          ML rlist;
         BM fl;          BM fl;
         VL vl,nvl;          VL vl,nvl;
         V y;          V y;
         int dx,dy,mev;          int dx,dy;
         GFS ev;          GFS ev;
         P f1,t,yev,c,sf;          P f1,t,c,sf;
         DCP dc;          DCP dc;
         UM w,w1,q,fm,hm;          UM q,fm,hm;
         UM *gm;          UM *gm;
         struct oEGT tmp0,tmp1,eg_hensel,eg_hensel_t;          struct oEGT tmp0,tmp1,eg_hensel,eg_hensel_t;
   
Line 662  ML *listp;
Line 605  ML *listp;
   
 /* main variable of f = x */  /* main variable of f = x */
   
 int sfberle(vl,f,count,ev,dcp)  int sfberle(VL vl,P f,int count,GFS *ev,DCP *dcp)
 VL vl;  
 P f;  
 int count;  
 GFS *ev;  
 DCP *dcp;  
 {  {
         UM wf,wf1,wf2,wfs,gcd;          UM wf,wf1,wf2,wfs,gcd;
         ML flist;          int fn,n;
         int fn,fn1,n;  
         GFS m,fm;          GFS m,fm;
         DCP dc,dct,dc0;          DCP dc,dct,dc0;
         VL nvl;          VL nvl;
         V x,y;          V x,y;
         P g,lc,lc0,f0;          P lc,lc0,f0;
           Obj obj;
         int j,q1,index,i;          int j,q1,index,i;
   
         clctv(vl,f,&nvl); vl = nvl;          clctv(vl,f,&nvl); vl = nvl;
         x = vl->v; y = vl->next->v;          x = vl->v; y = vl->next->v;
         simp_ff(f,&g); g = f;          simp_ff((Obj)f,&obj); f = (P)obj;
         n = QTOS(DEG(DC(f)));          n = QTOS(DEG(DC(f)));
         wf = W_UMALLOC(n); wf1 = W_UMALLOC(n); wf2 = W_UMALLOC(n);          wf = W_UMALLOC(n); wf1 = W_UMALLOC(n); wf2 = W_UMALLOC(n);
         wfs = W_UMALLOC(n); gcd = W_UMALLOC(n);          wfs = W_UMALLOC(n); gcd = W_UMALLOC(n);
Line 716  DCP *dcp;
Line 654  DCP *dcp;
         }          }
 }  }
   
 void sfgcdgen(f,blist,clistp)  void sfgcdgen(P f,ML blist,ML *clistp)
 P f;  
 ML blist,*clistp;  
 {  {
         int i;          int i;
         int n,d,np;          int n,d,np;
Line 747  ML blist,*clistp;
Line 683  ML blist,*clistp;
   
 /* f = g0*h0 mod y -> f = gk*hk mod y^(dy+1), f is replaced by hk */  /* f = g0*h0 mod y -> f = gk*hk mod y^(dy+1), f is replaced by hk */
   
 void sfhenmain2(f,g0,h0,dy,gp)  void sfhenmain2(BM f,UM g0,UM h0,int dy,BM *gp)
 BM f;  
 UM g0,h0;  
 int dy;  
 BM *gp;  
 {  {
         int i,j,k,l;          int i,k;
         int *px,*py;          int dx;
         int **pp,**pp1;          UM wt,wa,wb,q,w1,w2,wh1,wg1,ws;
         int dx,np,dr,tmp;  
         UM wt,wa,wb,wm,q,w1,w2,wh1,wg1,ws;  
         UM wc,wd,we,wz;          UM wc,wd,we,wz;
         BM wb0,wb1;          BM wb0,wb1;
         int dg,dh;          int dg,dh;
Line 858  BM *gp;
Line 788  BM *gp;
   
 /* fl->c[i] = coef_y(f,i) */  /* fl->c[i] = coef_y(f,i) */
   
 void ptosfbm(dy,f,fl)  void ptosfbm(int dy,P f,BM fl)
 int dy;  
 P f;  
 BM fl;  
 {  {
         DCP dc;          DCP dc;
         int d,i,dx;          int d,i,dx;
Line 885  BM fl;
Line 812  BM fl;
   
 /* x : main variable */  /* x : main variable */
   
 void sfbmtop(f,x,y,fp)  void sfbmtop(BM f,V x,V y,P *fp)
 BM f;  
 V x,y;  
 P *fp;  
 {  {
         UM *c;          UM *c;
         int i,j,d,a,dy;          int i,j,d,a,dy;
Line 926  P *fp;
Line 850  P *fp;
                 *fp = 0;                  *fp = 0;
 }  }
   
 void sfsqfr(f,dcp)  void sfsqfr(P f,DCP *dcp)
 P f;  
 DCP *dcp;  
 {  {
         P g;          Obj obj;
         V x;  
         DCP dc;          DCP dc;
         VL vl;          VL vl;
   
         simp_ff(f,&g); f = g;          simp_ff((Obj)f,&obj); f = (P)obj;
         clctv(CO,f,&vl);          clctv(CO,f,&vl);
         if ( !vl ) {          if ( !vl ) {
                 /* f is a const */                  /* f is a const */
Line 943  DCP *dcp;
Line 864  DCP *dcp;
         } else if ( !NEXT(vl) )          } else if ( !NEXT(vl) )
                 sfusqfr(f,dcp);                  sfusqfr(f,dcp);
         else if ( !NEXT(NEXT(vl)) )          else if ( !NEXT(NEXT(vl)) )
                 sfbsqfr(f,x,NEXT(vl)->v,dcp);                  sfbsqfr(f,vl->v,NEXT(vl)->v,dcp);
         else          else
                 error("sfsqfr : not implemented yet");                  error("sfsqfr : not implemented yet");
 }  }
   
 void sfusqfr(f,dcp)  void sfusqfr(P f,DCP *dcp)
 P f;  
 DCP *dcp;  
 {  {
         DCP dc,dct;          DCP dc,dct;
         struct oDUM *udc;          struct oDUM *udc;
Line 978  DCP *dcp;
Line 897  DCP *dcp;
         *dcp = dct;          *dcp = dct;
 }  }
   
 void sfbsqfr(f,x,y,dcp)  void sfbsqfr(P f,V x,V y,DCP *dcp)
 P f;  
 V x,y;  
 DCP *dcp;  
 {  {
         P t,rf,cx,cy;          P t,rf,cx,cy;
         VL vl,rvl;          VL vl,rvl;
Line 1005  DCP *dcp;
Line 921  DCP *dcp;
   
 void sfdtest(P,ML,V,V,DCP *);  void sfdtest(P,ML,V,V,DCP *);
   
 void sfbfctr(f,x,y,dcp)  void sfbfctr(P f,V x,V y,DCP *dcp)
 P f;  
 V x,y;  
 DCP *dcp;  
 {  {
         ML list;          ML list;
         P sf;          P sf;
Line 1043  DCP *dcp;
Line 956  DCP *dcp;
   
 /* f = f(x,y) = list->c[0]*list->c[1]*... mod y^(list->bound+1) */  /* f = f(x,y) = list->c[0]*list->c[1]*... mod y^(list->bound+1) */
   
 void sfdtest(f,list,x,y,dcp)  void sfdtest(P f,ML list,V x,V y,DCP *dcp)
 P f;  
 ML list;  
 V x,y;  
 DCP *dcp;  
 {  {
         int np,dx,dy;          int np,dx,dy;
         int i,j,k;          int i,j,k;
         int *win;          int *win;
         P g,lcg,factor,cofactor,lcyx;          P g,lcg,factor,cofactor,lcyx;
         P t,csum;          P csum;
         DCP dcf,dcf0,dc;          DCP dcf,dcf0,dc;
         BM *c;          BM *c;
         BM lcy;          BM lcy;
Line 1147  DCP *dcp;
Line 1056  DCP *dcp;
 }  }
   
 /* lcy = LC(g), lcg = lcy*g, lcg0 = const part of lcg */  /* lcy = LC(g), lcg = lcy*g, lcg0 = const part of lcg */
 int sfdtestmain(vl,lcg,lcg0,lcy,csum,list,k,in,fp,cofp)  int sfdtestmain(VL vl,P lcg,UM lcg0,BM lcy,P csum,ML list,
 VL vl;          int k,int *in,P *fp,P *cofp)
 P lcg;  
 UM lcg0;  
 BM lcy;  
 P csum;  
 ML list;  
 int k;  
 int *in;  
 P *fp,*cofp;  
 {  {
         P fmul,csumg,q,cont;          P fmul,csumg,q,cont;
         V x,y;          V x,y;
Line 1181  P *fp,*cofp;
Line 1082  P *fp,*cofp;
                 return 0;                  return 0;
 }  }
   
 void const_term(f,c)  void const_term(P f,UM c)
 P f;  
 UM c;  
 {  {
         DCP dc;          DCP dc;
   
Line 1194  UM c;
Line 1093  UM c;
                 DEG(c) = -1;                  DEG(c) = -1;
 }  }
   
 void const_term_sfbm(f,c)  void const_term_sfbm(BM f,UM c)
 BM f;  
 UM c;  
 {  {
         int i,dy;          int i,dy;
   
Line 1211  UM c;
Line 1108  UM c;
   
 /* lcy*(product of const part) | lcg0 ? */  /* lcy*(product of const part) | lcg0 ? */
   
 int sfctest(lcg0,lcy,list,k,in)  int sfctest(UM lcg0,BM lcy,ML list,int k,int *in)
 UM lcg0;  
 BM lcy;  
 ML list;  
 int k;  
 int *in;  
 {  {
         DCP dc;  
         int dy,i,dr;          int dy,i,dr;
         UM t,s,u,w;          UM t,s,u,w;
         BM *l;          BM *l;
Line 1249  int *in;
Line 1140  int *in;
   
 /* main var of f is x */  /* main var of f is x */
   
 void mulsfbmarray(dx,lcy,list,k,in,x,y,g)  void mulsfbmarray(int dx,BM lcy,ML list,int k,int *in,V x,V y,P *g)
 int dx;  
 BM lcy;  
 ML list;  
 int k;  
 int *in;  
 V x,y;  
 P *g;  
 {  {
         int dy,i;          int dy,i;
         BM wb0,wb1,t,lcbm;          BM wb0,wb1,t;
         BM *l;          BM *l;
   
         dy = list->bound;          dy = list->bound;
Line 1275  P *g;
Line 1159  P *g;
         sfbmtop(wb0,x,y,g);          sfbmtop(wb0,x,y,g);
 }  }
   
 void sfcsump(vl,f,s)  void sfcsump(VL vl,P f,P *s)
 VL vl;  
 P f;  
 P *s;  
 {  {
         P t,u;          P t,u;
         DCP dc;          DCP dc;
Line 1291  P *s;
Line 1172  P *s;
   
 /* *fp = primitive part of f w.r.t. x */  /* *fp = primitive part of f w.r.t. x */
   
 void cont_pp_sfp(vl,f,cp,fp)  void cont_pp_sfp(VL vl,P f,P *cp,P *fp)
 VL vl;  
 P f;  
 P *cp,*fp;  
 {  {
         V x,y;          V x,y;
         int d;          int d;
Line 1325  P *cp,*fp;
Line 1203  P *cp,*fp;
         }          }
 }  }
   
 int divtp_by_sfbm(vl,f,g,qp)  int divtp_by_sfbm(VL vl,P f,P g,P *qp)
 VL vl;  
 P f,g;  
 P *qp;  
 {  {
         V x,y;          V x,y;
         int fx,fy,gx,gy;          int fx,fy,gx,gy;
Line 1369  P *qp;
Line 1244  P *qp;
         if ( j >= 0 )          if ( j >= 0 )
                 return 0;                  return 0;
         sfbmtop(ql,x,y,qp);          sfbmtop(ql,x,y,qp);
           return 1;
 }  }
   
 /* XXX generate an irreducible poly of degree n */  /* XXX generate an irreducible poly of degree n */
   
 extern int current_gfs_q1;  extern int current_gfs_q1;
   
 void generate_defpoly_sfum(n,dp)  void generate_defpoly_sfum(int n,UM *dp)
 int n;  
 UM *dp;  
 {  {
         UM r,dr,t,g;          UM r,dr,t,g;
         UM *f;          UM *f;

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

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