[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:54:39 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit 4de02bf2d596a6cb2019f581e3980176105dc0eb
Author: Martin Lee <martinlee84 at web.de>
Date: Tue Dec 20 00:37:08 2011 +0000
chg: use Flint GCD instead of NTL gcd
diff --git a/factory/cf_gcd.cc b/factory/cf_gcd.cc
index 65c2bd6..0b377c5 100644
--- a/factory/cf_gcd.cc
+++ b/factory/cf_gcd.cc
@@ -29,6 +29,12 @@ static CanonicalForm gcd_univar_ntl0( const CanonicalForm &, const CanonicalForm
static CanonicalForm gcd_univar_ntlp( const CanonicalForm &, const CanonicalForm & );
#endif
+#ifdef HAVE_FLINT
+#include "FLINTconvert.h"
+static CanonicalForm gcd_univar_flint0 (const CanonicalForm &, const CanonicalForm &);
+static CanonicalForm gcd_univar_flintp (const CanonicalForm &, const CanonicalForm &);
+#endif
+
static CanonicalForm cf_content ( const CanonicalForm &, const CanonicalForm & );
static void cf_prepgcd( const CanonicalForm &, const CanonicalForm &, int &, int &, int & );
@@ -543,7 +549,10 @@ gcd_poly_p( const CanonicalForm & f, const CanonicalForm & g )
else
{
bpure = isPurePoly(pi) && isPurePoly(pi1);
-#ifdef HAVE_NTL
+#ifdef HAVE_FLINT
+ if (bpure && (CFFactory::gettype() != GaloisFieldDomain))
+ return gcd_univar_flintp(pi,pi1)*C;
+#else ifdef HAVE_NTL
if ( isOn(SW_USE_NTL_GCD_P) && bpure && (CFFactory::gettype() != GaloisFieldDomain))
return gcd_univar_ntlp(pi, pi1 ) * C;
#endif
@@ -616,7 +625,10 @@ gcd_poly_0( const CanonicalForm & f, const CanonicalForm & g )
C = gcd( Ci, Ci1 );
if ( pi.isUnivariate() && pi1.isUnivariate() )
{
-#ifdef HAVE_NTL
+#ifdef HAVE_FLINT
+ if (isPurePoly(pi) && isPurePoly(pi1) )
+ return gcd_univar_flint0(pi, pi1 ) * C;
+#else ifdef HAVE_NTL
if ( isOn(SW_USE_NTL_GCD_0) && isPurePoly(pi) && isPurePoly(pi1) )
return gcd_univar_ntl0(pi, pi1 ) * C;
#endif
@@ -1042,6 +1054,35 @@ gcd_univar_ntlp( const CanonicalForm & F, const CanonicalForm & G )
#endif
+#ifdef HAVE_FLINT
+static CanonicalForm
+gcd_univar_flintp (const CanonicalForm& F, const CanonicalForm& G)
+{
+ nmod_poly_t F1, G1;
+ convertFacCF2nmod_poly_t (F1, F);
+ convertFacCF2nmod_poly_t (G1, G);
+ nmod_poly_gcd (F1, F1, G1);
+ CanonicalForm result= convertnmod_poly_t2FacCF (F1, F.mvar());
+ nmod_poly_clear (F1);
+ nmod_poly_clear (G1);
+ return result;
+}
+
+static CanonicalForm
+gcd_univar_flint0( const CanonicalForm & F, const CanonicalForm & G )
+{
+ fmpz_poly_t F1, G1;
+ convertFacCF2Fmpz_poly_t(F1, F);
+ convertFacCF2Fmpz_poly_t(G1, G);
+ fmpz_poly_gcd (F1, F1, G1);
+ CanonicalForm result= convertFmpz_poly_t2FacCF (F1, F.mvar());
+ fmpz_poly_clear (F1);
+ fmpz_poly_clear (G1);
+ return result;
+}
+#endif
+
+
/*
* compute positions p1 and pe of optimal variables:
* pe is used in "ezgcd" and
--
an open source computer algebra system
More information about the debian-science-commits
mailing list