Changeset f63dbca in git for factory/cf_gcd.cc
- Timestamp:
- Jul 8, 1996, 10:21:10 AM (27 years ago)
- Branches:
- (u'spielwiese', 'a719bcf0b8dbc648b128303a49777a094b57592c')
- Children:
- 7b4bfe63f5e8232ccce6c9f00ab9238ceabc1041
- Parents:
- d675c7716d78a6d5c5238c8820480fc2f09a860e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
rd675c7 rf63dbca 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: cf_gcd.cc,v 1. 3 1996-06-18 12:22:54stobbe Exp $2 // $Id: cf_gcd.cc,v 1.4 1996-07-08 08:21:10 stobbe Exp $ 3 3 4 4 /* 5 5 $Log: not supported by cvs2svn $ 6 Revision 1.3 1996/06/18 12:22:54 stobbe 7 "gcd_poly_univar0: now uses getSmallPrimes (due to changes in the handling 8 of prime numbers in cf_primes. 9 " 10 6 11 Revision 1.2 1996/06/13 08:18:34 stobbe 7 12 "balance: Now balaces polynomials even if the coefficient sizes are higher … … 31 36 #include "cf_primes.h" 32 37 #include "cf_chinese.h" 38 #include "cf_map.h" 39 #include "fac_util.h" 33 40 #include "templates/functions.h" 34 41 … … 51 58 } 52 59 53 staticbool54 gcd_test_one ( const CanonicalForm & f, const CanonicalForm & g )60 bool 61 gcd_test_one ( const CanonicalForm & f, const CanonicalForm & g, bool swap ) 55 62 { 56 63 int count = 0; 57 64 // assume polys have same level; 58 65 CFRandom * sample = CFRandomFactory::generate(); 59 REvaluation e( 2, f.level(), *sample );66 REvaluation e( 2, tmax( f.level(), g.level() ), *sample ); 60 67 delete sample; 61 CanonicalForm lcf = swapvar( LC( f ), Variable(1), f.mvar() ); 62 CanonicalForm lcg = swapvar( LC( g ), Variable(1), f.mvar() ); 68 CanonicalForm lcf, lcg; 69 if ( swap ) { 70 lcf = swapvar( LC( f ), Variable(1), f.mvar() ); 71 lcg = swapvar( LC( g ), Variable(1), f.mvar() ); 72 } 73 else { 74 lcf = LC( f, Variable(1) ); 75 lcg = LC( g, Variable(1) ); 76 } 63 77 while ( ( e( lcf ).isZero() || e( lcg ).isZero() ) && count < 100 ) { 64 78 e.nextpoint(); … … 67 81 if ( count == 100 ) 68 82 return false; 69 CanonicalForm F=swapvar( f, Variable(1), f.mvar() ); 70 CanonicalForm G=swapvar( g, Variable(1), g.mvar() ); 83 CanonicalForm F, G; 84 if ( swap ) { 85 F=swapvar( f, Variable(1), f.mvar() ); 86 G=swapvar( g, Variable(1), g.mvar() ); 87 } 88 else { 89 F = f; 90 G = g; 91 } 71 92 if ( e(F).taildegree() > 0 && e(G).taildegree() > 0 ) 72 93 return false; … … 291 312 if ( i >= 0 ) { 292 313 // now balance D mod q 293 D = pp( balance( cg *D, q ) );314 D = pp( balance( D, q ) ); 294 315 if ( divides( D, f ) && divides( D, g ) ) 295 316 return D * c; … … 300 321 return gcd_poly( F, G, false ); 301 322 } 302 } 303 } 304 305 306 static CanonicalForm 307 gcd_poly( const CanonicalForm & f, const CanonicalForm& g, bool modularflag ) 323 cerr << "another try ..." << endl; 324 } 325 } 326 327 328 static CanonicalForm 329 gcd_poly1( const CanonicalForm & f, const CanonicalForm & g, bool modularflag ) 308 330 { 309 331 CanonicalForm C, Ci, Ci1, Hi, bi, pi, pi1, pi2; … … 325 347 } 326 348 else 327 if ( gcd_test_one( pi1, pi ) )349 if ( gcd_test_one( pi1, pi, true ) ) 328 350 return C; 329 351 delta = degree( pi, v ) - degree( pi1, v ); … … 353 375 } 354 376 377 378 static CanonicalForm 379 gcd_poly( const CanonicalForm & f, const CanonicalForm & g, bool modularflag ) 380 { 381 if ( isOn( SW_USE_EZGCD ) && ! ( f.isUnivariate() && g.isUnivariate() ) ) { 382 CFMap M, N; 383 compress( f, g, M, N ); 384 return N( ezgcd( M(f), M(g) ) ); 385 } 386 else { 387 return gcd_poly1( f, g, modularflag ); 388 } 389 } 390 355 391 356 392 static CanonicalForm
Note: See TracChangeset
for help on using the changeset viewer.