Changeset 52a933f in git
- Timestamp:
- Jun 20, 2014, 2:45:30 PM (10 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38077648e7239f98078663eb941c3c979511150a')
- Children:
- 2080e22c0e94d72b5402e5d6ec49d7a581b21f3f
- Parents:
- a4d2fae92c6a452e379d088cfdef55fab20197de
- git-author:
- Martin Lee <martinlee84@web.de>2014-06-20 14:45:30+02:00
- git-committer:
- Martin Lee <martinlee84@web.de>2014-06-24 12:06:05+02:00
- Location:
- factory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cfEzgcd.cc
ra4d2fa r52a933f 956 956 { 957 957 if (hasFirstAlgVar (FF, a) || hasFirstAlgVar (GG, a)) 958 return GCD_Fp_extension(FF, GG, a);958 return modGCDFq (FF, GG, a); 959 959 else if (CFFactory::gettype() == GaloisFieldDomain) 960 return GCD_GF (FF, GG);960 return modGCDGF (FF, GG); 961 961 else 962 return GCD_small_p (FF, GG);962 return modGCDFp (FF, GG); 963 963 } 964 964 … … 1021 1021 { 1022 1022 if (hasFirstAlgVar (F, a) || hasFirstAlgVar (G, a)) 1023 return N (d* GCD_Fp_extension(F, G, a));1023 return N (d*modGCDFq (F, G, a)); 1024 1024 else if (CFFactory::gettype() == GaloisFieldDomain) 1025 return N (d* GCD_GF (F, G));1025 return N (d*modGCDGF (F, G)); 1026 1026 else 1027 return N (d* GCD_small_p (F, G));1027 return N (d*modGCDFp (F, G)); 1028 1028 } 1029 1029 … … 1393 1393 if (algExtension) 1394 1394 { 1395 result= GCD_Fp_extension(F, G, a);1395 result= modGCDFq (F, G, a); 1396 1396 if (extOfExt) 1397 1397 result= mapDown (result, primElem, imPrimElem, oldA, dest, source); … … 1400 1400 if (CFFactory::gettype() == GaloisFieldDomain) 1401 1401 { 1402 result= GCD_GF (F, G);1402 result= modGCDGF (F, G); 1403 1403 if (passToGF) 1404 1404 { … … 1416 1416 } 1417 1417 else 1418 return N (d* GCD_small_p (F,G));1418 return N (d*modGCDFp (F,G)); 1419 1419 } 1420 1420 … … 1427 1427 if (algExtension) 1428 1428 { 1429 result= GCD_Fp_extension(F, G, a);1429 result= modGCDFq (F, G, a); 1430 1430 if (extOfExt) 1431 1431 result= mapDown (result, primElem, imPrimElem, oldA, dest, source); … … 1434 1434 if (CFFactory::gettype() == GaloisFieldDomain) 1435 1435 { 1436 result= GCD_GF (F, G);1436 result= modGCDGF (F, G); 1437 1437 if (passToGF) 1438 1438 { … … 1454 1454 return N (d*sparseGCDFp (F,G)); 1455 1455 else 1456 return N (d* GCD_small_p (F,G));1456 return N (d*modGCDFp (F,G)); 1457 1457 } 1458 1458 } -
factory/cf_gcd.cc
ra4d2fa r52a933f 111 111 Variable a; 112 112 if (hasFirstAlgVar (fc, a) || hasFirstAlgVar (gc, a)) 113 fc= GCD_Fp_extension(fc, gc, a);113 fc=modGCDFq (fc, gc, a); 114 114 else if (CFFactory::gettype() == GaloisFieldDomain) 115 fc= GCD_GF (fc, gc);115 fc=modGCDGF (fc, gc); 116 116 else 117 fc= GCD_small_p (fc, gc);117 fc=modGCDFp (fc, gc); 118 118 } 119 119 else … … 126 126 fc= ezgcd (fc, gc); 127 127 else if (isOn(SW_USE_CHINREM_GCD)) 128 fc = chinrem_gcd( fc, gc);128 fc = modGCDZ( fc, gc); 129 129 else 130 130 { -
factory/cf_gcd_smallp.cc
ra4d2fa r52a933f 4 4 * 5 5 * This file implements the GCD of two polynomials over \f$ F_{p} \f$ , 6 * \f$ F_{p}(\alpha ) \f$ or GF based on Alg. 7.2. as described in "Algorithms 7 * for Computer Algebra" by Geddes, Czapor, Labahn 6 * \f$ F_{p}(\alpha ) \f$, GF or Z based on Alg. 7.1. and 7.2. as described in 7 * "Algorithms for Computer Algebra" by Geddes, Czapor, Labahn via modular 8 * computations. And sparse modular variants as described in Zippel 9 * "Effective Polynomial Computation", deKleine, Monagan, Wittkopf 10 * "Algorithms for the non-monic case of the sparse modular GCD algorithm" and 11 * Javadi "A new solution to the normalization problem" 8 12 * 9 13 * @author Martin Lee … … 441 445 442 446 CanonicalForm 443 GCD_Fp_extension(const CanonicalForm& F, const CanonicalForm& G,447 modGCDFq (const CanonicalForm& F, const CanonicalForm& G, 444 448 CanonicalForm& coF, CanonicalForm& coG, 445 449 Variable & alpha, CFList& l, bool& topLevel); 446 450 447 451 CanonicalForm 448 GCD_Fp_extension(const CanonicalForm& F, const CanonicalForm& G,452 modGCDFq (const CanonicalForm& F, const CanonicalForm& G, 449 453 Variable & alpha, CFList& l, bool& topLevel) 450 454 { 451 455 CanonicalForm dummy1, dummy2; 452 CanonicalForm result= GCD_Fp_extension(F, G, dummy1, dummy2, alpha, l,456 CanonicalForm result= modGCDFq (F, G, dummy1, dummy2, alpha, l, 453 457 topLevel); 454 458 return result; … … 460 464 /// Computer Algebra" by Geddes, Czapor, Labahn 461 465 CanonicalForm 462 GCD_Fp_extension(const CanonicalForm& F, const CanonicalForm& G,466 modGCDFq (const CanonicalForm& F, const CanonicalForm& G, 463 467 CanonicalForm& coF, CanonicalForm& coG, 464 468 Variable & alpha, CFList& l, bool& topLevel) … … 648 652 TIMING_START (gcd_recursion); 649 653 G_random_element= 650 GCD_Fp_extension(ppA (random_element, x), ppB (random_element, x),654 modGCDFq (ppA (random_element, x), ppB (random_element, x), 651 655 coF_random_element, coG_random_element, V_buf, 652 656 list, topLevel); … … 660 664 TIMING_START (gcd_recursion); 661 665 G_random_element= 662 GCD_Fp_extension(ppA(random_element, x), ppB(random_element, x),666 modGCDFq (ppA(random_element, x), ppB(random_element, x), 663 667 coF_random_element, coG_random_element, V_buf, 664 668 list, topLevel); … … 823 827 824 828 CanonicalForm 825 GCD_GF (const CanonicalForm& F, const CanonicalForm& G,829 modGCDGF (const CanonicalForm& F, const CanonicalForm& G, 826 830 CanonicalForm& coF, CanonicalForm& coG, 827 831 CFList& l, bool& topLevel); 828 832 829 833 CanonicalForm 830 GCD_GF (const CanonicalForm& F, const CanonicalForm& G, CFList& l,834 modGCDGF (const CanonicalForm& F, const CanonicalForm& G, CFList& l, 831 835 bool& topLevel) 832 836 { 833 837 CanonicalForm dummy1, dummy2; 834 CanonicalForm result= GCD_GF (F, G, dummy1, dummy2, l, topLevel);838 CanonicalForm result= modGCDGF (F, G, dummy1, dummy2, l, topLevel); 835 839 return result; 836 840 } … … 838 842 /// GCD of F and G over GF, based on Alg. 7.2. as described in "Algorithms for 839 843 /// Computer Algebra" by Geddes, Czapor, Labahn 840 /// Usually this algorithm will be faster than GCD_Fp_extensionsince GF has844 /// Usually this algorithm will be faster than modGCDFq since GF has 841 845 /// faster field arithmetics, however it might fail if the input is large since 842 846 /// the size of the base field is bounded by 2^16, output is monic 843 847 CanonicalForm 844 GCD_GF (const CanonicalForm& F, const CanonicalForm& G,848 modGCDGF (const CanonicalForm& F, const CanonicalForm& G, 845 849 CanonicalForm& coF, CanonicalForm& coG, 846 850 CFList& l, bool& topLevel) … … 979 983 { 980 984 expon= (int) floor((log ((double)((1<<16) - 1)))/(log((double)p)*kk)); 981 ASSERT (expon >= 2, "not enough points in GCD_GF");985 ASSERT (expon >= 2, "not enough points in modGCDGF"); 982 986 setCharacteristic (p, (int)(kk*expon), 'b'); 983 987 } … … 1000 1004 CFList list; 1001 1005 TIMING_START (gcd_recursion); 1002 G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x),1006 G_random_element= modGCDGF (ppA(random_element, x), ppB(random_element, x), 1003 1007 coF_random_element, coG_random_element, 1004 1008 list, topLevel); … … 1011 1015 CFList list; 1012 1016 TIMING_START (gcd_recursion); 1013 G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x),1017 G_random_element= modGCDGF (ppA(random_element, x), ppB(random_element, x), 1014 1018 coF_random_element, coG_random_element, 1015 1019 list, topLevel); … … 1192 1196 1193 1197 CanonicalForm 1194 GCD_small_p (const CanonicalForm& F, const CanonicalForm& G,1198 modGCDFp (const CanonicalForm& F, const CanonicalForm& G, 1195 1199 CanonicalForm& coF, CanonicalForm& coG, 1196 1200 bool& topLevel, CFList& l); 1197 1201 1198 1202 CanonicalForm 1199 GCD_small_p (const CanonicalForm& F, const CanonicalForm& G,1203 modGCDFp (const CanonicalForm& F, const CanonicalForm& G, 1200 1204 bool& topLevel, CFList& l) 1201 1205 { 1202 1206 CanonicalForm dummy1, dummy2; 1203 CanonicalForm result= GCD_small_p (F, G, dummy1, dummy2, topLevel, l);1207 CanonicalForm result= modGCDFp (F, G, dummy1, dummy2, topLevel, l); 1204 1208 return result; 1205 1209 } 1206 1210 1207 1211 CanonicalForm 1208 GCD_small_p (const CanonicalForm& F, const CanonicalForm& G,1212 modGCDFp (const CanonicalForm& F, const CanonicalForm& G, 1209 1213 CanonicalForm& coF, CanonicalForm& coG, 1210 1214 bool& topLevel, CFList& l) … … 1342 1346 TIMING_START (gcd_recursion); 1343 1347 G_random_element= 1344 GCD_small_p (ppA (random_element,x), ppB (random_element,x),1348 modGCDFp (ppA (random_element,x), ppB (random_element,x), 1345 1349 coF_random_element, coG_random_element, topLevel, 1346 1350 list); … … 1354 1358 TIMING_START (gcd_recursion); 1355 1359 G_random_element= 1356 GCD_Fp_extension(ppA (random_element, x), ppB (random_element, x),1360 modGCDFq (ppA (random_element, x), ppB (random_element, x), 1357 1361 coF_random_element, coG_random_element, V_buf, 1358 1362 list, topLevel); … … 1380 1384 TIMING_START (gcd_recursion); 1381 1385 G_random_element= 1382 GCD_Fp_extension(ppA (random_element, x), ppB (random_element, x),1386 modGCDFq (ppA (random_element, x), ppB (random_element, x), 1383 1387 coF_random_element, coG_random_element, alpha, 1384 1388 list, topLevel); … … 1448 1452 TIMING_START (gcd_recursion); 1449 1453 G_random_element= 1450 GCD_Fp_extension(ppA (random_element, x), ppB (random_element, x),1454 modGCDFq (ppA (random_element, x), ppB (random_element, x), 1451 1455 coF_random_element, coG_random_element, V_buf, 1452 1456 list, topLevel); … … 3853 3857 } 3854 3858 else 3855 return N(gcdcAcB* GCD_small_p (ppA, ppB));3859 return N(gcdcAcB*modGCDFp (ppA, ppB)); 3856 3860 } while (1); //end of first do 3857 3861 } 3858 3862 3859 TIMING_DEFINE_PRINT( chinrem_termination)3860 TIMING_DEFINE_PRINT( chinrem_recursion)3863 TIMING_DEFINE_PRINT(modZ_termination) 3864 TIMING_DEFINE_PRINT(modZ_recursion) 3861 3865 3862 3866 /// modular gcd algorithm, see Keith, Czapor, Geddes "Algorithms for Computer 3863 3867 /// Algebra", Algorithm 7.1 3864 CanonicalForm chinrem_gcd( const CanonicalForm & FF, const CanonicalForm & GG )3868 CanonicalForm modGCDZ ( const CanonicalForm & FF, const CanonicalForm & GG ) 3865 3869 { 3866 3870 CanonicalForm f, g, cl, q(0), Dp, newD, D, newq, newqh; … … 3932 3936 fp= mapinto (f); 3933 3937 gp= mapinto (g); 3934 TIMING_START ( chinrem_recursion)3938 TIMING_START (modZ_recursion) 3935 3939 #ifdef HAVE_NTL 3936 3940 if (size (fp)/maxNumVars > 500 && size (gp)/maxNumVars > 500) 3937 Dp = GCD_small_p (fp, gp, cofp, cogp);3941 Dp = modGCDFp (fp, gp, cofp, cogp); 3938 3942 else 3939 3943 { … … 3947 3951 cogp= gp/Dp; 3948 3952 #endif 3949 TIMING_END_AND_PRINT ( chinrem_recursion,3953 TIMING_END_AND_PRINT (modZ_recursion, 3950 3954 "time for gcd mod p in modular gcd: "); 3951 3955 Dp /=Dp.lc(); … … 4022 4026 cogn /= cl/cDn; 4023 4027 //cogn /= icontent (cogn); 4024 TIMING_START ( chinrem_termination);4028 TIMING_START (modZ_termination); 4025 4029 if ((terminationTest (f,g, cofn, cogn, Dn)) || 4026 4030 ((equal || q > b) && fdivides (Dn, f) && fdivides (Dn, g))) 4027 4031 { 4028 TIMING_END_AND_PRINT ( chinrem_termination,4032 TIMING_END_AND_PRINT (modZ_termination, 4029 4033 "time for successful termination in modular gcd: "); 4030 4034 //printf(" -> success\n"); 4031 4035 return Dn*gcdcfcg; 4032 4036 } 4033 TIMING_END_AND_PRINT ( chinrem_termination,4037 TIMING_END_AND_PRINT (modZ_termination, 4034 4038 "time for unsuccessful termination in modular gcd: "); 4035 4039 equal= false; -
factory/cf_gcd_smallp.h
ra4d2fa r52a933f 5 5 /** @file cf_gcd_smallp.h 6 6 * 7 * This file defines the functions GCD_Fp_extension which computes the GCD of 8 * two polynomials over \f$ F_{p}(\alpha ) \f$ , GCD_small_p which computes the 9 * GCD of two polynomials over \f$ F_{p} \f$ , and GCD_GF which computes the 10 * GCD of two polynomials over GF. Algorithms are based on "On the Genericity of 11 * the Modular Polynomial GCD Algorithm" by E. Kaltofen & M. Monagan 7 * modular and sparse modular GCD algorithms over finite fields and Z. 12 8 * 13 9 * @author Martin Lee … … 25 21 #include "cf_factory.h" 26 22 27 CanonicalForm GCD_Fp_extension(const CanonicalForm& F, const CanonicalForm& G,23 CanonicalForm modGCDFq (const CanonicalForm& F, const CanonicalForm& G, 28 24 Variable & alpha, CFList& l, bool& top_level); 29 25 30 26 /// GCD of A and B over \f$ F_{p}(\alpha ) \f$ 31 static inline CanonicalForm GCD_Fp_extension(const CanonicalForm& A, const CanonicalForm& B,27 static inline CanonicalForm modGCDFq (const CanonicalForm& A, const CanonicalForm& B, 32 28 Variable & alpha) 33 29 { 34 30 CFList list; 35 31 bool top_level= true; 36 return GCD_Fp_extension(A, B, alpha, list, top_level);32 return modGCDFq (A, B, alpha, list, top_level); 37 33 } 38 34 39 35 40 CanonicalForm GCD_small_p (const CanonicalForm& F, const CanonicalForm& G,36 CanonicalForm modGCDFp (const CanonicalForm& F, const CanonicalForm& G, 41 37 bool& top_level, CFList& l); 42 38 43 CanonicalForm GCD_small_p (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& coF, CanonicalForm& coG,39 CanonicalForm modGCDFp (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& coF, CanonicalForm& coG, 44 40 bool& topLevel, CFList& l); 45 41 46 42 ///GCD of A and B over \f$ F_{p} \f$ 47 static inline CanonicalForm GCD_small_p (const CanonicalForm& A, const CanonicalForm& B)43 static inline CanonicalForm modGCDFp (const CanonicalForm& A, const CanonicalForm& B) 48 44 { 49 45 CFList list; 50 46 bool top_level= true; 51 return GCD_small_p (A, B, top_level, list);47 return modGCDFp (A, B, top_level, list); 52 48 } 53 49 54 static inline CanonicalForm GCD_small_p (const CanonicalForm& A, const CanonicalForm& B, CanonicalForm& coA, CanonicalForm& coB)50 static inline CanonicalForm modGCDFp (const CanonicalForm& A, const CanonicalForm& B, CanonicalForm& coA, CanonicalForm& coB) 55 51 { 56 52 CFList list; 57 53 bool top_level= true; 58 return GCD_small_p (A, B, coA, coB, top_level, list);54 return modGCDFp (A, B, coA, coB, top_level, list); 59 55 } 60 56 61 CanonicalForm GCD_GF (const CanonicalForm& F, const CanonicalForm& G, CFList& l,57 CanonicalForm modGCDGF (const CanonicalForm& F, const CanonicalForm& G, CFList& l, 62 58 bool& top_level); 63 59 64 60 /// GCD of A and B over GF 65 static inline CanonicalForm GCD_GF (const CanonicalForm& A, const CanonicalForm& B)61 static inline CanonicalForm modGCDGF (const CanonicalForm& A, const CanonicalForm& B) 66 62 { 67 63 ASSERT (CFFactory::gettype() == GaloisFieldDomain, … … 69 65 CFList list; 70 66 bool top_level= true; 71 return GCD_GF (A, B, list, top_level);67 return modGCDGF (A, B, list, top_level); 72 68 } 73 69 … … 111 107 const CanonicalForm& cand); 112 108 113 CanonicalForm chinrem_gcd( const CanonicalForm & FF, const CanonicalForm & GG );109 CanonicalForm modGCDZ ( const CanonicalForm & FF, const CanonicalForm & GG ); 114 110 #endif
Note: See TracChangeset
for help on using the changeset viewer.