Changeset e22ea7 in git
- Timestamp:
- Jan 5, 2005, 12:27:17 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 7dd754926fbde53f14c682a4eee9f02960f174e1
- Parents:
- 672566a7f6af2a2349ebd32302a58c4c91a0259e
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
r672566a re22ea7 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.2 6 2004-11-25 15:43:36Singular Exp $ */2 /* $Id: cf_gcd.cc,v 1.27 2005-01-05 11:27:17 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 376 376 CFMap M, N; 377 377 compress( f, g, M, N ); 378 #if 0 378 379 CanonicalForm r=N( ezgcd( M(f), M(g) ) ); 379 380 if ((f%r!=0) || (g % r !=0)) … … 383 384 return gcd_poly1( f, g, modularflag); 384 385 } 385 else return r; 386 else 387 return r; 388 #else 389 return N( ezgcd( M(f), M(g) ) ); 390 #endif 386 391 } 387 392 else if ( isOn( SW_USE_SPARSEMOD ) 388 393 && ! ( f.isUnivariate() && g.isUnivariate() ) ) 389 394 { 395 #if 0 390 396 CanonicalForm r=sparsemod( f, g ); 391 397 if ((f%r!=0) || (g % r !=0)) … … 393 399 if (si_factor_reminder) 394 400 printf("sparsemod failed, trying gcd_poly1\n"); 395 return gcd_poly1( f, g, modularflag); 401 return r; 402 //return gcd_poly1( f, g, modularflag); 396 403 } 397 else return r; 404 else 405 return r; 406 #else 407 return sparsemod( f, g ); 408 #endif 398 409 } 399 410 else -
factory/fac_ezgcd.cc
r672566a re22ea7 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_ezgcd.cc,v 1.1 4 2001-01-24 18:09:41Singular Exp $ */2 /* $Id: fac_ezgcd.cc,v 1.15 2005-01-05 11:27:17 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 40 40 CanonicalForm F, G, f, g, d, Fb, Gb, Db, Fbt, Gbt, Dbt, B0, B, D0, lcF, lcG, lcD; 41 41 CFArray DD( 1, 2 ), lcDD( 1, 2 ); 42 int degF, degG, delta, deltaold,t;42 int degF, degG, delta, t; 43 43 REvaluation bt; 44 44 bool gcdfound = false; … … 54 54 F = FF / f; G = GG / g; 55 55 if ( F.isUnivariate() && G.isUnivariate() ) 56 { 57 DEBDECLEVEL( cerr, "ezgcd" ); 56 58 return d * gcd( F, G ); 59 } 57 60 else if ( gcd_test_one( F, G, false ) ) 61 { 62 DEBDECLEVEL( cerr, "ezgcd" ); 58 63 return d; 64 } 59 65 lcF = LC( F, x ); lcG = LC( G, x ); 60 66 lcD = gcd( lcF, lcG ); … … 64 70 bound = findBound( F, G, lcF, lcG, degF, degG ); 65 71 if ( ! internal ) 66 b = REvaluation( 2, t, IntRandom( 100 ) );72 b = REvaluation( 2, t, IntRandom( 50 ) ); 67 73 while ( ! gcdfound ) { 68 74 /// ---> A2 … … 78 84 /// ---> A3 79 85 if ( delta == 0 ) 80 return d; 86 { 87 DEBDECLEVEL( cerr, "ezgcd" ); 88 return d; 89 } 81 90 /// ---> A4 82 deltaold = delta + 1;83 while ( deltaold != delta) {91 //deltaold = delta; 92 while ( 1 ) { 84 93 bt = b; 85 94 findeval( F, G, Fbt, Gbt, Dbt, bt, delta + 1, degF, degG ); 86 if ( degree( Dbt ) == 0 ) 95 int dd=degree( Dbt ); 96 if ( dd /*degree( Dbt )*/ == 0 ) 97 { 98 DEBDECLEVEL( cerr, "ezgcd" ); 87 99 return d; 88 if ( degree( Dbt ) == delta ) 89 deltaold = delta;90 else if ( degree( Dbt ) < delta ) {91 deltaold = delta;92 delta = d egree( Dbt );100 } 101 if ( dd /*degree( Dbt )*/ == delta ) 102 break; 103 else if ( dd /*degree( Dbt )*/ < delta ) { 104 delta = dd /*degree( Dbt )*/; 93 105 b = bt; 94 106 Db = Dbt; Fb = Fbt; Gb = Gbt; … … 98 110 /// ---> A5 99 111 if ( degF <= degG && delta == degF && divides( F, G ) ) 112 { 113 DEBDECLEVEL( cerr, "ezgcd" ); 100 114 return d*F; 115 } 101 116 if ( degG < degF && delta == degG && divides( G, F ) ) 117 { 118 DEBDECLEVEL( cerr, "ezgcd" ); 102 119 return d*G; 120 } 103 121 if ( delta != degF && delta != degG ) { 104 122 /// ---> A6 … … 144 162 gcdfound = Hensel( B, DD, lcDD, b, bound, x ); 145 163 DEBOUTLN( cerr, "(hensel finished) DD = " << DD ); 164 165 if (gcdfound) 166 { 167 CanonicalForm cand=DD[2] / content(DD[2],Variable(1)); 168 if (B==F) 169 { 170 DEBOUTLN( cerr, "(test) G: "<<G<<" % gcd:"<<cand<<" -> " << G%cand ); 171 gcdfound= divides(cand,G); 172 //gcdfound= ((G-((G/cand)*cand))==0); 173 //gcdfound= ((G % cand)==0); 174 } 175 else 176 { 177 DEBOUTLN( cerr, "(test) F: "<<F<<" % gcd:"<<cand<<" -> " << F%cand); 178 gcdfound= divides(cand,F); 179 //gcdfound= ((F-((F/cand)*cand))==0); 180 //gcdfound= ((F % cand)==0); 181 } 182 } 146 183 /// ---> A8 (gcdfound) 147 184 } … … 234 271 findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG ) 235 272 { 273 // int t=tmax(F.level(),G.level()); 274 int i; 236 275 bool ok; 237 276 if ( delta != 0 ) 238 277 b.nextpoint(); 278 // i=2; 279 // while(i<=t) 280 // { 281 // if (b[i]==0) { b.nextpoint(); i=2; } 282 // else i++; 283 // } 284 DEBOUTLN( cerr, "ezgcd: (findeval) F = " << F <<", G="<< G); 285 DEBOUTLN( cerr, "ezgcd: (findeval) degF = " << degF << ", degG="<<degG ); 239 286 do { 240 287 DEBOUTLN( cerr, "ezgcd: (findeval) b = " << b ); … … 245 292 ok = degree( Gb ) == degG; 246 293 } 294 247 295 if ( ok ) { 248 Db = gcd( Fb, Gb ); 249 if ( delta > 0 ) 296 // if ((Fb.isZero())||(Gb.isZero())) 297 // ok=false; 298 // else 299 { 300 Db = gcd( Fb, Gb ); 301 if ( delta > 0 ) 250 302 ok = degree( Db ) < delta; 303 } 251 304 } 252 305 if ( ! ok )
Note: See TracChangeset
for help on using the changeset viewer.