Changeset 1130ffc in git for factory/facBivar.cc
- Timestamp:
- Oct 25, 2012, 2:25:59 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 139f6f800b915490dfaa914ef7676d29a3236b92186df6b3fe891f605e0e3e7324333e7713165436
- Parents:
- becbea965e6c5de8e8ab195c7f480cabc295ac0cd91423947d67c2ab2eaf1aae4a61f9f2988e9510
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facBivar.cc
rbecbea r1130ffc 13 13 #include "config.h" 14 14 15 #include " assert.h"15 #include "cf_assert.h" 16 16 #include "debug.h" 17 17 #include "timing.h" … … 28 28 TIMING_DEFINE_PRINT(fac_bi_hensel_lift) 29 29 TIMING_DEFINE_PRINT(fac_bi_factor_recombination) 30 TIMING_DEFINE_PRINT(fac_bi_evaluation) 31 TIMING_DEFINE_PRINT(fac_bi_shift_to_zero) 30 32 31 33 // bound on coeffs of f (cf. Musser: Multivariate Polynomial Factorization, … … 186 188 } 187 189 188 CFList189 earlyFactorDetection0 (CanonicalForm& F, CFList& factors,int& adaptedLiftBound,190 DegreePattern& degs, bool& success, int deg)191 {192 DegreePattern bufDegs1= degs;193 DegreePattern bufDegs2;194 CFList result;195 CFList T= factors;196 CanonicalForm buf= F;197 CanonicalForm LCBuf= LC (buf, Variable (1));198 CanonicalForm g, quot;199 CanonicalForm M= power (F.mvar(), deg);200 adaptedLiftBound= 0;201 int d= degree (F) + degree (LCBuf, F.mvar());202 for (CFListIterator i= factors; i.hasItem(); i++)203 {204 if (!bufDegs1.find (degree (i.getItem(), 1)))205 continue;206 else207 {208 g= i.getItem() (0, 1);209 g *= LCBuf;210 g= mod (g, M);211 if (fdivides (LC (g), LCBuf))212 {213 g= mulMod2 (i.getItem(), LCBuf, M);214 g /= content (g, Variable (1));215 if (fdivides (g, buf, quot))216 {217 result.append (g);218 buf= quot;219 d -= degree (g) + degree (LC (g, Variable (1)), F.mvar());220 LCBuf= LC (buf, Variable (1));221 T= Difference (T, CFList (i.getItem()));222 223 // compute new possible degree pattern224 bufDegs2= DegreePattern (T);225 bufDegs1.intersect (bufDegs2);226 bufDegs1.refine ();227 if (bufDegs1.getLength() <= 1)228 {229 result.append (buf);230 break;231 }232 }233 }234 }235 }236 adaptedLiftBound= d + 1;237 if (d < deg)238 {239 factors= T;240 degs= bufDegs1;241 F= buf;242 success= true;243 }244 if (bufDegs1.getLength() <= 1)245 degs= bufDegs1;246 return result;247 }248 249 250 CFList251 henselLiftAndEarly0 (CanonicalForm& A, bool& earlySuccess, CFList&252 earlyFactors, DegreePattern& degs, int& liftBound,253 const CFList& uniFactors, const CanonicalForm& eval)254 {255 int sizeOfLiftPre;256 int * liftPre= getLiftPrecisions (A, sizeOfLiftPre, degree (LC (A, 1), 2));257 258 Variable x= Variable (1);259 Variable y= Variable (2);260 CFArray Pi;261 CFList diophant;262 CFList bufUniFactors= uniFactors;263 bufUniFactors.insert (LC (A, x));264 CFMatrix M= CFMatrix (liftBound, bufUniFactors.length() - 1);265 earlySuccess= false;266 int newLiftBound= 0;267 int smallFactorDeg= tmin (11, liftPre [sizeOfLiftPre- 1] + 1);//this is a tunable parameter268 if (smallFactorDeg >= liftBound || degree (A,y) <= 4)269 henselLift12 (A, bufUniFactors, liftBound, Pi, diophant, M);270 else if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30)271 {272 henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M);273 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,274 degs, earlySuccess,275 smallFactorDeg);276 if (degs.getLength() > 1 && !earlySuccess &&277 smallFactorDeg != liftPre [sizeOfLiftPre-1] + 1)278 {279 if (newLiftBound > liftPre[sizeOfLiftPre-1]+1)280 {281 bufUniFactors.insert (LC (A, x));282 henselLiftResume12 (A, bufUniFactors, smallFactorDeg,283 liftPre[sizeOfLiftPre-1] + 1, Pi, diophant, M);284 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,285 degs, earlySuccess, liftPre[sizeOfLiftPre-1] + 1);286 }287 }288 else if (earlySuccess)289 liftBound= newLiftBound;290 int i= sizeOfLiftPre - 1;291 while (degs.getLength() > 1 && !earlySuccess && i - 1 >= 0)292 {293 if (newLiftBound > liftPre[i] + 1)294 {295 bufUniFactors.insert (LC (A, x));296 henselLiftResume12 (A, bufUniFactors, liftPre[i] + 1,297 liftPre[i-1] + 1, Pi, diophant, M);298 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,299 degs, earlySuccess, liftPre[i-1] + 1);300 }301 else302 {303 liftBound= newLiftBound;304 break;305 }306 i--;307 }308 if (earlySuccess)309 liftBound= newLiftBound;310 //after here all factors are lifted to liftPre[sizeOfLiftPre-1]311 }312 else313 {314 henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M);315 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,316 degs, earlySuccess,317 smallFactorDeg);318 int i= 1;319 while ((degree (A,y)/4)*i + 4 <= smallFactorDeg)320 i++;321 if (degs.getLength() > 1 && !earlySuccess)322 {323 bufUniFactors.insert (LC (A, x));324 henselLiftResume12 (A, bufUniFactors, smallFactorDeg,325 (degree (A, y)/4)*i + 4, Pi, diophant, M);326 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,327 degs, earlySuccess, (degree (A, y)/4)*i + 4);328 }329 while (degs.getLength() > 1 && !earlySuccess && i < 4)330 {331 if (newLiftBound > (degree (A, y)/4)*i + 4)332 {333 bufUniFactors.insert (LC (A, x));334 henselLiftResume12 (A, bufUniFactors, (degree (A,y)/4)*i + 4,335 (degree (A, y)/4)*(i+1) + 4, Pi, diophant, M);336 earlyFactors= earlyFactorDetection0 (A, bufUniFactors, newLiftBound,337 degs, earlySuccess, (degree (A, y)/4)*(i+1) + 4);338 }339 else340 {341 liftBound= newLiftBound;342 break;343 }344 i++;345 }346 if (earlySuccess)347 liftBound= newLiftBound;348 }349 350 return bufUniFactors;351 }352 353 190 CFList biFactorize (const CanonicalForm& F, const Variable& v) 354 191 { … … 499 336 { 500 337 bufAeval= A; 338 TIMING_START (fac_bi_evaluation); 501 339 bufAeval= evalPoint (A, bufEvaluation); 340 TIMING_END_AND_PRINT (fac_bi_evaluation, "time for eval point over Q: "); 502 341 503 342 bufAeval2= buf; 343 TIMING_START (fac_bi_evaluation); 504 344 bufAeval2= evalPoint (buf, bufEvaluation2); 345 TIMING_END_AND_PRINT (fac_bi_evaluation, 346 "time for eval point over Q in y: "); 505 347 506 348 // univariate factorization 507 TIMING_START (uni_factorize); 508 349 TIMING_START (fac_uni_factorizer); 509 350 if (extension) 510 351 bufUniFactors= conv (factorize (bufAeval, v)); 511 352 else 512 353 bufUniFactors= conv (factorize (bufAeval, true)); 513 TIMING_END_AND_PRINT ( uni_factorize,514 "time for univariate factorization : ");354 TIMING_END_AND_PRINT (fac_uni_factorizer, 355 "time for univariate factorization over Q: "); 515 356 DEBOUTLN (cerr, "prod (bufUniFactors)== bufAeval " << 516 357 (prod (bufUniFactors) == bufAeval)); 517 358 518 TIMING_START ( uni_factorize);359 TIMING_START (fac_uni_factorizer); 519 360 if (extension) 520 361 bufUniFactors2= conv (factorize (bufAeval2, v)); 521 362 else 522 363 bufUniFactors2= conv (factorize (bufAeval2, true)); 523 TIMING_END_AND_PRINT ( uni_factorize,524 "time for univariate factorization in y : ");364 TIMING_END_AND_PRINT (fac_uni_factorizer, 365 "time for univariate factorization in y over Q: "); 525 366 DEBOUTLN (cerr, "prod (bufuniFactors2)== bufAeval2 " << 526 367 (prod (bufUniFactors2) == bufAeval2)); … … 709 550 (A, earlySuccess, earlyFactors, degs, liftBound, 710 551 uniFactors, dummy, evaluation, b); 711 TIMING_END_AND_PRINT (fac_bi_hensel_lift, "time for hensel lifting: "); 552 TIMING_END_AND_PRINT (fac_bi_hensel_lift, 553 "time for bivariate hensel lifting over Q: "); 712 554 DEBOUTLN (cerr, "lifted factors= " << uniFactors); 713 555 … … 728 570 Off (SW_RATIONAL); 729 571 572 TIMING_START (fac_bi_factor_recombination); 730 573 factors= factorRecombination (uniFactors, A, MODl, degs, 1, 731 574 uniFactors.length()/2, b); 575 TIMING_END_AND_PRINT (fac_bi_factor_recombination, 576 "time for bivariate factor recombination over Q: "); 732 577 733 578 On (SW_RATIONAL);
Note: See TracChangeset
for help on using the changeset viewer.