Changeset 074fe7 in git
- Timestamp:
- Jan 10, 2013, 4:23:31 PM (11 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- bbcc98f3a145ea12750c79cdc791d485911ab3e3
- Parents:
- e8880a0b01758b6b968ac3c91e6538157a2cb836
- git-author:
- Martin Lee <martinlee84@web.de>2013-01-10 16:23:31+01:00
- git-committer:
- Martin Lee <martinlee84@web.de>2013-02-18 15:01:39+01:00
- Location:
- factory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facFactorize.cc
re8880a r074fe7 413 413 414 414 if (w.level() != 1) 415 changeSecondVariable (A, biFactors, evaluation, oldAeval, lengthAeval2, uniFactors, w); 415 changeSecondVariable (A, biFactors, evaluation, oldAeval, lengthAeval2, 416 uniFactors, w); 416 417 417 418 CanonicalForm oldA= A; … … 507 508 CFList contents, LCs; 508 509 bool foundTrueMultiplier= false; 509 LCHeuristic3 (LCmultiplier, factors, leadingCoeffs2[lengthAeval2-1], contents, LCs, foundTrueMultiplier); 510 LCHeuristic2 (LCmultiplier, factors, leadingCoeffs2[lengthAeval2-1], 511 contents, LCs, foundTrueMultiplier); 510 512 if (foundTrueMultiplier) 511 513 { … … 520 522 { 521 523 bool foundMultiplier= false; 522 LCHeuristic4 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, A, leadingCoeffs2, lengthAeval2, foundMultiplier); 524 LCHeuristic3 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, 525 A, leadingCoeffs2, lengthAeval2, foundMultiplier); 523 526 // coming from above: divide out more LCmultiplier if possible 524 527 if (foundMultiplier) 525 528 { 526 529 foundMultiplier= false; 527 LCHeuristic5 (oldBiFactors, oldAeval, contents, factors, testVars, lengthAeval2, leadingCoeffs2, A, LCmultiplier, foundMultiplier); 530 LCHeuristic4 (oldBiFactors, oldAeval, contents, factors, testVars, 531 lengthAeval2, leadingCoeffs2, A, LCmultiplier, 532 foundMultiplier); 528 533 } 529 534 else 530 535 { 531 LCHeuristic 2 (LCs, contents, A, oldA, leadingCoeffs2[lengthAeval2-1],532 foundMultiplier);536 LCHeuristicCheck (LCs, contents, A, oldA, 537 leadingCoeffs2[lengthAeval2-1], foundMultiplier); 533 538 if (!foundMultiplier && fdivides (getVars (LCmultiplier), testVars)) 534 539 { -
factory/facFqFactorize.cc
re8880a r074fe7 2557 2557 2558 2558 void 2559 LCHeuristic 2(const CFList& LCs, const CFList& contents, CanonicalForm& A,2560 const CanonicalForm& oldA, CFList& leadingCoeffs,2561 bool& foundTrueMultiplier)2559 LCHeuristicCheck (const CFList& LCs, const CFList& contents, CanonicalForm& A, 2560 const CanonicalForm& oldA, CFList& leadingCoeffs, 2561 bool& foundTrueMultiplier) 2562 2562 { 2563 2563 CanonicalForm pLCs= prod (LCs); … … 2573 2573 2574 2574 void 2575 LCHeuristic3 (const CanonicalForm& LCmultiplier, const CFList& factors, CFList& leadingCoeffs, CFList& contents, CFList& LCs, bool& foundTrueMultiplier) 2575 LCHeuristic2 (const CanonicalForm& LCmultiplier, const CFList& factors, 2576 CFList& leadingCoeffs, CFList& contents, CFList& LCs, 2577 bool& foundTrueMultiplier) 2576 2578 { 2577 2579 CanonicalForm cont; … … 2601 2603 2602 2604 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)) 2605 LCHeuristic3 (const CanonicalForm& LCmultiplier, const CFList& factors, 2606 const CFList& oldBiFactors, const CFList& contents, 2607 const CFList* oldAeval, CanonicalForm& A, CFList*& leadingCoeffs, 2608 int lengthAeval, bool& foundMultiplier) 2609 { 2610 int index= 1; 2611 CFListIterator iter, iter2= factors; 2612 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 2613 { 2614 if (fdivides (iter.getItem(), LCmultiplier)) 2615 { 2616 if ((LCmultiplier/iter.getItem()).inCoeffDomain() && 2617 !isOnlyLeadingCoeff(iter2.getItem())) //content divides LCmultiplier completely and factor consists of more terms than just the leading coeff 2618 { 2619 Variable xx= Variable (2); 2620 CanonicalForm vars; 2621 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 2622 xx)); 2623 for (int i= 0; i < lengthAeval; i++) 2624 { 2625 if (oldAeval[i].isEmpty()) 2626 continue; 2627 xx= oldAeval[i].getFirst().mvar(); 2628 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 2629 xx)); 2630 } 2631 if (vars.level() <= 2) 2632 { 2633 int index2= 1; 2634 for (CFListIterator iter3= leadingCoeffs[lengthAeval-1]; 2635 iter3.hasItem(); iter3++, index2++) 2611 2636 { 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 2637 if (index2 == index) 2614 2638 { 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[lengthAeval-1]; 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 } 2639 iter3.getItem() /= LCmultiplier; 2640 break; 2643 2641 } 2644 2642 } 2645 } 2643 A /= LCmultiplier; 2644 foundMultiplier= true; 2645 iter.getItem()= 1; 2646 } 2647 } 2648 } 2649 } 2646 2650 } 2647 2651 2648 2652 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++) 2653 LCHeuristic4 (const CFList& oldBiFactors, const CFList* oldAeval, 2654 const CFList& contents, const CFList& factors, 2655 const CanonicalForm& testVars, int lengthAeval, 2656 CFList*& leadingCoeffs, CanonicalForm& A, 2657 CanonicalForm& LCmultiplier, bool& foundMultiplier) 2658 { 2659 int index=1; 2660 CFListIterator iter, iter2= factors; 2661 for (iter= contents; iter.hasItem(); iter++, iter2++, index++) 2662 { 2663 if (!iter.getItem().isOne() && 2664 fdivides (iter.getItem(), LCmultiplier)) 2665 { 2666 if (!isOnlyLeadingCoeff (iter2.getItem())) // factor is more than just leading coeff 2667 { 2668 int index2= 1; 2669 for (iter2= leadingCoeffs[lengthAeval-1]; iter2.hasItem(); 2670 iter2++, index2++) 2671 { 2672 if (index2 == index) 2654 2673 { 2655 if (!iter.getItem().isOne() && 2656 fdivides (iter.getItem(), LCmultiplier)) 2674 iter2.getItem() /= iter.getItem(); 2675 foundMultiplier= true; 2676 break; 2677 } 2678 } 2679 A /= iter.getItem(); 2680 LCmultiplier /= iter.getItem(); 2681 iter.getItem()= 1; 2682 } 2683 else if (fdivides (getVars (LCmultiplier), testVars))//factor consists of just leading coeff 2684 { 2685 Variable xx= Variable (2); 2686 CanonicalForm vars; 2687 vars= power (xx, degree (LC (getItem(oldBiFactors, index),1), 2688 xx)); 2689 for (int i= 0; i < lengthAeval; i++) 2690 { 2691 if (oldAeval[i].isEmpty()) 2692 continue; 2693 xx= oldAeval[i].getFirst().mvar(); 2694 vars *= power (xx, degree (LC (getItem(oldAeval[i], index),1), 2695 xx)); 2696 } 2697 if (myGetVars(content(getItem(leadingCoeffs[lengthAeval-1],index),1)) 2698 /myGetVars (LCmultiplier) == vars) 2699 { 2700 int index2= 1; 2701 for (iter2= leadingCoeffs[lengthAeval-1]; iter2.hasItem(); 2702 iter2++, index2++) 2703 { 2704 if (index2 == index) 2657 2705 { 2658 if (!isOnlyLeadingCoeff (iter2.getItem())) // factor is more than just leading coeff 2659 { 2660 int index2= 1; 2661 for (iter2= leadingCoeffs[lengthAeval-1]; 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[lengthAeval-1],index),1)) 2690 /myGetVars (LCmultiplier) == vars) 2691 { 2692 int index2= 1; 2693 for (iter2= leadingCoeffs[lengthAeval-1]; 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 } 2706 iter2.getItem() /= LCmultiplier; 2707 foundMultiplier= true; 2708 break; 2707 2709 } 2708 2710 } 2711 A /= LCmultiplier; 2712 iter.getItem()= 1; 2713 } 2714 } 2715 } 2716 } 2709 2717 } 2710 2718 … … 3083 3091 3084 3092 if (v.level() != 1) 3085 changeSecondVariable (A, biFactors, evaluation, oldAeval, lengthAeval2, uniFactors, v); 3093 changeSecondVariable (A, biFactors, evaluation, oldAeval, lengthAeval2, 3094 uniFactors, v); 3086 3095 3087 3096 CanonicalForm oldA= A; … … 3097 3106 //prepare leading coefficients 3098 3107 CFList* leadingCoeffs2= new CFList [lengthAeval2]; 3099 prepareLeadingCoeffs (leadingCoeffs2, A, Aeval, A.level(), leadingCoeffs, biFactors,3100 evaluation);3108 prepareLeadingCoeffs (leadingCoeffs2, A, Aeval, A.level(), leadingCoeffs, 3109 biFactors, evaluation); 3101 3110 3102 3111 CFListIterator iter; … … 3182 3191 CFList contents, LCs; 3183 3192 bool foundTrueMultiplier= false; 3184 LCHeuristic3 (LCmultiplier, factors, leadingCoeffs2[lengthAeval2-1], contents, LCs, foundTrueMultiplier); 3193 LCHeuristic2 (LCmultiplier, factors, leadingCoeffs2[lengthAeval2-1], 3194 contents, LCs, foundTrueMultiplier); 3185 3195 if (foundTrueMultiplier) 3186 3196 { … … 3195 3205 { 3196 3206 bool foundMultiplier= false; 3197 LCHeuristic4 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, A, leadingCoeffs2, lengthAeval2, foundMultiplier); 3207 LCHeuristic3 (LCmultiplier, factors, oldBiFactors, contents, oldAeval, 3208 A, leadingCoeffs2, lengthAeval2, foundMultiplier); 3198 3209 3199 3210 // coming from above: divide out more LCmultiplier if possible … … 3201 3212 { 3202 3213 foundMultiplier= false; 3203 LCHeuristic5 (oldBiFactors, oldAeval, contents, factors, testVars, lengthAeval2, leadingCoeffs2, A, LCmultiplier, foundMultiplier); 3214 LCHeuristic4 (oldBiFactors, oldAeval, contents, factors, testVars, 3215 lengthAeval2, leadingCoeffs2, A, LCmultiplier, 3216 foundMultiplier); 3204 3217 } 3205 3218 else 3206 3219 { 3207 LCHeuristic 2 (LCs, contents, A, oldA, leadingCoeffs2[lengthAeval2-1],3208 foundMultiplier);3220 LCHeuristicCheck (LCs, contents, A, oldA, 3221 leadingCoeffs2[lengthAeval2-1], foundMultiplier); 3209 3222 if (!foundMultiplier && fdivides (getVars (LCmultiplier), testVars)) 3210 3223 { -
factory/facFqFactorize.h
re8880a r074fe7 710 710 ); 711 711 712 void 713 LCHeuristic (CanonicalForm& A, const CanonicalForm& LCmultiplier, 714 CFList& biFactors, CFList*& leadingCoeffs, const CFList* oldAeval, 715 int lengthAeval, const CFList& evaluation, 716 const CFList& oldBiFactors); 717 718 void 719 LCHeuristic2 (const CFList& LCs, const CFList& contents, CanonicalForm& A, 720 const CanonicalForm& oldA, CFList& leadingCoeffs, 721 bool& foundTrueMultiplier); 722 723 void 724 LCHeuristic3 (const CanonicalForm& LCmultiplier, const CFList& factors, CFList& leadingCoeffs, CFList& contents, CFList& LCs, bool& foundTrueMultiplier); 725 726 void 727 LCHeuristic4 (const CanonicalForm& LCmultiplier, const CFList& factors, const CFList& oldBiFactors, 728 const CFList& contents, const CFList* oldAeval, CanonicalForm& A, CFList*& leadingCoeffs, int lengthAeval, bool& foundMultiplier); 729 730 void 731 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); 712 /// heuristic to distribute @a LCmultiplier onto factors based on the variables 713 /// that occur in @a LCmultiplier and in the leading coeffs of bivariate factors 714 void 715 LCHeuristic (CanonicalForm& A, ///<[in,out] a poly 716 const CanonicalForm& LCmultiplier,///<[in,out] divisor of LC (A,1) 717 CFList& biFactors, ///<[in,out] bivariate factors 718 CFList*& leadingCoeffs, ///<[in,out] leading coeffs 719 const CFList* oldAeval, ///<[in] bivariate factors wrt. 720 ///< different second vars 721 int lengthAeval, ///<[in] length of oldAeval 722 const CFList& evaluation, ///<[in] evaluation point 723 const CFList& oldBiFactors ///<[in] bivariate factors 724 ///< without LCmultiplier 725 ///< distributed on them 726 ); 727 728 /// checks if prod(LCs)==LC (oldA,1) and if so divides elements of leadingCoeffs 729 /// by elements in contents, sets A to oldA and sets foundTrueMultiplier to true 730 void 731 LCHeuristicCheck (const CFList& LCs, ///<[in] leading coeffs computed 732 const CFList& contents, ///<[in] content of factors 733 CanonicalForm& A, ///<[in,out] oldA*LCmultiplier^m 734 const CanonicalForm& oldA,///<[in] some poly 735 CFList& leadingCoeffs, ///<[in,out] leading coefficients 736 bool& foundTrueMultiplier ///<[in,out] success? 737 ); 738 739 void 740 LCHeuristic2 (const CanonicalForm& LCmultiplier, 741 const CFList& factors, 742 CFList& leadingCoeffs, 743 CFList& contents, 744 CFList& LCs, 745 bool& foundTrueMultiplier 746 ); 747 748 void 749 LCHeuristic3 (const CanonicalForm& LCmultiplier, 750 const CFList& factors, 751 const CFList& oldBiFactors, 752 const CFList& contents, 753 const CFList* oldAeval, 754 CanonicalForm& A, 755 CFList*& leadingCoeffs, 756 int lengthAeval, 757 bool& foundMultiplier 758 ); 759 760 void 761 LCHeuristic4 (const CFList& oldBiFactors, 762 const CFList* oldAeval, 763 const CFList& contents, 764 const CFList& factors, 765 const CanonicalForm& testVars, 766 int lengthAeval, 767 CFList*& leadingCoeffs, 768 CanonicalForm& A, 769 CanonicalForm& LCmultiplier, 770 bool& foundMultiplier 771 ); 732 772 733 773 #endif
Note: See TracChangeset
for help on using the changeset viewer.