Changeset 297e92 in git


Ignore:
Timestamp:
Sep 27, 2011, 3:53:23 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
30a68478d0ec6f1ae5fc55c6907b025bedae4404
Parents:
563364d1cd5bd1d1a7baf4123776a2bd37d99f23
Message:
added equality test before testing divisibility and multiply by gcd of contents
in chinrem_gcd


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

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd.cc

    r563364 r297e92  
    11561156CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG )
    11571157{
    1158   bool saveRat= isOn (SW_RATIONAL);
    1159   if (!saveRat)
    1160     On (SW_RATIONAL);
    1161   CanonicalForm f, g, cg, cl, q(0), Dp, newD, D, newq;
     1158  CanonicalForm f, g, cl, q(0), Dp, newD, D, newq;
    11621159  int p, i, dp_deg, d_deg=-1;
    11631160
    11641161  CanonicalForm cd ( bCommonDen( FF ));
    11651162  f=cd*FF;
    1166   f /=vcontent(f,Variable(1));
     1163  Variable x= Variable (1);
     1164  CanonicalForm cf, cg;
     1165  cf= icontent (f);
     1166  f /= cf;
    11671167  //cd = bCommonDen( f ); f *=cd;
    11681168  //f /=vcontent(f,Variable(1));
     
    11701170  cd = bCommonDen( GG );
    11711171  g=cd*GG;
    1172   g /=vcontent(g,Variable(1));
     1172  cg= icontent (g);
     1173  g /= cg;
    11731174  //cd = bCommonDen( g ); g *=cd;
    11741175  //g /=vcontent(g,Variable(1));
    11751176
     1177  CanonicalForm Dn, test= 0;
     1178  bool equal= false;
    11761179  i = cf_getNumBigPrimes() - 1;
    1177   cl =  f.lc()* g.lc();
    1178 
    1179   Off (SW_RATIONAL);
     1180  cl =  gcd (f.lc(),g.lc());
     1181
     1182  CanonicalForm gcdcfcg= gcd (cf, cg);
     1183  //Off (SW_RATIONAL);
    11801184  while ( true )
    11811185  {
     
    11961200    {
    11971201      //printf(" -> 1\n");
    1198       if (saveRat)
    1199         On (SW_RATIONAL);
    1200       return CanonicalForm(1);
     1202      return CanonicalForm(gcdcfcg);
    12011203    }
    12021204    if ( q.isZero() )
     
    12211223        D = mapinto( Dp );
    12221224        d_deg=dp_deg;
     1225        test= 0;
     1226        equal= false;
    12231227      }
    12241228      else
     
    12301234    if ( i >= 0 )
    12311235    {
     1236      Dn= Farey(D,q);
     1237      int is_rat= isOn (SW_RATIONAL);
    12321238      On (SW_RATIONAL);
    1233       CanonicalForm Dn= Farey(D,q);
    1234       CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL)
     1239      cd = bCommonDen( Dn ); // we need On(SW_RATIONAL)
     1240      if (!is_rat)
     1241        Off (SW_RATIONAL);
    12351242      Dn *=cd;
     1243      if (test != Dn)
     1244        test= Dn;
     1245      else
     1246        equal= true;
    12361247      //Dn /=vcontent(Dn,Variable(1));
    1237       if ( fdivides( Dn, f ) && fdivides( Dn, g ) )
     1248      if (equal && fdivides( Dn, f ) && fdivides( Dn, g ) )
    12381249      {
    1239         if (!saveRat)
    1240           Off (SW_RATIONAL);
    12411250        //printf(" -> success\n");
    1242         return Dn;
     1251        return Dn*gcdcfcg;
    12431252      }
    1244       Off (SW_RATIONAL);
     1253      equal= false;
    12451254      //else: try more primes
    12461255    }
     
    12481257    { // try other method
    12491258      //printf("try other gcd\n");
    1250       if (saveRat)
    1251         On (SW_RATIONAL);
    12521259      Off(SW_USE_CHINREM_GCD);
    12531260      D=gcd_poly( f, g );
    12541261      On(SW_USE_CHINREM_GCD);
    1255       return D;
     1262      return D*gcdcfcg;
    12561263    }
    12571264  }
Note: See TracChangeset for help on using the changeset viewer.