[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.8 and 1.9

version 1.8, 2001/06/25 10:01:28 version 1.9, 2001/06/26 03:00:40
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/Hgfs.c,v 1.7 2001/06/25 06:10:48 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/Hgfs.c,v 1.8 2001/06/25 10:01:28 noro Exp $ */
   
 #include "ca.h"  #include "ca.h"
   
Line 17  void sfbmtop(int,BM,V,V,P *);
Line 17  void sfbmtop(int,BM,V,V,P *);
 void pp_sfp(VL,P,P *);  void pp_sfp(VL,P,P *);
 void sfcsump(VL,P,P *);  void sfcsump(VL,P,P *);
 void mulsfbmarray(int,BM,ML,int,int *,V,V,P *);  void mulsfbmarray(int,BM,ML,int,int *,V,V,P *);
   void const_term(P,UM);
   
 void fctrsf(p,dcp)  void fctrsf(p,dcp)
 P p;  P p;
Line 1030  P *fp;
Line 1031  P *fp;
   
 void sfdtest(P,ML,V,V,DCP *);  void sfdtest(P,ML,V,V,DCP *);
   
 void sfbfctr(f,x,y,evp,dcp)  void sfbfctr(f,x,y,dcp)
 P f;  P f;
 V x,y;  V x,y;
 GFS *evp;  
 DCP *dcp;  DCP *dcp;
 {  {
         ML list;          ML list;
         P sf;          P sf;
           GFS ev;
           DCP dc,dct;
           BM fl;
           int n,bound;
   
         /* sf(x) = f(x+ev) = list->c[0]*list->c[1]*... */          /* sf(x) = f(x+ev) = list->c[0]*list->c[1]*... */
         sfhensel(5,f,x,evp,&sf,&list);          sfhensel(5,f,x,&ev,&sf,&list);
         sfdtest(sf,list,x,y,dcp);          sfdtest(sf,list,x,y,&dc);
           n = getdeg(x,sf);
           bound = list->bound;
           W_BMALLOC(n,bound,fl);
           for ( dct = dc; dct; dct = NEXT(dct) ) {
                   ptosfbm(bound,COEF(dct),fl);
                   shiftsfbm(bound,fl,_chsgnsf(FTOIF(CONT(ev))));
                   sfbmtop(bound,fl,x,y,&COEF(dct));
           }
           *dcp = dc;
 }  }
   
 /* f = f(x,y) = list->c[0]*list->c[1]*... mod y^list->bound */  /* f = f(x,y) = list->c[0]*list->c[1]*... mod y^list->bound */
Line 1056  DCP *dcp;
Line 1069  DCP *dcp;
         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 csum,csumt;          P t,csum;
         DCP dcf,dcf0,dc;          DCP dcf,dcf0,dc;
         BM *c;          BM *c;
         BM lcy;          BM lcy;
           UM lcg0;
         ML wlist;          ML wlist;
         struct oVL vl1,vl0;          struct oVL vl1,vl0;
         VL vl;          VL vl;
Line 1068  DCP *dcp;
Line 1082  DCP *dcp;
         /* vl = [x,y] */          /* vl = [x,y] */
         vl0.v = x; vl0.next = &vl1; vl1.v = y; vl1.next = 0; vl = &vl0;          vl0.v = x; vl0.next = &vl1; vl1.v = y; vl1.next = 0; vl = &vl0;
   
           /* setup various structures and arrays */
         n = UDEG(f); np = list->n; bound = list->bound; win = W_ALLOC(np+1);          n = UDEG(f); np = list->n; bound = list->bound; win = W_ALLOC(np+1);
   
         /* csum = lc(f)*f(1) */  
         sfcsump(vl,f,&csum); mulp(vl,csum,COEF(DC(f)),&csumt); csum = csumt;  
   
         wlist = W_MLALLOC(np); wlist->n = list->n;          wlist = W_MLALLOC(np); wlist->n = list->n;
         wlist->bound = list->bound;          wlist->bound = list->bound;
         c = (BM *)COEF(wlist);          c = (BM *)COEF(wlist);
         bcopy((char *)COEF(list),(char *)c,(int)(sizeof(BM)*np));          bcopy((char *)COEF(list),(char *)c,(int)(sizeof(BM)*np));
   
           lcg0 = W_UMALLOC(2*bound);
   
         /* initialize g by f */          /* initialize g by f */
         g = f; mulp(vl,g,COEF(DC(g)),&lcg);          g = f;
   
           /* initialize lcg */
           mulp(vl,g,COEF(DC(g)),&lcg);
   
           /* initialize lcg0 */
           const_term(lcg,lcg0);
   
           /* initialize csum = lcg(1) */
           sfcsump(vl,lcg,&csum);
   
         /* initialize lcy by LC(f) */          /* initialize lcy by LC(f) */
         W_BMALLOC(0,bound,lcy);          W_BMALLOC(0,bound,lcy);
         NEWDC(dc); COEF(dc) = COEF(DC(g));          NEWDC(dc); COEF(dc) = COEF(DC(g)); DEG(dc) = 0;
         DEG(dc) = 0;  
         NEWP(lcyx); VR(lcyx) = x; DC(lcyx) = dc;          NEWP(lcyx); VR(lcyx) = x; DC(lcyx) = dc;
         ptosfbm(bound,lcyx,lcy);          ptosfbm(bound,lcyx,lcy);
   
         fprintf(stderr,"np = %d\n",np);          fprintf(stderr,"np = %d\n",np);
         for ( g = f, k = 1, dcf = dcf0 = 0, win[0] = 1, --np, z = 0; ; z++ ) {          for ( g = f, k = 1, dcf = dcf0 = 0, win[0] = 1, --np, z = 0; ; z++ ) {
                 if ( !(z % 1000) ) fprintf(stderr,".");                  if ( !(z % 1000) ) fprintf(stderr,".");
                 if ( sfdtestmain(vl,lcg,lcy,csum,wlist,k,win,&factor,&cofactor) ) {                  if ( sfdtestmain(vl,lcg,lcg0,lcy,csum,wlist,k,win,&factor,&cofactor) ) {
                         NEXTDC(dcf0,dcf); DEG(dcf) = ONE; COEF(dcf) = factor;                          NEXTDC(dcf0,dcf); DEG(dcf) = ONE; COEF(dcf) = factor;
                         g = cofactor;                          g = cofactor;
   
                         /* update csum */  
                         sfcsump(vl,g,&csum); mulp(vl,csum,COEF(DC(g)),&csumt); csum = csumt;  
   
                         /* update lcg */                          /* update lcg */
                         mulp(vl,g,COEF(DC(g)),&lcg);                          mulp(vl,g,COEF(DC(g)),&lcg);
   
                           /* update lcg0 */
                           const_term(lcg,lcg0);
   
                           /* update csum */
                           sfcsump(vl,lcg,&csum);
   
                         /* update lcy */                          /* update lcy */
                         clearsfbm(bound,0,lcy);                          clearsfbm(bound,0,lcy);
                         COEF(dc) = COEF(DC(g)); ptosfbm(bound,lcyx,lcy);                          COEF(dc) = COEF(DC(g)); ptosfbm(bound,lcyx,lcy);
Line 1133  DCP *dcp;
Line 1157  DCP *dcp;
         DEG(dcf) = ONE; NEXT(dcf) = 0; *dcp = dcf0;          DEG(dcf) = ONE; NEXT(dcf) = 0; *dcp = dcf0;
 }  }
   
 /* lcy = LC(g), lcg = lcy*g */  /* lcy = LC(g), lcg = lcy*g, lcg0 = const part of lcg */
 int sfdtestmain(vl,lcg,lcy,csum,list,k,in,fp,cofp)  int sfdtestmain(vl,lcg,lcg0,lcy,csum,list,k,in,fp,cofp)
 VL vl;  VL vl;
 P lcg;  P lcg;
   UM lcg0;
 BM lcy;  BM lcy;
 P csum;  P csum;
 ML list;  ML list;
Line 1149  P *fp,*cofp;
Line 1174  P *fp,*cofp;
   
         x = vl->v;          x = vl->v;
         y = vl->next->v;          y = vl->next->v;
 #if 0          if (!sfctest(lcg0,lcy,list,k,in))
         if (!sfctest(g,list,k,in))  
                 return 0;                  return 0;
 #endif  
         mulsfbmarray(UDEG(lcg),lcy,list,k,in,x,y,&fmul);          mulsfbmarray(UDEG(lcg),lcy,list,k,in,x,y,&fmul);
         if ( csum ) {          if ( csum ) {
                 sfcsump(vl,fmul,&csumg);                  sfcsump(vl,fmul,&csumg);
Line 1169  P *fp,*cofp;
Line 1192  P *fp,*cofp;
                 return 0;                  return 0;
 }  }
   
 #if 0  void const_term(f,c)
 int sfctest(g,list,k,in)  P f;
 P g;  UM c;
   {
           DCP dc;
   
           for ( dc = DC(f); dc && DEG(dc); dc = NEXT(dc) );
           if ( dc )
                   ptosfum(COEF(dc),c);
           else
                   DEG(c) = -1;
   }
   
   void const_term_sfbm(f,bound,c)
   BM f;
   int bound;
   UM c;
   {
           int i;
   
           for ( i = 0; i < bound; i++ )
                   if ( DEG(COEF(f)[i]) >= 0 )
                           COEF(c)[i] = COEF(COEF(f)[i])[0];
                   else
                           COEF(c)[i] = 0;
           degum(c,bound-1);
   }
   
   /* lcy*(product of const part) | lcg0 ? */
   
   int sfctest(lcg0,lcy,list,k,in)
   UM lcg0;
   BM lcy;
 ML list;  ML list;
 int k;  int k;
 int *in;  int *in;
 {  {
         register int i;  
         int q,bound;  
         int *wm,*wm1,*tmpp;  
         DCP dc;          DCP dc;
         Q dvr;          int bound,i,dr;
         N lcn,cstn,dndn,dmyn,rn;          UM t,s,u,w;
         LUM *l;          BM *l;
   
         for ( dc = DC(g); dc && DEG(dc); dc = NEXT(dc) );          bound = list->bound;
         if ( dc )          t = W_UMALLOC(2*bound);
                 cstn = NM((Q)COEF(dc));          s = W_UMALLOC(2*bound);
         else          u = W_UMALLOC(2*bound);
           const_term_sfbm(lcy,bound,t);
           if ( DEG(t) < 0 )
                 return 1;                  return 1;
         q = list->mod; bound = list->bound;  
         ntobn(q,NM((Q)COEF(DC(g))),&lcn);;          l = (BM *)list->c;
         W_CALLOC(bound+1,int,wm); W_CALLOC(bound+1,int,wm1);          for ( i = 0; i < k; i++ ) {
         for ( i = 0; i < PL(lcn); i++ )                  const_term_sfbm(l[in[i]],bound,s);
                 wm[i] = BD(lcn)[i];                  mulsfum(t,s,u);
         for ( i = 0, l = (LUM *)list->c; i < k; i++ ) {                  if ( DEG(u) >= bound )
                 mulpadic(q,bound,wm,COEF(l[in[i]])[0],wm1);                          degum(u,bound-1);
                 tmpp = wm; wm = wm1; wm1 = tmpp;                  w = t; t = u; u = w;
         }          }
         padictoq(q,bound,wm,&dvr);          cpyum(lcg0,s);
         kmuln(NM((Q)COEF(DC(g))),cstn,&dndn); divn(dndn,NM(dvr),&dmyn,&rn);          dr = divsfum(s,t,u);
         return rn ? 0 : 1;          if ( dr >= 0 )
                   return 0;
           else
                   return 1;
 }  }
 #endif  
   
 /* main var of f is x */  /* main var of f is x */
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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