Changeset 2156ec in git for factory


Ignore:
Timestamp:
May 3, 2012, 12:10:05 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
0d56271c672440c06e14ca2528a5185bb37e1e6f
Parents:
e2666785b249262bbfdcdc9e4ca1a39a4054e994
git-author:
Martin Lee <martinlee84@web.de>2012-05-03 12:10:05+02:00
git-committer:
Martin Lee <martinlee84@web.de>2012-05-07 14:17:10+02:00
Message:
chg: compute content in QGCD
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/algext.cc

    re26667 r2156ec  
    2424#include "cf_map.h"
    2525#include "cf_generator.h"
     26
     27#ifdef HAVE_NTL
     28#include "NTLconvert.h"
     29#endif
    2630
    2731/// compressing two polynomials F and G, M is used for compressing,
     
    585589}
    586590
     591#ifdef HAVE_NTL
     592static CanonicalForm
     593myicontent ( const CanonicalForm & f, const CanonicalForm & c )
     594{
     595    if (f.isOne() || c.isOne())
     596      return 1;
     597    if ( f.inBaseDomain() && c.inBaseDomain())
     598    {
     599      if (c.isZero()) return abs(f);
     600      return bgcd( f, c );
     601    }
     602    else if ( (f.inCoeffDomain() && c.inCoeffDomain()) ||
     603              (f.inCoeffDomain() && c.inBaseDomain()) ||
     604              (f.inBaseDomain() && c.inCoeffDomain()))
     605    {
     606      if (c.isZero()) return abs (f);
     607      ZZX NTLf= convertFacCF2NTLZZX (f);
     608      ZZX NTLc= convertFacCF2NTLZZX (c);
     609      NTLc= GCD (NTLc, NTLf);
     610      if (f.inCoeffDomain())
     611        return convertNTLZZX2CF(NTLc,f.mvar());
     612      else
     613        return convertNTLZZX2CF(NTLc,c.mvar());
     614    }
     615    else
     616    {
     617        CanonicalForm g = c;
     618        for ( CFIterator i = f; i.hasTerms() && ! g.isOne(); i++ )
     619            g = myicontent( i.coeff(), g );
     620        return g;
     621    }
     622}
     623#endif
     624
     625CanonicalForm
     626myicontent ( const CanonicalForm & f )
     627{
     628#ifdef HAVE_NTL
     629    return myicontent( f, 0 );
     630#else
     631    return 1;
     632#endif
     633}
     634
    587635CanonicalForm QGCD( const CanonicalForm & F, const CanonicalForm & G )
    588636{ // f,g in Q(a)[x1,...,xn]
     
    612660  f = F * bCommonDen(F);
    613661  g = G * bCommonDen(G);
     662  CanonicalForm contf= myicontent (f);
     663  CanonicalForm contg= myicontent (g);
     664  f /= contf;
     665  g /= contg;
     666  CanonicalForm gcdcfcg= myicontent (contf, contg);
    614667  Variable a, b;
    615668  if(hasFirstAlgVar(f,a))
     
    627680      Off( SW_RATIONAL );
    628681      Off( SW_USE_QGCD );
    629       tmp = gcd( F, G );
     682      tmp = gcdcfcg*gcd( f, g );
    630683      On( SW_USE_QGCD );
    631684      if (off_rational) Off(SW_RATIONAL);
     
    682735      if (off_rational) Off(SW_RATIONAL); else On(SW_RATIONAL);
    683736      setCharacteristic(0);
    684       return CanonicalForm(1);
     737      return gcdcfcg;
    685738    }
    686739    setCharacteristic(0);
     
    712765        setReduce(a,true);
    713766        if (off_rational) Off(SW_RATIONAL); else On(SW_RATIONAL);
    714         return tmp;
     767        return tmp*gcdcfcg;
    715768      }
    716769      Off( SW_RATIONAL );
     
    729782  setReduce(a,true);
    730783  Off( SW_USE_QGCD );
    731   D = gcd( f, g );
     784  D = gcdcfcg*gcd( f, g );
    732785  On( SW_USE_QGCD );
    733786  if (off_rational) Off(SW_RATIONAL); else On(SW_RATIONAL);
Note: See TracChangeset for help on using the changeset viewer.