Changeset 3163a2 in git
 Timestamp:
 Jan 10, 2013, 3:04:45 PM (10 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
 Children:
 e8880a0b01758b6b968ac3c91e6538157a2cb836
 Parents:
 4505ca15be27a1d26c6a46880debf164fc3d31b0
 gitauthor:
 Martin Lee <martinlee84@web.de>20130110 15:04:45+01:00
 gitcommitter:
 Martin Lee <martinlee84@web.de>20130218 15:01:20+01:00
 Location:
 factory
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

factory/facFactorize.cc
r4505ca r3163a2 430 430 biFactors, evaluation); 431 431 432 CFListIterator iter 2, iter;432 CFListIterator iter; 433 433 CFList bufLeadingCoeffs2= leadingCoeffs2[lengthAeval21]; 434 434 bufBiFactors= biFactors; 435 435 bufA= A; 436 CanonicalForm bufLCmultiplier= LCmultiplier; 437 CanonicalForm testVars; 436 CanonicalForm testVars, bufLCmultiplier= LCmultiplier; 438 437 if (!LCmultiplierIsConst) 439 438 { … … 506 505 LCheuristic= true; 507 506 factors= oldFactors; 508 CanonicalForm cont;509 507 CFList contents, LCs; 510 int index=1;511 508 bool foundTrueMultiplier= false; 512 for (iter= factors; iter.hasItem(); iter++, index++) 513 { 514 cont= content (iter.getItem(), 1); 515 cont= gcd (cont , LCmultiplier); 516 contents.append (cont); 517 if (cont.inCoeffDomain()) // trivial content>LCmultiplier needs to go there 518 { 519 foundTrueMultiplier= true; 520 int index2= 1; 521 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); iter2++, 522 index2++) 523 { 524 if (index2 == index) 525 continue; 526 iter2.getItem() /= LCmultiplier; 527 } 509 LCHeuristic3 (LCmultiplier, factors, leadingCoeffs2[lengthAeval21], contents, LCs, foundTrueMultiplier); 510 if (foundTrueMultiplier) 511 { 528 512 A= oldA; 529 513 leadingCoeffs= leadingCoeffs2[lengthAeval21]; … … 532 516 prepareLeadingCoeffs (leadingCoeffs2, A, Aeval, A.level(), 533 517 leadingCoeffs, biFactors, evaluation); 534 break; 535 } 536 else 537 LCs.append (LC (iter.getItem()/cont, 1)); 538 } 539 if (!foundTrueMultiplier) 540 { 541 index= 1; 542 iter2= factors; 518 } 519 else 520 { 543 521 bool foundMultiplier= false; 544 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 545 { 546 if (fdivides (iter.getItem(), LCmultiplier)) 547 { 548 if ((LCmultiplier/iter.getItem()).inCoeffDomain() && 549 !isOnlyLeadingCoeff(iter2.getItem())) //content divides LCmultiplier completely and factor consists of more terms than just the leading coeff 550 { 551 Variable xx= Variable (2); 552 CanonicalForm vars; 553 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 554 xx)); 555 for (int i= 0; i < lengthAeval2; i++) 556 { 557 if (oldAeval[i].isEmpty()) 558 continue; 559 xx= oldAeval[i].getFirst().mvar(); 560 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 561 xx)); 562 } 563 if (vars.level() <= 2) 564 { 565 int index2= 1; 566 for (CFListIterator iter3= leadingCoeffs2[lengthAeval21]; 567 iter3.hasItem(); iter3++, index2++) 568 { 569 if (index2 == index) 570 { 571 iter3.getItem() /= LCmultiplier; 572 break; 573 } 574 } 575 A /= LCmultiplier; 576 foundMultiplier= true; 577 iter.getItem()= 1; 578 } 579 } 580 } 581 } 522 LCHeuristic4 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, A, leadingCoeffs2, lengthAeval2, foundMultiplier); 582 523 // coming from above: divide out more LCmultiplier if possible 583 524 if (foundMultiplier) 584 525 { 585 526 foundMultiplier= false; 586 index=1; 587 iter2= factors; 588 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 589 { 590 if (!iter.getItem().isOne() && 591 fdivides (iter.getItem(), LCmultiplier)) 592 { 593 if (!isOnlyLeadingCoeff (iter2.getItem())) // factor is more than just leading coeff 594 { 595 int index2= 1; 596 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); 597 iter2++, index2++) 598 { 599 if (index2 == index) 600 { 601 iter2.getItem() /= iter.getItem(); 602 foundMultiplier= true; 603 break; 604 } 605 } 606 A /= iter.getItem(); 607 LCmultiplier /= iter.getItem(); 608 iter.getItem()= 1; 609 } 610 else if (fdivides (getVars (LCmultiplier), testVars))//factor consists of just leading coeff 611 { 612 Variable xx= Variable (2); 613 CanonicalForm vars; 614 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 615 xx)); 616 for (int i= 0; i < lengthAeval2; i++) 617 { 618 if (oldAeval[i].isEmpty()) 619 continue; 620 xx= oldAeval[i].getFirst().mvar(); 621 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 622 xx)); 623 } 624 if (myGetVars(content(getItem(leadingCoeffs2[lengthAeval21],index),1)) 625 /myGetVars (LCmultiplier) == vars) 626 { 627 int index2= 1; 628 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); 629 iter2++, index2++) 630 { 631 if (index2 == index) 632 { 633 iter2.getItem() /= LCmultiplier; 634 foundMultiplier= true; 635 break; 636 } 637 } 638 A /= LCmultiplier; 639 iter.getItem()= 1; 640 } 641 } 642 } 643 } 527 LCHeuristic5 (oldBiFactors, oldAeval, contents, factors, testVars, lengthAeval2, leadingCoeffs2, A, LCmultiplier, foundMultiplier); 644 528 } 645 529 else 646 530 { 647 CanonicalForm pLCs= prod (LCs); 648 if (fdivides (pLCs, LC (oldA,1)) && (LC(oldA,1)/pLCs).inCoeffDomain()) // check if the product of the lead coeffs of the primitive factors equals the lead coeff of the old A 649 { 650 A= oldA; 651 iter2= leadingCoeffs2[lengthAeval21]; 652 for (iter= contents; iter.hasItem(); iter++, iter2++) 653 iter2.getItem() /= iter.getItem(); 654 foundMultiplier= true; 655 } 531 LCHeuristic2 (LCs, contents, A, oldA, leadingCoeffs2[lengthAeval21], 532 foundMultiplier); 656 533 if (!foundMultiplier && fdivides (getVars (LCmultiplier), testVars)) 657 534 { … … 751 628 commonDenominators.append (bCommonDen (iter.getItem())); 752 629 CanonicalForm tmp1, tmp2, tmp3=1; 630 CFListIterator iter2; 753 631 for (int i= 0; i < lengthAeval2; i++) 754 632 { 
factory/facFqFactorize.cc
r4505ca r3163a2 2355 2355 } 2356 2356 2357 void changeSecondVariable (CanonicalForm& A, CFList& biFactors, CFList& evaluation, CFList*& oldAeval, int lengthAeval2, const CFList& uniFactors, const Variable& w) 2357 void 2358 changeSecondVariable (CanonicalForm& A, CFList& biFactors, CFList& evaluation, 2359 CFList*& oldAeval, int lengthAeval2, 2360 const CFList& uniFactors, const Variable& w) 2358 2361 { 2359 2362 Variable y= Variable (2); … … 2399 2402 } 2400 2403 2401 void distributeLCmultiplier (CanonicalForm& A, CFList& leadingCoeffs, CFList& biFactors, const CFList& evaluation, const CanonicalForm& LCmultipler) 2404 void 2405 distributeLCmultiplier (CanonicalForm& A, CFList& leadingCoeffs, 2406 CFList& biFactors, const CFList& evaluation, 2407 const CanonicalForm& LCmultipler) 2402 2408 { 2403 2409 CanonicalForm tmp= power (LCmultipler, biFactors.length()  1); … … 2550 2556 } 2551 2557 2558 void 2559 LCHeuristic2 (const CFList& LCs, const CFList& contents, CanonicalForm& A, 2560 const CanonicalForm& oldA, CFList& leadingCoeffs, 2561 bool& foundTrueMultiplier) 2562 { 2563 CanonicalForm pLCs= prod (LCs); 2564 if (fdivides (pLCs, LC (oldA,1)) && (LC(oldA,1)/pLCs).inCoeffDomain()) // check if the product of the lead coeffs of the primitive factors equals the lead coeff of the old A 2565 { 2566 A= oldA; 2567 CFListIterator iter2= leadingCoeffs; 2568 for (CFListIterator iter= contents; iter.hasItem(); iter++, iter2++) 2569 iter2.getItem() /= iter.getItem(); 2570 foundTrueMultiplier= true; 2571 } 2572 } 2573 2574 void 2575 LCHeuristic3 (const CanonicalForm& LCmultiplier, const CFList& factors, CFList& leadingCoeffs, CFList& contents, CFList& LCs, bool& foundTrueMultiplier) 2576 { 2577 CanonicalForm cont; 2578 int index= 1; 2579 CFListIterator iter2; 2580 for (CFListIterator iter= factors; iter.hasItem(); iter++, index++) 2581 { 2582 cont= content (iter.getItem(), 1); 2583 cont= gcd (cont , LCmultiplier); 2584 contents.append (cont); 2585 if (cont.inCoeffDomain()) // trivial content>LCmultiplier needs to go there 2586 { 2587 foundTrueMultiplier= true; 2588 int index2= 1; 2589 for (iter2= leadingCoeffs; iter2.hasItem(); iter2++, index2++) 2590 { 2591 if (index2 == index) 2592 continue; 2593 iter2.getItem() /= LCmultiplier; 2594 } 2595 break; 2596 } 2597 else 2598 LCs.append (LC (iter.getItem()/cont, 1)); 2599 } 2600 } 2601 2602 void 2603 LCHeuristic4 (const CanonicalForm& LCmultiplier, const CFList& factors, const CFList& oldBiFactors, 2604 const CFList& contents, const CFList* oldAeval, CanonicalForm& A, CFList*& leadingCoeffs, int lengthAeval, bool& foundMultiplier) 2605 { 2606 int index= 1; 2607 CFListIterator iter, iter2= factors; 2608 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 2609 { 2610 if (fdivides (iter.getItem(), LCmultiplier)) 2611 { 2612 if ((LCmultiplier/iter.getItem()).inCoeffDomain() && 2613 !isOnlyLeadingCoeff(iter2.getItem())) //content divides LCmultiplier completely and factor consists of more terms than just the leading coeff 2614 { 2615 Variable xx= Variable (2); 2616 CanonicalForm vars; 2617 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 2618 xx)); 2619 for (int i= 0; i < lengthAeval; i++) 2620 { 2621 if (oldAeval[i].isEmpty()) 2622 continue; 2623 xx= oldAeval[i].getFirst().mvar(); 2624 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 2625 xx)); 2626 } 2627 if (vars.level() <= 2) 2628 { 2629 int index2= 1; 2630 for (CFListIterator iter3= leadingCoeffs[lengthAeval1]; 2631 iter3.hasItem(); iter3++, index2++) 2632 { 2633 if (index2 == index) 2634 { 2635 iter3.getItem() /= LCmultiplier; 2636 break; 2637 } 2638 } 2639 A /= LCmultiplier; 2640 foundMultiplier= true; 2641 iter.getItem()= 1; 2642 } 2643 } 2644 } 2645 } 2646 } 2647 2648 void 2649 LCHeuristic5 (const CFList& oldBiFactors, const CFList* oldAeval, const CFList& contents, const CFList& factors, const CanonicalForm& testVars, int lengthAeval, CFList*& leadingCoeffs, CanonicalForm& A, CanonicalForm& LCmultiplier, bool& foundMultiplier) 2650 { 2651 int index=1; 2652 CFListIterator iter, iter2= factors; 2653 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 2654 { 2655 if (!iter.getItem().isOne() && 2656 fdivides (iter.getItem(), LCmultiplier)) 2657 { 2658 if (!isOnlyLeadingCoeff (iter2.getItem())) // factor is more than just leading coeff 2659 { 2660 int index2= 1; 2661 for (iter2= leadingCoeffs[lengthAeval1]; iter2.hasItem(); 2662 iter2++, index2++) 2663 { 2664 if (index2 == index) 2665 { 2666 iter2.getItem() /= iter.getItem(); 2667 foundMultiplier= true; 2668 break; 2669 } 2670 } 2671 A /= iter.getItem(); 2672 LCmultiplier /= iter.getItem(); 2673 iter.getItem()= 1; 2674 } 2675 else if (fdivides (getVars (LCmultiplier), testVars))//factor consists of just leading coeff 2676 { 2677 Variable xx= Variable (2); 2678 CanonicalForm vars; 2679 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 2680 xx)); 2681 for (int i= 0; i < lengthAeval; i++) 2682 { 2683 if (oldAeval[i].isEmpty()) 2684 continue; 2685 xx= oldAeval[i].getFirst().mvar(); 2686 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 2687 xx)); 2688 } 2689 if (myGetVars(content(getItem(leadingCoeffs[lengthAeval1],index),1)) 2690 /myGetVars (LCmultiplier) == vars) 2691 { 2692 int index2= 1; 2693 for (iter2= leadingCoeffs[lengthAeval1]; iter2.hasItem(); 2694 iter2++, index2++) 2695 { 2696 if (index2 == index) 2697 { 2698 iter2.getItem() /= LCmultiplier; 2699 foundMultiplier= true; 2700 break; 2701 } 2702 } 2703 A /= LCmultiplier; 2704 iter.getItem()= 1; 2705 } 2706 } 2707 } 2708 } 2709 } 2710 2552 2711 CFList 2553 2712 extFactorize (const CanonicalForm& F, const ExtensionInfo& info); … … 2941 3100 evaluation); 2942 3101 2943 CFListIterator iter 2, iter;3102 CFListIterator iter; 2944 3103 CFList bufLeadingCoeffs2= leadingCoeffs2[lengthAeval21]; 2945 3104 bufBiFactors= biFactors; 2946 3105 bufA= A; 2947 CanonicalForm bufLCmultiplier= LCmultiplier; 2948 CanonicalForm testVars; 3106 CanonicalForm testVars, bufLCmultiplier= LCmultiplier; 2949 3107 if (!LCmultiplierIsConst) 2950 3108 { … … 3022 3180 LCheuristic= true; 3023 3181 factors= oldFactors; 3024 CanonicalForm cont;3025 3182 CFList contents, LCs; 3026 int index=1;3027 3183 bool foundTrueMultiplier= false; 3028 for (iter= factors; iter.hasItem(); iter++, index++) 3029 { 3030 cont= content (iter.getItem(), 1); 3031 cont= gcd (cont , LCmultiplier); 3032 contents.append (cont); 3033 if (cont.inCoeffDomain()) // trivial content>LCmultiplier needs to go there 3034 { 3035 foundTrueMultiplier= true; 3036 int index2= 1; 3037 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); iter2++, 3038 index2++) 3039 { 3040 if (index2 == index) 3041 continue; 3042 iter2.getItem() /= LCmultiplier; 3043 } 3184 LCHeuristic3 (LCmultiplier, factors, leadingCoeffs2[lengthAeval21], contents, LCs, foundTrueMultiplier); 3185 if (foundTrueMultiplier) 3186 { 3044 3187 A= oldA; 3045 3188 leadingCoeffs= leadingCoeffs2[lengthAeval21]; … … 3048 3191 prepareLeadingCoeffs (leadingCoeffs2, A, Aeval, A.level(), 3049 3192 leadingCoeffs, biFactors, evaluation); 3050 break; 3051 } 3052 else 3053 LCs.append (LC (iter.getItem()/cont, 1)); 3054 } 3055 if (!foundTrueMultiplier) 3056 { 3057 index= 1; 3058 iter2= factors; 3193 } 3194 else 3195 { 3059 3196 bool foundMultiplier= false; 3060 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 3061 { 3062 if (fdivides (iter.getItem(), LCmultiplier)) 3063 { 3064 if ((LCmultiplier/iter.getItem()).inCoeffDomain() && 3065 !isOnlyLeadingCoeff(iter2.getItem())) //content divides LCmultiplier completely and factor consists of more terms than just the leading coeff 3066 { 3067 Variable xx= Variable (2); 3068 CanonicalForm vars; 3069 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 3070 xx)); 3071 for (int i= 0; i < lengthAeval2; i++) 3072 { 3073 if (oldAeval[i].isEmpty()) 3074 continue; 3075 xx= oldAeval[i].getFirst().mvar(); 3076 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 3077 xx)); 3078 } 3079 if (vars.level() <= 2) 3080 { 3081 int index2= 1; 3082 for (CFListIterator iter3= leadingCoeffs2[lengthAeval21]; 3083 iter3.hasItem(); iter3++, index2++) 3084 { 3085 if (index2 == index) 3086 { 3087 iter3.getItem() /= LCmultiplier; 3088 break; 3089 } 3090 } 3091 A /= LCmultiplier; 3092 foundMultiplier= true; 3093 iter.getItem()= 1; 3094 } 3095 } 3096 } 3097 } 3197 LCHeuristic4 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, A, leadingCoeffs2, lengthAeval2, foundMultiplier); 3198 3098 3199 // coming from above: divide out more LCmultiplier if possible 3099 3200 if (foundMultiplier) 3100 3201 { 3101 3202 foundMultiplier= false; 3102 index=1; 3103 iter2= factors; 3104 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 3105 { 3106 if (!iter.getItem().isOne() && 3107 fdivides (iter.getItem(), LCmultiplier)) 3108 { 3109 if (!isOnlyLeadingCoeff (iter2.getItem())) // factor is more than just leading coeff 3110 { 3111 int index2= 1; 3112 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); 3113 iter2++, index2++) 3114 { 3115 if (index2 == index) 3116 { 3117 iter2.getItem() /= iter.getItem(); 3118 foundMultiplier= true; 3119 break; 3120 } 3121 } 3122 A /= iter.getItem(); 3123 LCmultiplier /= iter.getItem(); 3124 iter.getItem()= 1; 3125 } 3126 else if (fdivides (getVars (LCmultiplier), testVars))//factor consists of just leading coeff 3127 { 3128 //TODO maybe use a sqrffree decomposition of LCmultiplier as below 3129 Variable xx= Variable (2); 3130 CanonicalForm vars; 3131 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 3132 xx)); 3133 for (int i= 0; i < lengthAeval2; i++) 3134 { 3135 if (oldAeval[i].isEmpty()) 3136 continue; 3137 xx= oldAeval[i].getFirst().mvar(); 3138 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 3139 xx)); 3140 } 3141 if (myGetVars(content(getItem(leadingCoeffs2[lengthAeval21],index),1)) 3142 /myGetVars (LCmultiplier) == vars) 3143 { 3144 int index2= 1; 3145 for (iter2= leadingCoeffs2[lengthAeval21]; iter2.hasItem(); 3146 iter2++, index2++) 3147 { 3148 if (index2 == index) 3149 { 3150 iter2.getItem() /= LCmultiplier; 3151 foundMultiplier= true; 3152 break; 3153 } 3154 } 3155 A /= LCmultiplier; 3156 iter.getItem()= 1; 3157 } 3158 } 3159 } 3160 } 3203 LCHeuristic5 (oldBiFactors, oldAeval, contents, factors, testVars, lengthAeval2, leadingCoeffs2, A, LCmultiplier, foundMultiplier); 3161 3204 } 3162 3205 else 3163 3206 { 3164 CanonicalForm pLCs= prod (LCs); 3165 if (fdivides (pLCs, LC (oldA,1)) && (LC(oldA,1)/pLCs).inCoeffDomain()) // check if the product of the lead coeffs of the primitive factors equals the lead coeff of the old A 3166 { 3167 A= oldA; 3168 iter2= leadingCoeffs2[lengthAeval21]; 3169 for (iter= contents; iter.hasItem(); iter++, iter2++) 3170 iter2.getItem() /= iter.getItem(); 3171 foundMultiplier= true; 3172 } 3207 LCHeuristic2 (LCs, contents, A, oldA, leadingCoeffs2[lengthAeval21], 3208 foundMultiplier); 3173 3209 if (!foundMultiplier && fdivides (getVars (LCmultiplier), testVars)) 3174 3210 { 
factory/facFqFactorize.h
r4505ca r3163a2 686 686 ); 687 687 688 void changeSecondVariable (CanonicalForm& A, CFList& biFactors, CFList& evaluation, CFList*& oldAeval, int lengthAeval2, const CFList& uniFactors, const Variable& w); 689 void distributeLCmultiplier (CanonicalForm& A, CFList& leadingCoeffs, CFList& biFactors, const CFList& evaluation, const CanonicalForm& LCmultipler); 688 void 689 changeSecondVariable (CanonicalForm& A, CFList& biFactors, CFList& evaluation, CFList*& oldAeval, int lengthAeval2, const CFList& uniFactors, const Variable& w); 690 691 void 692 distributeLCmultiplier (CanonicalForm& A, CFList& leadingCoeffs, CFList& biFactors, const CFList& evaluation, const CanonicalForm& LCmultipler); 693 690 694 void 691 695 LCHeuristic (CanonicalForm& A, const CanonicalForm& LCmultiplier, … … 694 698 const CFList& oldBiFactors); 695 699 700 void 701 LCHeuristic2 (const CFList& LCs, const CFList& contents, CanonicalForm& A, 702 const CanonicalForm& oldA, CFList& leadingCoeffs, 703 bool& foundTrueMultiplier); 704 705 void 706 LCHeuristic3 (const CanonicalForm& LCmultiplier, const CFList& factors, CFList& leadingCoeffs, CFList& contents, CFList& LCs, bool& foundTrueMultiplier); 707 708 void 709 LCHeuristic4 (const CanonicalForm& LCmultiplier, const CFList& factors, const CFList& oldBiFactors, 710 const CFList& contents, const CFList* oldAeval, CanonicalForm& A, CFList*& leadingCoeffs, int lengthAeval, bool& foundMultiplier); 711 712 void 713 LCHeuristic5 (const CFList& oldBiFactors, const CFList* oldAeval, const CFList& contents, const CFList& factors, const CanonicalForm& testVars, int lengthAeval, CFList*& leadingCoeffs, CanonicalForm& A, CanonicalForm& LCmultiplier, bool& foundMultiplier); 714 696 715 #endif 697 716 /* FAC_FQ_FACTORIZE_H */
Note: See TracChangeset
for help on using the changeset viewer.