Changeset 0db7c7 in git for factory/facHensel.cc
- Timestamp:
- Nov 28, 2012, 4:56:46 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 2e06defcff26c0ba83fc00b14887df89c80c32b2
- Parents:
- 2abbc7658912b7ff427a0603e95ab63e9a736311c7de47e178c8349df34306fb175cec16e9827d57
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facHensel.cc
r2abbc76 r0db7c7 450 450 CanonicalForm modulus= p; 451 451 int d= b.getk(); 452 modpk b2; 452 453 for (int i= 1; i < d; i++) 453 454 { … … 456 457 coeffE= coeffE.mapinto(); 457 458 setCharacteristic (0); 459 b2= modpk (p, d - i); 458 460 if (!coeffE.isZero()) 459 461 { … … 465 467 { 466 468 setCharacteristic (p); 467 g= mulNTL (coeffE, j.getItem()); 469 g= modNTL (coeffE, bufFactors[ii]); 470 g= mulNTL (g, j.getItem()); 468 471 g= modNTL (g, bufFactors[ii]); 469 472 setCharacteristic (0); 470 473 k.getItem() += g.mapinto()*modulus; 471 e -= mulNTL (g.mapinto() *modulus, l.getItem(), b);474 e -= mulNTL (g.mapinto(), b2 (l.getItem()), b2)*modulus; 472 475 e= b(e); 473 476 } … … 629 632 CanonicalForm modulus= p; 630 633 int d= b.getk(); 634 modpk b2; 631 635 for (int i= 1; i < d; i++) 632 636 { … … 647 651 coeffE= replacevar (coeffE, alpha, beta); 648 652 setCharacteristic (0); 653 b2= modpk (p, d - i); 649 654 if (!coeffE.isZero()) 650 655 { … … 656 661 { 657 662 setCharacteristic (p); 658 g= mulNTL (coeffE, j.getItem()); 663 g= modNTL (coeffE, bufFactors[ii]); 664 g= mulNTL (g, j.getItem()); 659 665 g= modNTL (g, bufFactors[ii]); 660 666 setCharacteristic (0); … … 663 669 setReduce (beta, false); 664 670 k.getItem() += replacevar (g.mapinto()*modulus, beta, gamma); 665 e -= mulNTL (replacevar (g.mapinto(), beta, gamma) *modulus,666 l.getItem(), b);671 e -= mulNTL (replacevar (g.mapinto(), beta, gamma), 672 b2 (l.getItem()), b2)*modulus; 667 673 setReduce (beta, true); 668 674 } 669 675 else 670 676 { 677 setReduce (beta, false); 671 678 k.getItem() += replacevar (g.mapinto()*modulus, beta, alpha); 672 e -= mulNTL (replacevar (g.mapinto()*modulus, beta, alpha), 673 l.getItem(), b); 679 e -= mulNTL (replacevar (g.mapinto(), beta, alpha), 680 b2 (l.getItem()), b2)*modulus; 681 setReduce (beta, true); 674 682 } 675 683 e= b(e); … … 681 689 } 682 690 691 return result; 692 } 693 694 CFList 695 diophantineQa (const CanonicalForm& F, const CanonicalForm& G, 696 const CFList& factors, modpk& b, const Variable& alpha) 697 { 698 bool fail= false; 699 CFList recResult; 700 CanonicalForm modMipo, mipo; 701 //here SW_RATIONAL is off 702 On (SW_RATIONAL); 703 mipo= getMipo (alpha); 704 bool mipoHasDen= false; 705 if (!bCommonDen (mipo).isOne()) 706 { 707 mipo *= bCommonDen (mipo); 708 mipoHasDen= true; 709 } 710 Off (SW_RATIONAL); 711 int p= b.getp(); 712 setCharacteristic (p); 713 setReduce (alpha, false); 714 while (1) 715 { 716 setCharacteristic (p); 717 modMipo= mapinto (mipo); 718 modMipo /= lc (modMipo); 719 tryDiophantine (recResult, mapinto (F), mapinto (factors), modMipo, fail); 720 if (fail) 721 { 722 int i= 0; 723 while (cf_getBigPrime (i) < p) 724 i++; 725 findGoodPrime (F, i); 726 findGoodPrime (G, i); 727 p=cf_getBigPrime(i); 728 b = coeffBound( G, p, mipo ); 729 modpk bb= coeffBound (F, p, mipo ); 730 if (bb.getk() > b.getk() ) b=bb; 731 fail= false; 732 } 733 else 734 break; 735 } 736 setReduce (alpha, true); 737 setCharacteristic (0); 738 739 Variable gamma= alpha; 740 CanonicalForm den; 741 if (mipoHasDen) 742 { 743 On (SW_RATIONAL); 744 modMipo= getMipo (alpha); 745 den= bCommonDen (modMipo); 746 modMipo *= den; 747 Off (SW_RATIONAL); 748 setReduce (alpha, false); 749 gamma= rootOf (b (modMipo*b.inverse (den))); 750 setReduce (alpha, true); 751 } 752 753 Variable x= Variable (1); 754 CanonicalForm buf1, buf2, buf3, S; 755 CFList bufFactors= factors; 756 CFListIterator i= bufFactors; 757 if (mipoHasDen) 758 { 759 for (; i.hasItem(); i++) 760 i.getItem()= replacevar (i.getItem(), alpha, gamma); 761 } 762 i= bufFactors; 763 CFList result; 764 if (i.hasItem()) 765 i++; 766 buf1= 0; 767 CanonicalForm Freplaced; 768 if (mipoHasDen) 769 { 770 Freplaced= replacevar (F, alpha, gamma); 771 buf2= divNTL (Freplaced, replacevar (i.getItem(), alpha, gamma), b); 772 } 773 else 774 buf2= divNTL (F, i.getItem(), b); 775 ZZ_p::init (convertFacCF2NTLZZ (b.getpk())); 776 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (getMipo (gamma))); 777 ZZ_pE::init (NTLmipo); 778 ZZ_pEX NTLS, NTLT, NTLbuf3; 779 ZZ_pEX NTLbuf1= convertFacCF2NTLZZ_pEX (buf1, NTLmipo); 780 ZZ_pEX NTLbuf2= convertFacCF2NTLZZ_pEX (buf2, NTLmipo); 781 XGCD (NTLbuf3, NTLS, NTLT, NTLbuf1, NTLbuf2); 782 result.append (b (convertNTLZZ_pEX2CF (NTLS, x, gamma))); 783 result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma))); 784 if (i.hasItem()) 785 i++; 786 for (; i.hasItem(); i++) 787 { 788 if (mipoHasDen) 789 buf1= divNTL (Freplaced, i.getItem(), b); 790 else 791 buf1= divNTL (F, i.getItem(), b); 792 XGCD (NTLbuf3, NTLS, NTLT, NTLbuf3, convertFacCF2NTLZZ_pEX (buf1, NTLmipo)); 793 CFListIterator k= bufFactors; 794 S= convertNTLZZ_pEX2CF (NTLS, x, gamma); 795 for (CFListIterator j= result; j.hasItem(); j++, k++) 796 { 797 j.getItem()= mulNTL (j.getItem(), S, b); 798 j.getItem()= modNTL (j.getItem(), k.getItem(), b); 799 } 800 result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma))); 801 } 683 802 return result; 684 803 } … … 698 817 if (b.getp() != 0) 699 818 { 700 CFList result= diophantine HenselQa (F, G, factors, b, v);819 CFList result= diophantineQa (F, G, factors, b, v); 701 820 return result; 702 821 }
Note: See TracChangeset
for help on using the changeset viewer.