Changeset 78030c in git
- Timestamp:
- Feb 14, 2005, 5:15:53 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- 49bfb1f50e3b7d2ed4c371ec6ee986a0d6f3d2ef
- Parents:
- 2664d0fccb132e3077f9f8feee90ee2ce139ee26
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/fast_mult.cc
r2664d0f r78030c 1 1 #include "fast_mult.h" 2 2 #include "kbuckets.h" 3 typedef poly fastmultrec(poly f, poly g );3 typedef poly fastmultrec(poly f, poly g, ring r); 4 4 static const int pass_option=1; 5 static void degsplit(poly p,int n,poly &p1,poly&p2, int vn ){5 static void degsplit(poly p,int n,poly &p1,poly&p2, int vn, ring r){ 6 6 poly erg1_i, erg2_i; 7 7 erg1_i=NULL; 8 8 erg2_i=NULL; 9 9 while(p){ 10 if(p GetExp(p,vn)>=n){10 if(p_GetExp(p,vn,r)>=n){ 11 11 if (p1==NULL){ 12 12 p1=p; … … 33 33 34 34 } 35 static void div_by_x_power_n(poly p, int n, int vn ){35 static void div_by_x_power_n(poly p, int n, int vn, ring r){ 36 36 while(p){ 37 assume(p GetExp(p,vn)>=n);38 int e=p GetExp(p,vn);39 p SetExp(p,vn,e-n);37 assume(p_GetExp(p,vn,r)>=n); 38 int e=p_GetExp(p,vn,r); 39 p_SetExp(p,vn,e-n,r); 40 40 p=pNext(p); 41 41 } 42 42 } 43 43 44 static poly do_unifastmult(poly f,int df,poly g,int dg, int vn, fastmultrec rec ){44 static poly do_unifastmult(poly f,int df,poly g,int dg, int vn, fastmultrec rec, ring r){ 45 45 int n=1; 46 46 if ((f==NULL)||(g==NULL)) return NULL; … … 59 59 } 60 60 if(n==1){ 61 return(pp Mult_qq(f,g));61 return(pp_Mult_qq(f,g,r)); 62 62 } 63 63 … … 69 69 poly f1=NULL; 70 70 poly f0=NULL;//f-(x^(pot)*F1); 71 degsplit(p Copy(f),pot,f1,f0,vn);72 div_by_x_power_n(f1,pot,vn );71 degsplit(p_Copy(f,r),pot,f1,f0,vn,r); 72 div_by_x_power_n(f1,pot,vn,r); 73 73 74 74 poly g1=NULL; 75 75 poly g0=NULL; 76 degsplit(p Copy(g),pot,g1,g0,vn);77 div_by_x_power_n(g1,pot,vn );76 degsplit(p_Copy(g,r),pot,g1,g0,vn,r); 77 div_by_x_power_n(g1,pot,vn,r); 78 78 79 79 //p00, p11 80 poly p00=rec(f0,g0 );//unifastmult(f0,g0);81 poly p11=rec(f1,g1 );80 poly p00=rec(f0,g0,r);//unifastmult(f0,g0); 81 poly p11=rec(f1,g1,r); 82 82 83 83 //construct erg, factor … … 85 85 poly factor=pOne(); 86 86 87 p SetExp(factor,vn,n);88 erg=pp Mult_mm(p11,factor);89 erg=p Add(erg,pCopy(p00));87 p_SetExp(factor,vn,n,r); 88 erg=pp_Mult_mm(p11,factor,r); 89 erg=p_Add_q(erg,p_Copy(p00,r),r); 90 90 91 91 … … 96 96 //if(true){ 97 97 //eat up f0,f1,g0,g1 98 poly s1=p Add(f0,f1);99 poly s2=p Add(g0,g1);100 poly pbig=rec(s1,s2 );101 p Delete(&s1);102 p Delete(&s2);98 poly s1=p_Add_q(f0,f1,r); 99 poly s2=p_Add_q(g0,g1,r); 100 poly pbig=rec(s1,s2,r); 101 p_Delete(&s1,r); 102 p_Delete(&s2,r); 103 103 104 104 105 105 //eat up pbig 106 106 poly sum=pbig; 107 p SetExp(factor,vn,pot);107 p_SetExp(factor,vn,pot,r); 108 108 109 109 //eat up p00 110 sum=p Add(sum,pNeg(p00));110 sum=p_Add_q(sum,p_Neg(p00,r),r); 111 111 112 112 //eat up p11 113 sum=p Add(sum,pNeg(p11));114 115 116 sum=p Mult_mm(sum,factor);113 sum=p_Add_q(sum,p_Neg(p11,r),r); 114 115 116 sum=p_Mult_mm(sum,factor,r); 117 117 118 118 119 119 //eat up sum 120 erg=p Add(sum,erg);120 erg=p_Add_q(sum,erg,r); 121 121 } else { 122 122 //eat up f0,f1,g0,g1 123 poly s1= unifastmult(f0,g1);124 poly s2= unifastmult(g0,f1);125 p SetExp(factor,vn,pot);126 poly h=p Mult_mm(((s1!=NULL)?s1:s2),factor);123 poly s1=rec(f0,g1,r); 124 poly s2=rec(g0,f1,r); 125 p_SetExp(factor,vn,pot,r); 126 poly h=p_Mult_mm(((s1!=NULL)?s1:s2),factor,r); 127 127 pDelete(&f1); 128 128 pDelete(&f0); 129 129 pDelete(&g0); 130 130 pDelete(&g1); 131 erg=p Add(erg,h);132 } 133 134 135 p Delete(&factor);131 erg=p_Add_q(erg,h,r); 132 } 133 134 135 p_Delete(&factor,r); 136 136 137 137 … … 230 230 return (a>b)? b:a; 231 231 } 232 poly unifastmult(poly f,poly g ){232 poly unifastmult(poly f,poly g, ring r){ 233 233 int vn=1; 234 234 if((f==NULL)||(g==NULL)) return NULL; 235 int df=p GetExp(f,vn);236 int dg=p GetExp(g,vn);235 int df=p_GetExp(f,vn,r); 236 int dg=p_GetExp(g,vn,r); 237 237 if ((df==0)||(dg==0)) 238 return pp Mult_qq(f,g);238 return pp_Mult_qq(f,g,r); 239 239 if (df*dg<100) 240 return pp Mult_qq(f,g);240 return pp_Mult_qq(f,g,r); 241 241 // if (df*dg>10000) 242 242 // return 243 243 // do_unifastmult_buckets(f,g); 244 244 //else 245 return do_unifastmult(f,df,g,dg,vn,unifastmult );246 247 } 248 249 poly multifastmult(poly f, poly g ){245 return do_unifastmult(f,df,g,dg,vn,unifastmult,r); 246 247 } 248 249 poly multifastmult(poly f, poly g, ring r){ 250 250 if((f==NULL)||(g==NULL)) return NULL; 251 251 if (pLength(f)*pLength(g)<100) 252 return pp Mult_qq(f,g);252 return pp_Mult_qq(f,g,r); 253 253 //find vn 254 254 //determine df,dg simultaneously … … 258 258 int can_dg=0; 259 259 int can_crit=0; 260 for(i=1;i<= pVariables;i++){260 for(i=1;i<=rVar(r);i++){ 261 261 poly p; 262 262 int df=0; … … 265 265 p=f; 266 266 while(p){ 267 df=max(df,p GetExp(p,i));267 df=max(df,p_GetExp(p,i,r)); 268 268 p=pNext(p); 269 269 } … … 271 271 p=g; 272 272 while(p){ 273 dg=max(dg,p GetExp(p,i));273 dg=max(dg,p_GetExp(p,i,r)); 274 274 p=pNext(p); 275 275 } … … 284 284 } 285 285 if(can_crit==0) 286 return pp Mult_qq(f,g);286 return pp_Mult_qq(f,g,r); 287 287 else 288 return do_unifastmult(f,can_df,g,can_dg,can_i,multifastmult); 289 } 288 { 289 poly erg=do_unifastmult(f,can_df,g,can_dg,can_i,multifastmult,r); 290 p_Normalize(erg,r); 291 return(erg); 292 } 293 } -
kernel/fast_mult.h
r2664d0f r78030c 3 3 #include "mod2.h" 4 4 #include "polys.h" 5 poly unifastmult(poly f,poly g );6 poly multifastmult(poly f, poly g );5 poly unifastmult(poly f,poly g, ring r); 6 poly multifastmult(poly f, poly g, ring r); 7 7 #endif
Note: See TracChangeset
for help on using the changeset viewer.