Changeset 1e9197 in git
- Timestamp:
- Nov 27, 2020, 11:06:46 AM (3 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38077648e7239f98078663eb941c3c979511150a')
- Children:
- 815e701a9eb465a5c6526483632b99b0dd38db32
- Parents:
- a0efc838470abff6a0d11126dd9350fd43451088
- Location:
- factory
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/FLINTconvert.cc
ra0efc8 r1e9197 734 734 } 735 735 736 #if __FLINT_RELEASE >= 20700 737 static void convFlint_RecPP ( const CanonicalForm & f, ulong * exp, fq_nmod_mpoly_t result, const fq_nmod_mpoly_ctx_t ctx, int N, const fq_nmod_ctx_t fq_ctx ) 738 { 739 // assume f!=0 740 if ( ! f.inCoeffDomain() ) 741 { 742 int l = f.level(); 743 for ( CFIterator i = f; i.hasTerms(); i++ ) 744 { 745 exp[N-l] = i.exp(); 746 convFlint_RecPP( i.coeff(), exp, result, ctx, N, fq_ctx ); 747 } 748 exp[N-l] = 0; 749 } 750 else 751 { 752 fq_nmod_t c; 753 convertFacCF2Fq_nmod_t (c, f, fq_ctx); 754 fq_nmod_mpoly_push_term_fq_nmod_ui(result,c,exp,ctx); 755 } 756 } 757 #endif 758 736 759 void convFactoryPFlintMP ( const CanonicalForm & f, nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, int N ) 737 760 { … … 765 788 Free(exp,N*sizeof(ulong)); 766 789 } 790 791 #if __FLINT_RELEASE >= 20700 792 void convFactoryPFlintMP ( const CanonicalForm & f, fq_nmod_mpoly_t res, fq_nmod_mpoly_ctx_t ctx, int N, fq_nmod_ctx_t fq_ctx ) 793 { 794 if (f.isZero()) return; 795 ulong * exp = (ulong*)Alloc(N*sizeof(ulong)); 796 memset(exp,0,N*sizeof(ulong)); 797 bool save_sym_ff= isOn (SW_SYMMETRIC_FF); 798 if (save_sym_ff) Off (SW_SYMMETRIC_FF); 799 convFlint_RecPP( f, exp, res, ctx, N, fq_ctx ); 800 if (save_sym_ff) On(SW_SYMMETRIC_FF); 801 Free(exp,N*sizeof(ulong)); 802 } 803 #endif 767 804 768 805 CanonicalForm convFlintMPFactoryP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, int N) … … 953 990 } 954 991 955 #endif 956 957 #endif 958 959 992 #endif // FLINT 2.5.3 993 994 #if __FLINT_RELEASE >= 20700 995 CFFList 996 convertFLINTFq_nmod_mpoly_factor2FacCFFList ( 997 fq_nmod_mpoly_factor_t fac, 998 const fq_nmod_mpoly_ctx_t& ctx, 999 const int N, 1000 const fq_nmod_ctx_t& fq_ctx, 1001 const Variable alpha) 1002 { 1003 CFFList result; 1004 1005 long i; 1006 1007 fq_nmod_t c; 1008 fq_nmod_init(c,fq_ctx); 1009 fq_nmod_mpoly_factor_get_constant_fq_nmod(c,fac,ctx); 1010 result.append(CFFactor(convertFq_nmod_t2FacCF(c,alpha,fq_ctx),1)); 1011 fq_nmod_clear(c,fq_ctx); 1012 1013 fq_nmod_mpoly_t p; 1014 fq_nmod_mpoly_init(p,ctx); 1015 long exp; 1016 for (i = 0; i < fac->num; i++) 1017 { 1018 fq_nmod_mpoly_factor_get_base(p,fac,i,ctx); 1019 exp=fq_nmod_mpoly_factor_get_exp_si(fac,i,ctx); 1020 result.append (CFFactor (convertFq_nmod_mpoly_t2FacCF ( 1021 p,ctx,N,fq_ctx,alpha), exp)); 1022 } 1023 fq_nmod_mpoly_clear(p,ctx); 1024 return result; 1025 } 1026 1027 void 1028 convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, 1029 const CanonicalForm& f, 1030 const fq_nmod_mpoly_ctx_t ctx, 1031 const int N, 1032 const fq_nmod_ctx_t fq_ctx 1033 ) 1034 { 1035 if (f.isZero()) return; 1036 ulong * exp = (ulong*)Alloc(N*sizeof(ulong)); 1037 memset(exp,0,N*sizeof(ulong)); 1038 convFlint_RecPP( f, exp, result, ctx, N, fq_ctx ); 1039 Free(exp,N*sizeof(ulong)); 1040 } 1041 1042 CanonicalForm 1043 convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t f, 1044 const fq_nmod_mpoly_ctx_t& ctx, 1045 const int N, 1046 const fq_nmod_ctx_t& fq_ctx, 1047 const Variable alpha) 1048 { 1049 CanonicalForm result; 1050 int d=fq_nmod_mpoly_length(f,ctx)-1; 1051 ulong* exp=(ulong*)Alloc(N*sizeof(ulong)); 1052 fq_nmod_t c; 1053 fq_nmod_init(c,fq_ctx); 1054 for(int i=d; i>=0; i--) 1055 { 1056 fq_nmod_mpoly_get_term_coeff_fq_nmod(c,f,i,ctx); 1057 fq_nmod_mpoly_get_term_exp_ui(exp,f,i,ctx); 1058 CanonicalForm term=convertFq_nmod_t2FacCF(c,alpha,fq_ctx); 1059 for ( int i = 0; i <N; i++ ) 1060 { 1061 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] ); 1062 } 1063 result+=term; 1064 } 1065 Free(exp,N*sizeof(ulong)); 1066 return result; 1067 } 1068 1069 #endif 1070 #endif // FLINT 1071 1072 -
factory/FLINTconvert.h
ra0efc8 r1e9197 43 43 #if ( __FLINT_RELEASE >= 20503) 44 44 #include <flint/fmpq_mpoly.h> 45 #include <flint/fq_nmod_mpoly_factor.h> 45 46 #endif 46 47 #endif … … 137 138 ); 138 139 140 /// conversion of a FLINT factorization over Zp(a) to a CFFList 141 CFFList 142 convertFLINTFq_nmod_mpoly_factor2FacCFFList ( 143 fq_nmod_mpoly_factor_t fac, ///< [in] a fq_nmod_mpoly_factor_t 144 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context 145 const int N, ///< [in] #vars 146 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context 147 const Variable alpha ///< [in] alpha 148 ); 149 139 150 /// conversion of a factory univariate poly over Z to a FLINT poly over 140 151 /// Z/p (for non word size p) … … 164 175 convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t 165 176 const Variable& alpha, ///< [in] algebraic variable 166 177 const fq_nmod_ctx_t ctx ///<[in] context 167 178 ); 168 179 … … 180 191 const CanonicalForm& f, ///< [in] element of Fq 181 192 const fq_nmod_ctx_t ctx ///< [in] Fq context 193 ); 194 195 /// conversion of a factory polynomial over of F_q to a FLINT fq_nmod_mpoly_t, does not do any 196 /// memory allocation for poly 197 void 198 convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, ///< [in,out] fq_nmod_mpoly__t 199 const CanonicalForm& f, ///< [in] poly over Fq 200 const fq_nmod_mpoly_ctx_t ctx,///< [in] context 201 const int N, ///< [in] #vars 202 const fq_nmod_ctx_t fq_ctx ///< [in] fq context 182 203 ); 183 204 … … 279 300 CanonicalForm convFlintMPFactoryP(fmpq_mpoly_t f, fmpq_mpoly_ctx_t ctx, int N); 280 301 CanonicalForm convFlintMPFactoryP(fmpz_mpoly_t f, fmpz_mpoly_ctx_t ctx, int N); 281 #endif 282 #endif 283 #endif 302 #endif // FLINT 2.5.3 303 #if __FLINT_RELEASE >= 20700 304 CanonicalForm 305 convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t poly, ///< [in] 306 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context 307 const int N, ///< [in] #vars 308 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context 309 const Variable alpha ///< [in] alpha 310 ); 311 #endif // FLINT2.7.0 312 #endif // FLINT 313 #endif -
factory/cf_factor.cc
ra0efc8 r1e9197 47 47 #include <flint/nmod_mpoly_factor.h> 48 48 #include <flint/fmpq_mpoly_factor.h> 49 #include <flint/fq_nmod_mpoly_factor.h> 49 50 #endif 50 51 #endif … … 880 881 else // char p, multivariate 881 882 { 882 #ifdef HAVE_NTL 883 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700) 884 // use FLINT 885 nmod_poly_t FLINTmipo, leadingCoeff; 886 fq_nmod_ctx_t fq_con; 887 fq_nmod_mpoly_ctx_t fq_mpoly_ctx; 888 889 nmod_poly_init (FLINTmipo, ch); 890 convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha)); 891 892 fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z"); 893 fq_nmod_mpoly_ctx_init(fq_mpoly_ctx,f.level(),ORD_LEX,fq_con); 894 895 fq_nmod_mpoly_t FLINTF; 896 fq_nmod_mpoly_init(FLINTF,ctx); 897 convertFacCF2Fq_nmod_mpoly_t(FLINTF,f,fq_mpoly_ctx,f.level(),fq_con); 898 fq_nmod_mpoly_factor_t res; 899 fq_nmod_mpoly_factor_init (res, fq_mpoly_ctx); 900 fq_nmod_mpoly_factor (res, FLINTF, fq_mpoly_ctx); 901 F= convertFLINTFq_nmod_mpoly_factor2FacCFFList (res, fq_mpoly_ctx,f.level(),fq_con,alpha); 902 //F.insert (CFFactor (Lc (f), 1)); 903 904 fq_nmod_mpoly_factor_clear (res, fq_mpoly_ctx); 905 fq_nmod_mpoly_clear (FLINTF, fq_mpoly_ctx); 906 nmod_poly_clear (FLINTmipo); 907 fq_nmod_mpoly_ctx_clear (fq_mpoly_ctx); 908 fq_nmod_ctx_clear (fq_con); 909 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 910 return F; 911 #elif defined(HAVE_NTL) 883 912 F= FqFactorize (f, alpha); 884 913 #else 885 factoryError ("multivariate factorization over Z/pZ(alpha) depends on NTL (missing)");914 factoryError ("multivariate factorization over Z/pZ(alpha) depends on NTL/Flint(missing)"); 886 915 return CFFList (CFFactor (f, 1)); 887 916 #endif … … 896 925 else //Q(a)[x1,...,xn] 897 926 { 898 #ifdef HAVE_NTL899 927 F= ratFactorize (f, alpha); 900 #else901 factoryError ("multivariate factorization over Q(alpha) depends on NTL(missing)");902 return CFFList (CFFactor (f, 1));903 #endif904 928 } 905 929 } -
factory/facBivar.h
ra0efc8 r1e9197 27 27 #include "cfNewtonPolygon.h" 28 28 #include "fac_util.h" 29 #include "cf_algorithm.h" 29 30 30 31 TIMING_DEFINE_PRINT(fac_bi_sqrf) … … 42 43 /// @ return @a ratBiSqrfFactorize returns a list of monic factors, the first 43 44 /// element is the leading coefficient. 44 #ifdef HAVE_NTL45 45 inline 46 46 CFList … … 276 276 } 277 277 278 #endif279 280 278 /// convert a CFFList to a CFList by dropping the multiplicity 281 279 CFList conv (const CFFList& L ///< [in] a CFFList -
factory/facFactorize.h
ra0efc8 r1e9197 173 173 } 174 174 #endif 175 #endif176 175
Note: See TracChangeset
for help on using the changeset viewer.