Changeset 7c4341 in git
- Timestamp:
- Jan 8, 2014, 11:36:50 AM (10 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 9fd8d2daa9bdbfb7c4a46ffcb388107cecceaa6b
- Parents:
- cb7b21794203a8052a1a05063ef1cc77ef771639
- git-author:
- Martin Lee <martinlee84@web.de>2014-01-08 11:36:50+01:00
- git-committer:
- Martin Lee <martinlee84@web.de>2014-01-20 16:45:04+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facFqBivar.cc
rcb7b21 r7c4341 829 829 adaptedLiftBound= 0; 830 830 int d= degree (F), l= 0; 831 bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || getCharacteristic() > 0; 831 bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || 832 getCharacteristic() > 0; 832 833 if (!isRat) 833 834 On (SW_RATIONAL); … … 2873 2874 } 2874 2875 2875 /*#ifdef HAVE_FLINT2876 #ifdef HAVE_FLINT 2876 2877 //over field extension 2877 2878 int … … 2988 2989 gamma, source, dest 2989 2990 ); 2990 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO2991 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 2991 2992 } 2992 2993 else … … 2997 2998 gamma, source, dest 2998 2999 ); 2999 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO3000 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 3000 3001 } 3001 3002 writeInMatrix (C, buf, ii + 1, 0); … … 3079 3080 return l; 3080 3081 } 3081 #endif */3082 #endif 3082 3083 3083 3084 // over Fq … … 3769 3770 CFArray * A= new CFArray [factors.length()]; 3770 3771 CFArray bufQ= CFArray (factors.length()); 3772 #ifdef HAVE_FLINT 3773 nmod_mat_t FLINTN; 3774 nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); 3775 for (long i=factors.length()-1; i >= 0; i--) 3776 nmod_mat_entry (FLINTN, i, i)= 1; 3777 #else 3771 3778 if (fac_NTL_char != getCharacteristic()) 3772 3779 { … … 3776 3783 mat_zz_p NTLN; 3777 3784 ident (NTLN, factors.length()); 3785 #endif 3778 3786 int minBound= bounds[0]; 3779 3787 for (int i= 1; i < d; i++) … … 3795 3803 CFMatrix Mat, C; 3796 3804 CFIterator iter; 3805 #ifdef HAVE_FLINT 3806 long rank; 3807 nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null; 3808 #else 3797 3809 mat_zz_p* NTLMat,*NTLC, NTLK; 3810 #endif 3798 3811 CFArray buf; 3799 3812 while (l <= precision) … … 3814 3827 } 3815 3828 3829 #ifdef HAVE_FLINT 3830 convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat); 3831 nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat), 3832 nmod_mat_nrows (FLINTMat), getCharacteristic()); 3833 nmod_mat_inv (FLINTMatInv, FLINTMat); 3834 #else 3816 3835 NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat); 3817 3836 *NTLMat= inv (*NTLMat); 3837 #endif 3838 3818 3839 if (GF) 3819 3840 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); … … 3852 3873 gamma, source, dest 3853 3874 ); 3875 #ifdef HAVE_FLINT 3876 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 3877 #else 3854 3878 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); 3879 #endif 3855 3880 } 3856 3881 else … … 3861 3886 gamma, source, dest 3862 3887 ); 3888 #ifdef HAVE_FLINT 3889 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 3890 #else 3863 3891 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); 3892 #endif 3864 3893 } 3865 3894 writeInMatrix (C, buf, ii + 1, 0); … … 3872 3901 setCharacteristic(getCharacteristic()); 3873 3902 3903 #ifdef HAVE_FLINT 3904 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 3905 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 3906 getCharacteristic()); 3907 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 3908 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 3909 getCharacteristic()); 3910 rank= nmod_mat_nullspace (null, FLINTK); 3911 nmod_mat_clear (FLINTK); 3912 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 3913 nmod_mat_clear (FLINTC); 3914 nmod_mat_init_set (FLINTC, FLINTN); 3915 nmod_mat_clear (FLINTN); 3916 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 3917 getCharacteristic()); 3918 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 3919 3920 nmod_mat_clear (FLINTC); 3921 nmod_mat_window_clear (FLINTK); 3922 nmod_mat_clear (null); 3923 #else 3874 3924 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 3875 3925 NTLK= (*NTLC)*NTLN; … … 3879 3929 NTLN *= NTLK; 3880 3930 delete NTLC; 3931 #endif 3881 3932 3882 3933 if (GF) 3883 3934 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 3884 3935 3936 #ifdef HAVE_FLINT 3937 if (nmod_mat_ncols (FLINTN) == 1) 3938 { 3939 nmod_mat_clear (FLINTMat); 3940 nmod_mat_clear (FLINTMatInv); 3941 nmod_mat_clear (FLINTN); 3942 #else 3885 3943 if (NTLN.NumCols() == 1) 3886 3944 { 3945 delete NTLMat; 3946 #endif 3887 3947 Variable y= Variable (2); 3888 3948 CanonicalForm tmp= F (y - evaluation, y); 3889 3949 CFList source, dest; 3890 3950 tmp= mapDown (tmp, info, source, dest); 3891 delete NTLMat;3892 3951 delete [] A; 3893 3952 delete [] bounds; … … 3898 3957 } 3899 3958 3959 #ifdef HAVE_FLINT 3960 nmod_mat_clear (FLINTMat); 3961 nmod_mat_clear (FLINTMatInv); 3962 #else 3900 3963 delete NTLMat; 3901 3964 #endif 3965 3966 #ifdef HAVE_FLINT 3967 if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound) 3968 { 3969 if (isReduced (FLINTN)) 3970 { 3971 int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 3972 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 3973 #else 3902 3974 if (NTLN.NumCols() < oldNumCols - factorsFound) 3903 3975 { … … 3906 3978 int * factorsFoundIndex= new int [NTLN.NumCols()]; 3907 3979 for (long i= 0; i < NTLN.NumCols(); i++) 3980 #endif 3908 3981 factorsFoundIndex[i]= 0; 3909 3982 int factorsFound2= 0; 3910 3983 CFList result; 3911 3984 CanonicalForm bufF= F; 3985 #ifdef HAVE_FLINT 3986 extReconstructionTry (result, bufF, factors,degree (F)+1, factorsFound2, 3987 factorsFoundIndex, FLINTN, false, info, evaluation 3988 ); 3989 if (result.length() == nmod_mat_ncols (FLINTN)) 3990 { 3991 nmod_mat_clear (FLINTN); 3992 #else 3912 3993 extReconstructionTry (result, bufF, factors,degree (F)+1, factorsFound2, 3913 3994 factorsFoundIndex, NTLN, false, info, evaluation … … 3915 3996 if (result.length() == NTLN.NumCols()) 3916 3997 { 3998 #endif 3917 3999 delete [] factorsFoundIndex; 3918 4000 delete [] A; … … 3926 4008 { 3927 4009 CanonicalForm bufF= F; 4010 #ifdef HAVE_FLINT 4011 int * zeroOne= extractZeroOneVecs (FLINTN); 4012 CFList result= extReconstruction (bufF, factors, zeroOne, precision, 4013 FLINTN, info, evaluation 4014 ); 4015 nmod_mat_clear (FLINTN); 4016 #else 3928 4017 int * zeroOne= extractZeroOneVecs (NTLN); 3929 4018 CFList result= extReconstruction (bufF, factors, zeroOne, precision, 3930 4019 NTLN, info, evaluation 3931 4020 ); 4021 #endif 3932 4022 F= bufF; 3933 4023 delete [] zeroOne; … … 3951 4041 } 3952 4042 } 4043 4044 #ifdef HAVE_FLINT 4045 nmod_mat_clear (FLINTN); 4046 #endif 3953 4047 delete [] bounds; 3954 4048 delete [] A; … … 4568 4662 4569 4663 //over field extension 4664 #ifdef HAVE_FLINT 4665 CFList 4666 extIncreasePrecision (CanonicalForm& F, CFList& factors, int oldL, int l, int d, 4667 int* bounds, CFArray& bufQ, nmod_mat_t FLINTN, const 4668 CanonicalForm& evaluation, const ExtensionInfo& info, 4669 CFList& source, CFList& dest 4670 ) 4671 #else 4570 4672 CFList 4571 4673 extIncreasePrecision (CanonicalForm& F, CFList& factors, int oldL, int l, int d, … … 4574 4676 CFList& source, CFList& dest 4575 4677 ) 4678 #endif 4576 4679 { 4577 4680 CFList result= CFList(); … … 4587 4690 CanonicalForm primElemAlpha= info.getGamma(); 4588 4691 CanonicalForm imPrimElemAlpha= info.getDelta(); 4692 #ifdef HAVE_FLINT 4693 nmod_mat_clear (FLINTN); 4694 nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); 4695 for (long i=factors.length()-1; i >= 0; i--) 4696 nmod_mat_entry (FLINTN, i, i)= 1; 4697 #else 4589 4698 if (NTLN.NumRows() != factors.length()) //refined factors 4590 4699 ident (NTLN, factors.length()); 4700 #endif 4591 4701 Variable y= F.mvar(); 4592 4702 CFListIterator j; … … 4594 4704 CFMatrix Mat, C; 4595 4705 CFIterator iter; 4596 mat_zz_p* NTLMat;4597 4706 CFArray buf; 4598 mat_zz_p* NTLC, NTLK; 4707 #ifdef HAVE_FLINT 4708 long rank; 4709 nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null; 4710 #else 4711 mat_zz_p* NTLC, NTLK, *NTLMat; 4712 #endif 4599 4713 CFList bufUniFactors; 4600 4714 while (oldL <= l) … … 4616 4730 } 4617 4731 4732 #ifdef HAVE_FLINT 4733 convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat); 4734 nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat), 4735 nmod_mat_nrows (FLINTMat), getCharacteristic()); 4736 nmod_mat_inv (FLINTMatInv, FLINTMat); 4737 #else 4618 4738 NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat); 4619 4739 *NTLMat= inv (*NTLMat); 4740 #endif 4741 4620 4742 if (GF) 4621 4743 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); … … 4654 4776 gamma, source, dest 4655 4777 ); 4778 #ifdef HAVE_FLINT 4779 buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, FLINTMatInv); 4780 #else 4656 4781 buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat); 4782 #endif 4657 4783 } 4658 4784 else … … 4663 4789 gamma, source, dest 4664 4790 ); 4791 #ifdef HAVE_FLINT 4792 buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, FLINTMatInv); 4793 #else 4665 4794 buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat); 4795 #endif 4666 4796 } 4667 4797 writeInMatrix (C, buf, ii + 1, 0); … … 4674 4804 setCharacteristic(getCharacteristic()); 4675 4805 4806 #ifdef HAVE_FLINT 4807 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 4808 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 4809 getCharacteristic()); 4810 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 4811 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 4812 getCharacteristic()); 4813 rank= nmod_mat_nullspace (null, FLINTK); 4814 nmod_mat_clear (FLINTK); 4815 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 4816 nmod_mat_clear (FLINTC); 4817 nmod_mat_init_set (FLINTC, FLINTN); 4818 nmod_mat_clear (FLINTN); 4819 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 4820 getCharacteristic()); 4821 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 4822 4823 nmod_mat_clear (FLINTC); 4824 nmod_mat_window_clear (FLINTK); 4825 nmod_mat_clear (null); 4826 #else 4676 4827 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 4677 4828 NTLK= (*NTLC)*NTLN; … … 4681 4832 NTLN *= NTLK; 4682 4833 delete NTLC; 4834 #endif 4683 4835 4684 4836 if (GF) 4685 4837 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 4686 4838 4839 #ifdef HAVE_FLINT 4840 if (nmod_mat_ncols (FLINTN) == 1) 4841 { 4842 nmod_mat_clear (FLINTMat); 4843 nmod_mat_clear (FLINTMatInv); 4844 #else 4687 4845 if (NTLN.NumCols() == 1) 4688 4846 { 4847 delete NTLMat; 4848 #endif 4689 4849 Variable y= Variable (2); 4690 4850 CanonicalForm tmp= F (y - evaluation, y); … … 4692 4852 tmp= mapDown (tmp, info, source, dest); 4693 4853 delete [] A; 4694 delete NTLMat;4695 4854 return CFList (tmp); 4696 4855 } … … 4698 4857 } 4699 4858 4859 #ifdef HAVE_FLINT 4860 nmod_mat_clear (FLINTMat); 4861 nmod_mat_clear (FLINTMatInv); 4862 #else 4700 4863 delete NTLMat; 4701 4864 #endif 4865 4866 #ifdef HAVE_FLINT 4867 if (nmod_mat_ncols (FLINTN) == 1) 4868 #else 4702 4869 if (NTLN.NumCols() == 1) 4870 #endif 4703 4871 { 4704 4872 Variable y= Variable (2); … … 4711 4879 4712 4880 int * zeroOneVecs; 4713 zeroOneVecs= extractZeroOneVecs (NTLN);4714 4881 bufF= F; 4715 4882 bufUniFactors= factors; 4883 #ifdef HAVE_FLINT 4884 zeroOneVecs= extractZeroOneVecs (FLINTN); 4885 result= extReconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN, 4886 info, evaluation 4887 ); 4888 #else 4889 zeroOneVecs= extractZeroOneVecs (NTLN); 4716 4890 result= extReconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN, 4717 4891 info, evaluation 4718 4892 ); 4893 #endif 4719 4894 delete [] zeroOneVecs; 4720 4895 if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0) … … 5268 5443 5269 5444 //over field extension 5445 #ifdef HAVE_FLINT 5446 CFList 5447 extFurtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& factors, int l, 5448 int liftBound, int d, int* bounds, 5449 nmod_mat_t FLINTN, CFList& diophant, 5450 CFMatrix& M, CFArray& Pi, CFArray& bufQ, 5451 const CanonicalForm& evaluation, const 5452 ExtensionInfo& info, CFList& source, 5453 CFList& dest 5454 ) 5455 #else 5270 5456 CFList 5271 5457 extFurtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& factors, int l, … … 5277 5463 CFList& dest 5278 5464 ) 5465 #endif 5279 5466 { 5280 5467 CanonicalForm LCF= LC (F, 1); … … 5294 5481 CanonicalForm primElemAlpha= info.getGamma(); 5295 5482 CanonicalForm imPrimElemAlpha= info.getDelta(); 5483 #ifdef HAVE_FLINT 5484 nmod_mat_clear (FLINTN); 5485 nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); 5486 for (long i=factors.length()-1; i >= 0; i--) 5487 nmod_mat_entry (FLINTN, i, i)= 1; 5488 #else 5296 5489 if (NTLN.NumRows() != factors.length()) //refined factors 5297 5490 ident (NTLN, factors.length()); 5491 #endif 5298 5492 Variable y= F.mvar(); 5299 5493 CanonicalForm powX, imBasis, bufF, truncF; 5300 5494 CFMatrix Mat, C; 5301 5495 CFIterator iter; 5496 #ifdef HAVE_FLINT 5497 long rank; 5498 nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null; 5499 #else 5302 5500 mat_zz_p* NTLMat,*NTLC, NTLK; 5501 #endif 5303 5502 CFListIterator j; 5304 5503 CFArray buf; … … 5324 5523 } 5325 5524 5525 #ifdef HAVE_FLINT 5526 convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat); 5527 nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat), 5528 nmod_mat_nrows (FLINTMat), getCharacteristic()); 5529 nmod_mat_inv (FLINTMatInv, FLINTMat); 5530 #else 5326 5531 NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat); 5327 5532 *NTLMat= inv (*NTLMat); 5533 #endif 5328 5534 5329 5535 if (GF) … … 5362 5568 gamma, source, dest 5363 5569 ); 5570 #ifdef HAVE_FLINT 5571 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 5572 #else 5364 5573 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); 5574 #endif 5365 5575 } 5366 5576 else … … 5371 5581 gamma, source, dest 5372 5582 ); 5583 #ifdef HAVE_FLINT 5584 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); 5585 #else 5373 5586 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); 5587 #endif 5374 5588 } 5375 5589 writeInMatrix (C, buf, ii + 1, 0); … … 5381 5595 if (GF) 5382 5596 setCharacteristic(getCharacteristic()); 5597 5598 #ifdef HAVE_FLINT 5599 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 5600 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 5601 getCharacteristic()); 5602 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 5603 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 5604 getCharacteristic()); 5605 rank= nmod_mat_nullspace (null, FLINTK); 5606 nmod_mat_clear (FLINTK); 5607 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 5608 nmod_mat_clear (FLINTC); 5609 nmod_mat_init_set (FLINTC, FLINTN); 5610 nmod_mat_clear (FLINTN); 5611 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 5612 getCharacteristic()); 5613 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 5614 5615 nmod_mat_clear (FLINTC); 5616 nmod_mat_window_clear (FLINTK); 5617 nmod_mat_clear (null); 5618 #else 5383 5619 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 5384 5620 NTLK= (*NTLC)*NTLN; … … 5388 5624 NTLN *= NTLK; 5389 5625 delete NTLC; 5626 #endif 5627 5390 5628 if (GF) 5391 5629 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 5392 5630 5631 #ifdef HAVE_FLINT 5632 if (nmod_mat_ncols (FLINTN) == 1) 5633 #else 5393 5634 if (NTLN.NumCols() == 1) 5635 #endif 5394 5636 { 5395 5637 irreducible= true; … … 5398 5640 } 5399 5641 } 5642 5643 #ifdef HAVE_FLINT 5644 nmod_mat_clear (FLINTMat); 5645 nmod_mat_clear (FLINTMatInv); 5646 if (nmod_mat_ncols (FLINTN) == 1) 5647 #else 5400 5648 delete NTLMat; 5401 5649 if (NTLN.NumCols() == 1) 5650 #endif 5402 5651 { 5403 5652 irreducible= true; … … 5405 5654 } 5406 5655 5656 bufF= F; 5657 #ifdef HAVE_FLINT 5658 int * zeroOneVecs= extractZeroOneVecs (FLINTN); 5659 result= extReconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN, info, 5660 evaluation 5661 ); 5662 #else 5407 5663 int * zeroOneVecs= extractZeroOneVecs (NTLN); 5408 bufF= F;5409 5664 result= extReconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN, info, 5410 5665 evaluation 5411 5666 ); 5667 #endif 5412 5668 delete [] zeroOneVecs; 5413 5669 if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) … … 5419 5675 } 5420 5676 5677 #ifdef HAVE_FLINT 5678 if (isReduced (FLINTN)) 5679 #else 5421 5680 if (isReduced (NTLN)) 5681 #endif 5422 5682 { 5423 5683 int factorsFound= 0; 5424 5684 bufF= F; 5685 #ifdef HAVE_FLINT 5686 int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 5687 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 5688 #else 5425 5689 int* factorsFoundIndex= new int [NTLN.NumCols()]; 5426 5690 for (long i= 0; i < NTLN.NumCols(); i++) 5691 #endif 5427 5692 factorsFoundIndex[i]= 0; 5693 #ifdef HAVE_FLINT 5694 if (l < degree (bufF) + 1 + degree (LCF)) 5695 extReconstructionTry (result, bufF, bufFactors, l, factorsFound, 5696 factorsFoundIndex, FLINTN, false, info, evaluation 5697 ); 5698 else 5699 extReconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + 5700 degree (LCF), factorsFound, factorsFoundIndex, 5701 FLINTN, false, info, evaluation 5702 ); 5703 if (nmod_mat_ncols (FLINTN) == result.length()) 5704 #else 5428 5705 if (l < degree (bufF) + 1 + degree (LCF)) 5429 5706 extReconstructionTry (result, bufF, bufFactors, l, factorsFound, … … 5436 5713 ); 5437 5714 if (NTLN.NumCols() == result.length()) 5715 #endif 5438 5716 { 5439 5717 delete [] A; … … 6162 6440 6163 6441 //over field extension 6442 #ifdef HAVE_FLINT 6443 CFList 6444 extEarlyReconstructionAndLifting (const CanonicalForm& F, const nmod_mat_t N, 6445 CanonicalForm& bufF, CFList& factors, int& l, 6446 int& factorsFound, bool beenInThres, CFMatrix& 6447 M, CFArray& Pi, CFList& diophant, const 6448 ExtensionInfo& info, const CanonicalForm& 6449 evaluation 6450 ) 6451 #else 6164 6452 CFList 6165 6453 extEarlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_p& N, … … 6170 6458 evaluation 6171 6459 ) 6460 #endif 6172 6461 { 6173 6462 int sizeOfLiftPre; … … 6178 6467 CFList result; 6179 6468 int smallFactorDeg= 11; 6469 #ifdef HAVE_FLINT 6470 nmod_mat_t FLINTN; 6471 nmod_mat_init_set (FLINTN, N); 6472 int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 6473 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 6474 #else 6180 6475 mat_zz_p NTLN= N; 6181 6476 int * factorsFoundIndex= new int [NTLN.NumCols()]; 6182 6477 for (long i= 0; i < NTLN.NumCols(); i++) 6478 #endif 6183 6479 factorsFoundIndex [i]= 0; 6184 6480 … … 6194 6490 } 6195 6491 TIMING_START (fac_fq_reconstruction); 6492 #ifdef HAVE_FLINT 6493 extReconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, 6494 factorsFoundIndex, FLINTN, beenInThres, info, 6495 evaluation 6496 ); 6497 #else 6196 6498 extReconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, 6197 6499 factorsFoundIndex, NTLN, beenInThres, info, 6198 6500 evaluation 6199 6501 ); 6502 #endif 6200 6503 TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct0: "); 6504 #ifdef HAVE_FLINT 6505 if (result.length() == nmod_mat_ncols (FLINTN)) 6506 { 6507 nmod_mat_clear (FLINTN); 6508 #else 6201 6509 if (result.length() == NTLN.NumCols()) 6202 6510 { 6511 #endif 6203 6512 delete [] liftPre; 6204 6513 delete [] factorsFoundIndex; … … 6228 6537 } 6229 6538 TIMING_START (fac_fq_reconstruction); 6539 #ifdef HAVE_FLINT 6540 extReconstructionTry (result, bufF, factors, l, factorsFound, 6541 factorsFoundIndex, FLINTN, beenInThres, info, 6542 evaluation 6543 ); 6544 #else 6230 6545 extReconstructionTry (result, bufF, factors, l, factorsFound, 6231 6546 factorsFoundIndex, NTLN, beenInThres, info, 6232 6547 evaluation 6233 6548 ); 6549 #endif 6234 6550 TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct1: "); 6551 #ifdef HAVE_FLINT 6552 if (result.length() == nmod_mat_ncols (FLINTN)) 6553 { 6554 nmod_mat_clear (FLINTN); 6555 #else 6235 6556 if (result.length() == NTLN.NumCols()) 6236 6557 { 6558 #endif 6237 6559 delete [] liftPre; 6238 6560 delete [] factorsFoundIndex; … … 6265 6587 } 6266 6588 TIMING_START (fac_fq_reconstruction); 6589 #ifdef HAVE_FLINT 6590 extReconstructionTry (result, bufF, factors, l, factorsFound, 6591 factorsFoundIndex, FLINTN, beenInThres, info, 6592 evaluation 6593 ); 6594 #else 6267 6595 extReconstructionTry (result, bufF, factors, l, factorsFound, 6268 6596 factorsFoundIndex, NTLN, beenInThres, info, 6269 6597 evaluation 6270 6598 ); 6599 #endif 6271 6600 TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct2: "); 6601 #ifdef HAVE_FLINT 6602 if (result.length() == nmod_mat_ncols (FLINTN)) 6603 { 6604 nmod_mat_clear (FLINTN); 6605 #else 6272 6606 if (result.length() == NTLN.NumCols()) 6273 6607 { 6608 #endif 6274 6609 delete [] liftPre; 6275 6610 delete [] factorsFoundIndex; … … 6280 6615 } 6281 6616 6617 #ifdef HAVE_FLINT 6618 nmod_mat_clear (FLINTN); 6619 #endif 6282 6620 delete [] liftPre; 6283 6621 delete [] factorsFoundIndex; … … 7370 7708 int l= 1; 7371 7709 7710 #ifdef HAVE_FLINT 7711 nmod_mat_t FLINTN; 7712 nmod_mat_init (FLINTN, bufUniFactors.length()-1, bufUniFactors.length()-1, 7713 getCharacteristic()); 7714 for (long i= bufUniFactors.length()-2; i >= 0; i--) 7715 nmod_mat_entry (FLINTN, i, i)= 1; 7716 #else 7372 7717 if (fac_NTL_char != getCharacteristic()) 7373 7718 { … … 7379 7724 7380 7725 ident (NTLN, bufUniFactors.length() - 1); 7726 #endif 7381 7727 bool irreducible= false; 7382 7728 CFArray bufQ= CFArray (bufUniFactors.length() - 1); … … 7387 7733 { 7388 7734 int start= 0; 7735 #ifdef HAVE_FLINT 7736 oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, start, 7737 bufUniFactors, FLINTN, diophant,M, Pi, bufQ, 7738 irreducible, evaluation, info2, source, dest 7739 ); 7740 #else 7389 7741 oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, start, 7390 7742 bufUniFactors, NTLN, diophant, M, Pi, bufQ, 7391 7743 irreducible, evaluation, info2, source, dest 7392 7744 ); 7745 #endif 7393 7746 } 7394 7747 else 7395 7748 { 7749 #ifdef HAVE_FLINT 7750 oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, 7751 minBound+1, bufUniFactors, FLINTN, diophant, 7752 M, Pi, bufQ, irreducible, evaluation, info2, 7753 source, dest 7754 ); 7755 #else 7396 7756 oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, 7397 7757 minBound + 1, bufUniFactors, NTLN, diophant, … … 7399 7759 source, dest 7400 7760 ); 7761 #endif 7401 7762 } 7402 7763 TIMING_END_AND_PRINT (fac_fq_till_reduced, … … 7406 7767 if (oldL > liftBound) 7407 7768 { 7769 #ifdef HAVE_FLINT 7770 nmod_mat_clear (FLINTN); 7771 #endif 7408 7772 delete [] bounds; 7409 7773 return Union (smallFactors, extFactorRecombination … … 7418 7782 if (irreducible) 7419 7783 { 7784 #ifdef HAVE_FLINT 7785 nmod_mat_clear (FLINTN); 7786 #endif 7420 7787 delete [] bounds; 7421 7788 CFList source, dest; … … 7432 7799 int * factorsFoundIndex; 7433 7800 7801 #ifdef HAVE_FLINT 7802 factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 7803 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 7804 #else 7434 7805 factorsFoundIndex= new int [NTLN.NumCols()]; 7435 7806 for (long i= 0; i < NTLN.NumCols(); i++) 7807 #endif 7436 7808 factorsFoundIndex[i]= 0; 7437 7809 … … 7439 7811 CanonicalForm bufF= F; 7440 7812 7813 #ifdef HAVE_FLINT 7814 extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1, 7815 factorsFound, factorsFoundIndex, FLINTN, false, info, 7816 evaluation 7817 ); 7818 7819 if (result.length() == nmod_mat_ncols (FLINTN)) 7820 { 7821 nmod_mat_clear (FLINTN); 7822 #else 7441 7823 extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1, 7442 7824 factorsFound, factorsFoundIndex, NTLN, false, info, … … 7446 7828 if (result.length() == NTLN.NumCols()) 7447 7829 { 7830 #endif 7448 7831 delete [] factorsFoundIndex; 7449 7832 delete [] bounds; … … 7456 7839 { 7457 7840 int * factorsFoundIndex; 7841 #ifdef HAVE_FLINT 7842 factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 7843 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 7844 #else 7458 7845 factorsFoundIndex= new int [NTLN.NumCols()]; 7459 7846 for (long i= 0; i < NTLN.NumCols(); i++) 7847 #endif 7460 7848 factorsFoundIndex[i]= 0; 7461 7849 CanonicalForm bufF= F; 7462 7850 int factorsFound= 0; 7463 7851 7852 #ifdef HAVE_FLINT 7853 extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1, 7854 factorsFound, factorsFoundIndex, FLINTN, false, 7855 info, evaluation 7856 ); 7857 7858 if (result.length() == nmod_mat_ncols (FLINTN)) 7859 { 7860 nmod_mat_clear (FLINTN); 7861 #else 7464 7862 extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1, 7465 7863 factorsFound, factorsFoundIndex, NTLN, false, … … 7469 7867 if (result.length() == NTLN.NumCols()) 7470 7868 { 7869 #endif 7471 7870 delete [] factorsFoundIndex; 7472 7871 delete [] bounds; … … 7479 7878 bool beenInThres= false; 7480 7879 int thres= 100; 7880 #ifdef HAVE_FLINT 7881 if (l <= thres && bufUniFactors.length() > nmod_mat_ncols (FLINTN)) 7882 { 7883 refineAndRestartLift (F, FLINTN, 2*totaldegree (F)-1, l, bufUniFactors, M, Pi, 7884 diophant 7885 ); 7886 #else 7481 7887 if (l <= thres && bufUniFactors.length() > NTLN.NumCols()) 7482 7888 { … … 7484 7890 diophant 7485 7891 ); 7892 #endif 7486 7893 beenInThres= true; 7487 7894 } … … 7491 7898 int factorsFound= 0; 7492 7899 7900 #ifdef HAVE_FLINT 7901 result= extEarlyReconstructionAndLifting (F, FLINTN, bufF, bufUniFactors, l, 7902 factorsFound, beenInThres, M, Pi, 7903 diophant, info, evaluation 7904 ); 7905 7906 if (result.length() == nmod_mat_ncols (FLINTN)) 7907 { 7908 nmod_mat_clear (FLINTN); 7909 #else 7493 7910 result= extEarlyReconstructionAndLifting (F, NTLN, bufF, bufUniFactors, l, 7494 7911 factorsFound, beenInThres, M, Pi, … … 7498 7915 if (result.length() == NTLN.NumCols()) 7499 7916 { 7917 #endif 7500 7918 delete [] bounds; 7501 7919 return Union (result, smallFactors); … … 7527 7945 else 7528 7946 { 7947 #ifdef HAVE_FLINT 7948 int * zeroOne= extractZeroOneVecs (FLINTN); 7949 #else 7529 7950 int * zeroOne= extractZeroOneVecs (NTLN); 7951 #endif 7530 7952 CFList bufBufUniFactors= bufUniFactors; 7531 7953 CFListIterator iter, iter2; 7532 7954 CanonicalForm buf; 7533 7955 CFList factorsConsidered; 7956 #ifdef HAVE_FLINT 7957 for (int i= 0; i < nmod_mat_ncols (FLINTN); i++) 7958 #else 7534 7959 for (int i= 0; i < NTLN.NumCols(); i++) 7960 #endif 7535 7961 { 7536 7962 if (zeroOne [i] == 0) … … 7539 7965 buf= 1; 7540 7966 factorsConsidered= CFList(); 7967 #ifdef HAVE_FLINT 7968 for (int j= 0; j < nmod_mat_nrows (FLINTN); j++, iter++) 7969 { 7970 if (!(nmod_mat_entry (FLINTN, j, i) == 0)) 7971 #else 7541 7972 for (int j= 0; j < NTLN.NumRows(); j++, iter++) 7542 7973 { 7543 7974 if (!IsZero (NTLN (j + 1,i + 1))) 7975 #endif 7544 7976 { 7545 7977 factorsConsidered.append (iter.getItem()); … … 7567 7999 irreducible= false; 7568 8000 8001 #ifdef HAVE_FLINT //TODO 8002 oldNumCols= nmod_mat_ncols (FLINTN); 8003 resultBufF= extIncreasePrecision (bufF, bufUniFactors, factorsFound, 8004 oldNumCols, oldL, evaluation, info2, 8005 source, dest, l 8006 ); 8007 nmod_mat_clear (FLINTN); 8008 #else 7569 8009 oldNumCols= NTLN.NumCols(); 7570 8010 resultBufF= extIncreasePrecision (bufF, bufUniFactors, factorsFound, … … 7572 8012 source, dest, l 7573 8013 ); 7574 8014 #endif 7575 8015 if (bufUniFactors.isEmpty() || degree (bufF) <= 0) 7576 8016 { … … 7605 8045 if (l/degMipo < liftBound) 7606 8046 { 8047 #ifdef HAVE_FLINT 8048 result=extIncreasePrecision (F, bufUniFactors, oldL, l, d, bounds, bufQ, 8049 FLINTN, evaluation, info2, source, dest 8050 ); 8051 8052 if (result.length()== nmod_mat_ncols (FLINTN)) 8053 { 8054 nmod_mat_clear (FLINTN); 8055 #else 7607 8056 result=extIncreasePrecision (F, bufUniFactors, oldL, l, d, bounds, bufQ, 7608 8057 NTLN, evaluation, info2, source, dest … … 7611 8060 if (result.length()== NTLN.NumCols()) 7612 8061 { 8062 #endif 7613 8063 delete [] bounds; 7614 8064 result= Union (result, smallFactors); … … 7618 8068 if (result.isEmpty()) 7619 8069 { 8070 #ifdef HAVE_FLINT 8071 result= extFurtherLiftingAndIncreasePrecision (F,bufUniFactors, l, 8072 liftBound, d,bounds,FLINTN, 8073 diophant, M, Pi, bufQ, 8074 evaluation, info2, source, 8075 dest 8076 ); 8077 if (result.length()== nmod_mat_ncols (FLINTN)) 8078 { 8079 nmod_mat_clear (FLINTN); 8080 #else 7620 8081 result= extFurtherLiftingAndIncreasePrecision (F,bufUniFactors, l, 7621 8082 liftBound, d, bounds, NTLN, … … 7626 8087 if (result.length()== NTLN.NumCols()) 7627 8088 { 8089 #endif 7628 8090 delete [] bounds; 7629 8091 result= Union (result, smallFactors); … … 7632 8094 } 7633 8095 } 8096 8097 #ifdef HAVE_FLINT 8098 nmod_mat_clear (FLINTN); 8099 #endif 7634 8100 7635 8101 DEBOUTLN (cerr, "lattice recombination failed");
Note: See TracChangeset
for help on using the changeset viewer.