Changeset c30347 in git


Ignore:
Timestamp:
Dec 19, 2007, 3:27:14 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
5a01219e1920f1b747aebaf636aa8c5b8f61b714
Parents:
1758fb8f662065e47c332dbd6c4688e8a2dd973c
Message:
*hannes: some other gcd strat


git-svn-id: file:///usr/local/Singular/svn/trunk@10482 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd.cc

    r1758fb rc30347  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_gcd.cc,v 1.57 2007-12-07 11:26:57 Singular Exp $ */
     2/* $Id: cf_gcd.cc,v 1.58 2007-12-19 14:27:14 Singular Exp $ */
    33
    44#include <config.h>
     
    8989icontent ( const CanonicalForm & f, const CanonicalForm & c )
    9090{
    91     if ( f.inCoeffDomain() )
    92         return gcd( f, c );
    93     else {
     91    if ( f.inBaseDomain() )
     92    {
     93      if (c.isZero()) return abs(f);
     94      return bgcd( f, c );
     95    }
     96    else if ( f.inCoeffDomain() )
     97       return gcd(f,c);
     98    else
     99    {
    94100        CanonicalForm g = c;
    95101        for ( CFIterator i = f; i.hasTerms() && ! g.isOne(); i++ )
     
    469475  int mp, cc, p1, pe;
    470476  mp = f.level()+1;
     477#if 0
     478  if (( getCharacteristic() == 0 )
     479  && (f.level() >4)
     480  && (g.level() >4)
     481  && isOn( SW_USE_CHINREM_GCD)
     482  && (!f.isUnivariate())
     483  && (!g.isUnivariate())
     484  && (isPurePoly_m(f))
     485  && (isPurePoly_m(g))
     486  )
     487  {
     488      return chinrem_gcd( f, g );
     489  }
     490#endif
    471491  cf_prepgcd( f, g, cc, p1, pe);
    472492  if ( cc != 0 )
     
    490510      return d1;
    491511  bool fc_isUnivariate=fc.isUnivariate();
     512  bool fc_and_gc_Univariate=fc_isUnivariate && gc.isUnivariate();
    492513  if ( getCharacteristic() != 0 )
    493514  {
    494     if (isOn( SW_USE_EZGCD_P ) && (!fc_isUnivariate))
     515    if (isOn( SW_USE_EZGCD_P ) && (!fc_and_gc_Univariate))
    495516    {
    496517      if ( pe == 1 )
     
    509530        fc = swapvar( fin_ezgcd( fc, gc ), Variable(1), Variable(pe) );
    510531      }
    511     } 
     532    }
    512533    else if (isOn(SW_USE_GCD_P))
    513534    {
     
    523544    }
    524545  }
    525   else if (!fc_isUnivariate)
    526   {
     546  else if (!fc_and_gc_Univariate)
     547  {
     548    if (
     549    isOn(SW_USE_CHINREM_GCD)
     550    && (gc.level() >5)
     551    && (fc.level() >5)
     552    && (isPurePoly_m(fc)) && (isPurePoly_m(gc))
     553    )
     554    {
     555    #if 0
     556      if ( p1 == fc.level() )
     557        fc = chinrem_gcd( fc, gc );
     558      else
     559      {
     560        fc = replacevar( fc, Variable(p1), Variable(mp) );
     561        gc = replacevar( gc, Variable(p1), Variable(mp) );
     562        fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) );
     563      }
     564    #else
     565      fc = chinrem_gcd( fc, gc);
     566    #endif
     567    }
    527568    if ( isOn( SW_USE_EZGCD ) )
    528569    {
     
    545586    else if (
    546587    isOn(SW_USE_CHINREM_GCD)
    547     && (!gc.isUnivariate())
    548588    && (isPurePoly_m(fc)) && (isPurePoly_m(gc))
    549589    )
     
    561601      fc = chinrem_gcd( fc, gc);
    562602    #endif
     603    }
     604    else
     605    {
     606       fc = gcd_poly_0( fc, gc );
    563607    }
    564608  }
     
    10401084      i--;
    10411085    }
     1086    //printf("try p=%d\n",p);
    10421087    setCharacteristic( p );
    1043     Dp = gcd( mapinto( f ), mapinto( g ) );
     1088    Dp = gcd_poly( mapinto( f ), mapinto( g ) );
    10441089    Dp /=Dp.lc();
    10451090    setCharacteristic( 0 );
    10461091    dp_deg=totaldegree(Dp);
    10471092    if ( dp_deg == 0 )
     1093    {
     1094      //printf(" -> 1\n");
    10481095      return CanonicalForm(1);
     1096    }
    10491097    if ( q.isZero() )
    10501098    {
     
    10631111      else if ( dp_deg < d_deg )
    10641112      {
     1113        //printf(" were all bad, try more\n");
    10651114        // all previous p's are bad primes
    10661115        q = p;
    10671116        D = mapinto( Dp );
    10681117        d_deg=dp_deg;
     1118      }
     1119      else
     1120      {
     1121        //printf(" was bad, try more\n");
    10691122      }
    10701123      //else dp_deg > d_deg: bad prime
     
    10811134      if ( fdivides( Dn, f ) && fdivides( Dn, g ) )
    10821135      {
     1136        //printf(" -> success\n");
    10831137        return Dn;
    10841138      }
     
    10871141    else
    10881142    { // try other method
     1143      //printf("try other gcd\n");
    10891144      Off(SW_USE_CHINREM_GCD);
    10901145      D=gcd_poly( f, g );
Note: See TracChangeset for help on using the changeset viewer.