Changeset 297e92 in git
- Timestamp:
- Sep 27, 2011, 3:53:23 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 30a68478d0ec6f1ae5fc55c6907b025bedae4404
- Parents:
- 563364d1cd5bd1d1a7baf4123776a2bd37d99f23
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
r563364 r297e92 1156 1156 CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG ) 1157 1157 { 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; 1162 1159 int p, i, dp_deg, d_deg=-1; 1163 1160 1164 1161 CanonicalForm cd ( bCommonDen( FF )); 1165 1162 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; 1167 1167 //cd = bCommonDen( f ); f *=cd; 1168 1168 //f /=vcontent(f,Variable(1)); … … 1170 1170 cd = bCommonDen( GG ); 1171 1171 g=cd*GG; 1172 g /=vcontent(g,Variable(1)); 1172 cg= icontent (g); 1173 g /= cg; 1173 1174 //cd = bCommonDen( g ); g *=cd; 1174 1175 //g /=vcontent(g,Variable(1)); 1175 1176 1177 CanonicalForm Dn, test= 0; 1178 bool equal= false; 1176 1179 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); 1180 1184 while ( true ) 1181 1185 { … … 1196 1200 { 1197 1201 //printf(" -> 1\n"); 1198 if (saveRat) 1199 On (SW_RATIONAL); 1200 return CanonicalForm(1); 1202 return CanonicalForm(gcdcfcg); 1201 1203 } 1202 1204 if ( q.isZero() ) … … 1221 1223 D = mapinto( Dp ); 1222 1224 d_deg=dp_deg; 1225 test= 0; 1226 equal= false; 1223 1227 } 1224 1228 else … … 1230 1234 if ( i >= 0 ) 1231 1235 { 1236 Dn= Farey(D,q); 1237 int is_rat= isOn (SW_RATIONAL); 1232 1238 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); 1235 1242 Dn *=cd; 1243 if (test != Dn) 1244 test= Dn; 1245 else 1246 equal= true; 1236 1247 //Dn /=vcontent(Dn,Variable(1)); 1237 if ( fdivides( Dn, f ) && fdivides( Dn, g ) )1248 if (equal && fdivides( Dn, f ) && fdivides( Dn, g ) ) 1238 1249 { 1239 if (!saveRat)1240 Off (SW_RATIONAL);1241 1250 //printf(" -> success\n"); 1242 return Dn ;1251 return Dn*gcdcfcg; 1243 1252 } 1244 Off (SW_RATIONAL);1253 equal= false; 1245 1254 //else: try more primes 1246 1255 } … … 1248 1257 { // try other method 1249 1258 //printf("try other gcd\n"); 1250 if (saveRat)1251 On (SW_RATIONAL);1252 1259 Off(SW_USE_CHINREM_GCD); 1253 1260 D=gcd_poly( f, g ); 1254 1261 On(SW_USE_CHINREM_GCD); 1255 return D ;1262 return D*gcdcfcg; 1256 1263 } 1257 1264 }
Note: See TracChangeset
for help on using the changeset viewer.