Changeset 4ec288 in git for factory/cf_gcd.cc


Ignore:
Timestamp:
Apr 11, 2012, 3:11:20 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
98adcdd62df51a4c6090574f59ad2b9a5d432d39
Parents:
4bafa67969ab030397c6410e512aadf5574be0dc0a7d0ca68a61f160eb5b83774592a019ed99f025
Message:
Merge pull request #94 from mmklee/swSingularFlint

first support of flint in singular:SW

TODO: improve the configure tests 
TODO: should flint be prefered over NTL by default?
TODO: suppress linking to different versions of libgmp.so in the same time due to flint
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd.cc

    r4bafa67 r4ec288  
    2929static CanonicalForm gcd_univar_ntl0( const CanonicalForm &, const CanonicalForm & );
    3030static CanonicalForm gcd_univar_ntlp( const CanonicalForm &, const CanonicalForm & );
     31#endif
     32
     33#ifdef HAVE_FLINT
     34#include "FLINTconvert.h"
     35static CanonicalForm gcd_univar_flint0 (const CanonicalForm &, const CanonicalForm &);
     36static CanonicalForm gcd_univar_flintp (const CanonicalForm &, const CanonicalForm &);
    3137#endif
    3238
     
    290296extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )
    291297{
     298  if (f.isZero())
     299  {
     300    a= 0;
     301    b= 1;
     302    return g;
     303  }
     304  else if (g.isZero())
     305  {
     306    a= 1;
     307    b= 0;
     308    return f;
     309  }
    292310#ifdef HAVE_NTL
    293311  if (isOn(SW_USE_NTL_GCD_P) && ( getCharacteristic() > 0 ) && (CFFactory::gettype() != GaloisFieldDomain)
     
    545563    {
    546564        bpure = isPurePoly(pi) && isPurePoly(pi1);
     565#ifdef HAVE_FLINT
     566        if (bpure && (CFFactory::gettype() != GaloisFieldDomain))
     567          return gcd_univar_flintp(pi,pi1)*C;
     568#else
    547569#ifdef HAVE_NTL
    548570        if ( isOn(SW_USE_NTL_GCD_P) && bpure && (CFFactory::gettype() != GaloisFieldDomain))
    549571            return gcd_univar_ntlp(pi, pi1 ) * C;
     572#endif
    550573#endif
    551574    }
     
    618641    if ( pi.isUnivariate() && pi1.isUnivariate() )
    619642    {
     643/*#ifdef HAVE_FLINT
     644        if (isPurePoly(pi) && isPurePoly(pi1) )
     645            return gcd_univar_flint0(pi, pi1 ) * C;
     646#else*/
    620647#ifdef HAVE_NTL
    621648        if ( isOn(SW_USE_NTL_GCD_0) && isPurePoly(pi) && isPurePoly(pi1) )
    622649            return gcd_univar_ntl0(pi, pi1 ) * C;
    623650#endif
     651//#endif
    624652        return gcd_poly_univar0( pi, pi1, true ) * C;
    625653    }
     
    10441072#endif
    10451073
     1074#ifdef HAVE_FLINT
     1075static CanonicalForm
     1076gcd_univar_flintp (const CanonicalForm& F, const CanonicalForm& G)
     1077{
     1078  nmod_poly_t F1, G1;
     1079  convertFacCF2nmod_poly_t (F1, F);
     1080  convertFacCF2nmod_poly_t (G1, G);
     1081  nmod_poly_gcd (F1, F1, G1);
     1082  CanonicalForm result= convertnmod_poly_t2FacCF (F1, F.mvar());
     1083  nmod_poly_clear (F1);
     1084  nmod_poly_clear (G1);
     1085  return result;
     1086}
     1087
     1088static CanonicalForm
     1089gcd_univar_flint0( const CanonicalForm & F, const CanonicalForm & G )
     1090{
     1091  fmpz_poly_t F1, G1;
     1092  convertFacCF2Fmpz_poly_t(F1, F);
     1093  convertFacCF2Fmpz_poly_t(G1, G);
     1094  fmpz_poly_gcd (F1, F1, G1);
     1095  CanonicalForm result= convertFmpz_poly_t2FacCF (F1, F.mvar());
     1096  fmpz_poly_clear (F1);
     1097  fmpz_poly_clear (G1);
     1098  return result;
     1099}
     1100#endif
     1101
     1102
    10461103/*
    10471104*  compute positions p1 and pe of optimal variables:
Note: See TracChangeset for help on using the changeset viewer.