Changeset 91bc52 in git
- Timestamp:
- Jan 23, 2021, 5:13:36 PM (2 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- d854d7ee2faa25bc4e7476b6668602d7f4f39384
- Parents:
- 35c6e2c47bae1f858ec6f4a0cdab911b80a1c383
- git-author:
- Daniel Schultz <tthsqe12@gmail.com>2021-01-23 17:13:36+01:00
- git-committer:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2021-01-26 11:36:58+01:00
- Location:
- factory
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/FLINTconvert.cc
r35c6e2c r91bc52 113 113 #include "FLINTconvert.h" 114 114 115 // TODO!! decide if the input to convertCF2Fmpz is expected to be: 116 // initialized, or 117 // uninitialized 115 118 void convertCF2Fmpz (fmpz_t result, const CanonicalForm& f) 116 119 { 117 120 if (f.isImm()) 118 *result=f.intval(); 121 *result=f.intval(); // assumes uninitialized 119 122 //fmpz_set_si (result, f.intval()); 120 123 else … … 122 125 mpz_t gmp_val; 123 126 f.mpzval(gmp_val); 124 fmpz_set_mpz (result, gmp_val); 127 fmpz_set_mpz (result, gmp_val); // assumes initialized 125 128 mpz_clear (gmp_val); 126 129 } … … 132 135 _fmpz_poly_set_length(result, degree(f)+1); 133 136 for (CFIterator i= f; i.hasTerms(); i++) 134 convertCF2Fmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); 137 convertCF2Fmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized 135 138 } 136 139 … … 299 302 { 300 303 for (CFIterator i= f; i.hasTerms(); i++) 301 convertCF2Fmpz (&result[i.exp()], i.coeff()); 304 convertCF2Fmpz (&result[i.exp()], i.coeff()); // assumes ? 302 305 } 303 306 … … 312 315 CanonicalForm den= bCommonDen (f); 313 316 convertFacCF2Fmpz_array (fmpq_poly_numref (result), f*den); 314 convertCF2Fmpz (fmpq_poly_denref (result), den); 317 convertCF2Fmpz (fmpq_poly_denref (result), den); // assumes initialized 315 318 316 319 if (!isRat) … … 409 412 fmpz_t FLINTp; 410 413 fmpz_init (FLINTp); 411 convertCF2Fmpz (FLINTp, b.getpk()); 414 convertCF2Fmpz (FLINTp, b.getpk()); // assumes initialized 412 415 fmpz_mod_ctx_t ctx; 413 416 fmpz_mod_ctx_init(ctx,FLINTp); … … 470 473 { 471 474 fmpz_poly_init2 (result, fq_ctx_degree(ctx)); 472 ASSERT (degree (f) < fq_ctx_degree (ctx), "input is not reduced");473 _fmpz_poly_set_length(result, degree(f)+1); 475 _fmpz_poly_set_length(result, fq_ctx_degree(ctx)); 476 474 477 for (CFIterator i= f; i.hasTerms(); i++) 475 convertCF2Fmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff());476 #if (__FLINT_RELEASE >= 20700)477 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, degree (f) + 1,478 ctx->ctxp->n);479 #else 480 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, degree (f) + 1,481 &ctx->p);482 #endif 478 { 479 ASSERT(i.exp() < result->length, "input is not reduced"); 480 convertCF2Fmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized 481 } 482 483 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, result->length, 484 fq_ctx_prime(ctx)); 485 483 486 _fmpz_poly_normalise (result); 484 487 } … … 495 498 { 496 499 fq_poly_init2 (result, degree (f)+1, ctx); 500 497 501 _fq_poly_set_length (result, degree (f) + 1, ctx); 498 fmpz_poly_t buf; 502 499 503 for (CFIterator i= f; i.hasTerms(); i++) 500 504 { 501 convertFacCF2Fmpz_poly_t (buf, i.coeff()); 502 #if (__FLINT_RELEASE >= 20700) 503 _fmpz_vec_scalar_mod_fmpz (buf->coeffs, buf->coeffs, degree (i.coeff()) + 1, 504 ctx->ctxp->n); 505 #else 506 _fmpz_vec_scalar_mod_fmpz (buf->coeffs, buf->coeffs, degree (i.coeff()) + 1, 507 &ctx->p); 508 #endif 509 _fmpz_poly_normalise (buf); 505 fq_t buf; 506 convertFacCF2Fq_t (buf, i.coeff(), ctx); 510 507 fq_poly_set_coeff (result, i.exp(), buf, ctx); 511 f mpz_poly_clear (buf);508 fq_clear (buf, ctx); 512 509 } 513 510 } … … 582 579 for(j=m.columns();j>0;j--) 583 580 { 584 convertCF2Fmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); 581 convertCF2Fmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); // assumes initialized 585 582 } 586 583 } … … 728 725 fmpz_t c; 729 726 fmpz_init(c); 730 convertCF2Fmpz(c,f); 727 convertCF2Fmpz(c,f); // assumes initialized 731 728 fmpz_mpoly_push_term_fmpz_ui(result,c,exp,ctx); 732 729 fmpz_clear(c); -
factory/cf_factor.cc
r35c6e2c r91bc52 925 925 else //Q(a)[x1,...,xn] 926 926 { 927 #if def HAVE_NTL927 #if defined(HAVE_NTL) || defined(HAVE_FLINT) 928 928 F= ratFactorize (f, alpha); 929 929 #else 930 factoryError ("multivariate factorization over Q(alpha) depends on NTL (missing)");930 factoryError ("multivariate factorization over Q(alpha) depends on NTL or FLINT (missing)"); 931 931 return CFFList (CFFactor (f, 1)); 932 932 #endif -
factory/facBivar.cc
r35c6e2c r91bc52 185 185 } 186 186 187 #if def HAVE_NTL// henselLiftAndEarly187 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // henselLiftAndEarly 188 188 CFList biFactorize (const CanonicalForm& F, const Variable& v) 189 189 { -
factory/facFactorize.h
r35c6e2c r91bc52 43 43 const Variable& v ///< [in] some algebraic variable 44 44 ); 45 #ifdef HAVE_NTL // ratBiSqrfFactorize 45 46 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // ratBiSqrfFactorize 46 47 /// factorize a squarefree multivariate polynomial over \f$ Q(\alpha) \f$ 47 48 /// … … 69 70 #endif 70 71 71 #if def HAVE_NTL// multiFactorize, henselLiftAndEarly, nonMonicHenselLift72 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // multiFactorize, henselLiftAndEarly, nonMonicHenselLift 72 73 /// factorize a multivariate polynomial over \f$ Q(\alpha) \f$ 73 74 /// -
factory/facFqBivar.cc
r35c6e2c r91bc52 1148 1148 } 1149 1149 1150 #if def HAVE_NTL// henselLift121150 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // henselLift12 1151 1151 CFList 1152 1152 henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList& -
factory/facHensel.cc
r35c6e2c r91bc52 474 474 diophantine (const CanonicalForm& F, const CFList& factors); 475 475 476 #if def HAVE_NTL// diophantine476 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // diophantine 477 477 CFList 478 478 diophantineHensel (const CanonicalForm & F, const CFList& factors, … … 777 777 778 778 779 779 780 /// solve \f$ 1=\sum_{i=1}^n{\delta_{i} \prod_{j\neq i}{f_j}} \f$ mod \f$p^k\f$ 780 781 /// over \f$ Q(\alpha) \f$ by first computing mod \f$p\f$ and if no zero divisor 781 782 /// occurred compute it mod \f$p^k\f$ 782 #if def HAVE_NTL// XGCD, zzp_eX783 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // XGCD, zzp_eX 783 784 CFList 784 785 diophantineQa (const CanonicalForm& F, const CanonicalForm& G, … … 862 863 else 863 864 buf2= divNTL (F, i.getItem(), b); 865 866 #ifdef HAVE_NTL 864 867 ZZ_p::init (convertFacCF2NTLZZ (b.getpk())); 865 868 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (getMipo (gamma))); … … 871 874 result.append (b (convertNTLZZ_pEX2CF (NTLS, x, gamma))); 872 875 result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma))); 876 #else // flint 877 fmpz_t bigpk; 878 fq_ctx_t fqctx; 879 fmpz_mod_poly_t FLINTmipo; 880 fq_poly_t FLINTS, FLINTT, FLINTbuf3, FLINTbuf1, FLINTbuf2; 881 fq_t fcheck; 882 883 fmpz_init(bigpk); // does convert expect an initalized object? 884 convertCF2Fmpz(bigpk, b.getpk()); 885 886 convertFacCF2Fmpz_mod_poly_t(FLINTmipo, getMipo(gamma), bigpk); 887 888 #if __FLINT_RELEASE >= 20700 889 fmpz_mod_ctx_t bigpk_ctx; 890 fmpz_mod_ctx_init(bigpk_ctx, bigpk); 891 fq_ctx_init_modulus(fqctx, FLINTmipo, bigpk_ctx, "Z"); 892 fmpz_mod_ctx_clear(bigpk_ctx); 893 #else 894 fq_ctx_init_modulus(fqctx, FLINTmipo, "Z"); 895 #endif 896 897 fq_init(fcheck, fqctx); 898 fq_poly_init(FLINTS, fqctx); 899 fq_poly_init(FLINTT, fqctx); 900 fq_poly_init(FLINTbuf3, fqctx); 901 //fq_poly_init(FLINTbuf1, fqctx); //convert expects uninitialized! 902 //fq_poly_init(FLINTbuf2, fqctx); //convert expects uninitialized! 903 convertFacCF2Fq_poly_t(FLINTbuf1, buf1, fqctx); 904 convertFacCF2Fq_poly_t(FLINTbuf2, buf2, fqctx); 905 906 fq_poly_xgcd_euclidean_f(fcheck, FLINTbuf3, FLINTS, FLINTT, 907 FLINTbuf1, FLINTbuf2, fqctx); 908 if (!fq_is_one(fcheck, fqctx)) 909 { 910 printf("factory error: non-invertible element encountered\n"); 911 abort(); 912 } 913 914 result.append(b(convertFq_poly_t2FacCF(FLINTS, x, alpha, fqctx))); 915 result.append(b(convertFq_poly_t2FacCF(FLINTT, x, alpha, fqctx))); 916 #endif 917 873 918 if (i.hasItem()) 874 919 i++; … … 879 924 else 880 925 buf1= divNTL (F, i.getItem(), b); 926 927 #ifdef HAVE_NTL 881 928 XGCD (NTLbuf3, NTLS, NTLT, NTLbuf3, convertFacCF2NTLZZ_pEX (buf1, NTLmipo)); 882 929 S= convertNTLZZ_pEX2CF (NTLS, x, gamma); 930 #else // HAVE_FLINT 931 fq_poly_clear(FLINTbuf1, fqctx); //convert expects uninitialized! 932 convertFacCF2Fq_poly_t(FLINTbuf1, buf1, fqctx); 933 fq_poly_xgcd_euclidean_f(fcheck, FLINTbuf3, FLINTS, FLINTT, 934 FLINTbuf3, FLINTbuf1, fqctx); 935 if (!fq_is_one(fcheck, fqctx)) 936 { 937 printf("factory error: non-invertible element encountered\n"); 938 abort(); 939 } 940 941 S= convertFq_poly_t2FacCF(FLINTS, x, alpha, fqctx); 942 #endif 943 883 944 CFListIterator k= bufFactors; 884 945 for (CFListIterator j= result; j.hasItem(); j++, k++) … … 887 948 j.getItem()= modNTL (j.getItem(), k.getItem(), b); 888 949 } 950 #if HAVE_NTL 889 951 result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma))); 890 } 952 #else 953 result.append (b (convertFq_poly_t2FacCF(FLINTT, x, alpha, fqctx))); 954 #endif 955 } 956 957 #if HAVE_NTL 958 // no cleanup for ntl 959 #else 960 fmpz_clear(bigpk); 961 fq_clear(fcheck, fqctx); 962 fq_poly_clear(FLINTS, fqctx); 963 fq_poly_clear(FLINTT, fqctx); 964 fq_poly_clear(FLINTbuf3, fqctx); 965 fq_poly_clear(FLINTbuf1, fqctx); 966 fq_poly_clear(FLINTbuf2, fqctx); 967 fq_ctx_clear(fqctx); 968 #endif 969 891 970 return result; 892 971 } 893 972 #endif 894 973 895 #if def HAVE_NTL// diophantineQa974 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // diophantineQa 896 975 CFList 897 976 diophantine (const CanonicalForm& F, const CanonicalForm& G, … … 946 1025 #endif 947 1026 948 #if def HAVE_NTL// diophantineQa1027 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // diophantineQa 949 1028 CFList 950 1029 diophantine (const CanonicalForm& F, const CFList& factors) … … 1158 1237 } 1159 1238 1160 #if def HAVE_NTL// diopantineQa1239 #if defined(HAVE_NTL) || defined(HAVE_FLINT) // diopantineQa 1161 1240 void 1162 1241 henselLift12 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi, … … 1218 1297 #endif 1219 1298 1220 #if def HAVE_NTL//henselLift121299 #if defined(HAVE_NTL) || defined(HAVE_FLINT) //henselLift12 1221 1300 void 1222 1301 henselLift12 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,
Note: See TracChangeset
for help on using the changeset viewer.