Changeset e7676a in git for factory/cf_gcd.cc
- Timestamp:
- May 7, 2012, 3:55:50 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 517530b37f04ee705b7b271243a265748c447cf5dccd6db99cc44c93669e843ddb6e06d2682769b8
- Parents:
- a034968a1bff5f6e4e9ad126551a2e9a377d9f6060cc1289a79586c1732ba3885997c3cb49bc01d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
ra03496 re7676a 757 757 else if (!fc_and_gc_Univariate) 758 758 { 759 if ( 760 isOn(SW_USE_CHINREM_GCD) 761 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 762 ) 763 { 764 #if 0 765 if ( p1 == fc.level() ) 766 fc = chinrem_gcd( fc, gc ); 767 else 768 { 769 fc = replacevar( fc, Variable(p1), Variable(mp) ); 770 gc = replacevar( gc, Variable(p1), Variable(mp) ); 771 fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) ); 772 } 773 #else 774 fc = chinrem_gcd( fc, gc); 775 #endif 776 } 777 else if ( isOn( SW_USE_EZGCD ) ) 778 { 779 if ( pe == 1 ) 759 if ( isOn( SW_USE_EZGCD ) ) 760 { 761 fc= ezgcd (fc, gc); 762 /*if ( pe == 1 ) 780 763 fc = ezgcd( fc, gc ); 781 764 else if ( pe > 0 )// no variable at position 1 … … 791 774 gc = swapvar( gc, Variable(pe), Variable(1) ); 792 775 fc = swapvar( ezgcd( fc, gc ), Variable(1), Variable(pe) ); 776 }*/ 777 } 778 else if ( 779 isOn(SW_USE_CHINREM_GCD) 780 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 781 ) 782 { 783 #if 0 784 if ( p1 == fc.level() ) 785 fc = chinrem_gcd( fc, gc ); 786 else 787 { 788 fc = replacevar( fc, Variable(p1), Variable(mp) ); 789 gc = replacevar( gc, Variable(p1), Variable(mp) ); 790 fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) ); 793 791 } 792 #else 793 fc = chinrem_gcd( fc, gc); 794 #endif 794 795 } 795 796 else … … 1236 1237 1237 1238 CanonicalForm Dn, test= 0; 1239 cl = gcd (f.lc(),g.lc()); 1240 CanonicalForm gcdcfcg= gcd (cf, cg); 1241 CanonicalForm b= 1; 1242 int minCommonDeg= 0; 1243 for (i= tmax (f.level(), g.level()); i > 0; i--) 1244 { 1245 if (degree (f, i) <= 0 || degree (g, i) <= 0) 1246 continue; 1247 else 1248 { 1249 minCommonDeg= tmin (degree (g, i), degree (f, i)); 1250 break; 1251 } 1252 } 1253 if (i == 0) 1254 return gcdcfcg; 1255 for (; i > 0; i--) 1256 { 1257 if (degree (f, i) <= 0 || degree (g, i) <= 0) 1258 continue; 1259 else 1260 minCommonDeg= tmin (minCommonDeg, tmin (degree (g, i), degree (f, i))); 1261 } 1262 b= 2*tmin (maxNorm (f), maxNorm (g))*abs (cl)* 1263 power (CanonicalForm (2), minCommonDeg); 1238 1264 bool equal= false; 1239 1265 i = cf_getNumBigPrimes() - 1; 1240 cl = gcd (f.lc(),g.lc()); 1241 1242 CanonicalForm gcdcfcg= gcd (cf, cg); 1266 1267 CanonicalForm cof, cog, cofp, cogp, newCof, newCog, cofn, cogn; 1243 1268 //Off (SW_RATIONAL); 1244 1269 while ( true ) … … 1246 1271 p = cf_getBigPrime( i ); 1247 1272 i--; 1248 while ( i >= 0 && mod( cl , p ) == 0 )1273 while ( i >= 0 && mod( cl*(lc(f)/cl)*(lc(g)/cl), p ) == 0 ) 1249 1274 { 1250 1275 p = cf_getBigPrime( i ); … … 1253 1278 //printf("try p=%d\n",p); 1254 1279 setCharacteristic( p ); 1255 Dp = gcd_poly( mapinto( f ), mapinto( g ));1280 Dp = GCD_small_p (mapinto (f), mapinto (g), cofp, cogp); 1256 1281 Dp /=Dp.lc(); 1282 cofp /= lc (cofp); 1283 cogp /= lc (cogp); 1257 1284 setCharacteristic( 0 ); 1258 1285 dp_deg=totaldegree(Dp); … … 1265 1292 { 1266 1293 D = mapinto( Dp ); 1294 cof= mapinto (cofp); 1295 cog= mapinto (cogp); 1267 1296 d_deg=dp_deg; 1268 1297 q = p; … … 1273 1302 { 1274 1303 chineseRemainder( D, q, mapinto( Dp ), p, newD, newq ); 1304 chineseRemainder( cof, q, mapinto (cofp), p, newCof, newq); 1305 chineseRemainder( cog, q, mapinto (cogp), p, newCog, newq); 1306 cof= newCof; 1307 cog= newCog; 1275 1308 q = newq; 1276 1309 D = newD; … … 1282 1315 q = p; 1283 1316 D = mapinto( Dp ); 1317 cof= mapinto (cof); 1318 cog= mapinto (cog); 1284 1319 d_deg=dp_deg; 1285 1320 test= 0; … … 1295 1330 { 1296 1331 Dn= Farey(D,q); 1332 cofn= Farey(cof,q); 1333 cogn= Farey(cog,q); 1297 1334 int is_rat= isOn (SW_RATIONAL); 1298 1335 On (SW_RATIONAL); 1299 1336 cd = bCommonDen( Dn ); // we need On(SW_RATIONAL) 1337 cofn *= bCommonDen (cofn); 1338 cogn *= bCommonDen (cogn); 1300 1339 if (!is_rat) 1301 1340 Off (SW_RATIONAL); … … 1306 1345 equal= true; 1307 1346 //Dn /=vcontent(Dn,Variable(1)); 1308 if (equal && fdivides( Dn, f ) && fdivides( Dn, g ) ) 1347 if ((terminationTest (f,g, cofn, cogn, Dn)) || 1348 ((equal || q > b) && fdivides (Dn, f) && fdivides (Dn, g))) 1309 1349 { 1310 1350 //printf(" -> success\n"); … … 1325 1365 } 1326 1366 1367
Note: See TracChangeset
for help on using the changeset viewer.