Changeset 9f84ad in git
- Timestamp:
- Apr 24, 2012, 4:38:56 PM (11 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 47046743f1273df49ef99fda72ed22a1531d10bd
- Parents:
- c244d04150a9fd45331938d2c9fb6f89985acb05
- git-author:
- Martin Lee <martinlee84@web.de>2012-04-24 16:38:56+02:00
- git-committer:
- Martin Lee <martinlee84@web.de>2012-05-07 14:16:12+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/fac_ezgcd.cc
rc244d04 r9f84ad 342 342 } 343 343 344 static 345 bool findeval (const CanonicalForm & F, const CanonicalForm & G, 346 CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, 347 REvaluation & b, int delta, int degF, int degG, int maxeval, 348 int & count, int& k, int bound, int& l) 349 { 350 if( count == 0 && delta != 0) 351 { 352 if( count++ > maxeval ) 353 return false; 354 } 355 if (count > 0) 356 { 357 b.nextpoint(k); 358 if (k == 0) 359 k++; 360 l++; 361 if (l > bound) 362 { 363 l= 1; 364 k++; 365 if (k > tmax (F.level(), G.level()) - 1) 366 return false; 367 b.nextpoint (k); 368 } 369 if (count++ > maxeval) 370 return false; 371 } 372 while( true ) 373 { 374 Fb = b( F ); 375 if( degree( Fb, 1 ) == degF ) 376 { 377 Gb = b( G ); 378 if( degree( Gb, 1 ) == degG ) 379 { 380 Db = gcd( Fb, Gb ); 381 if( delta > 0 ) 382 { 383 if( degree( Db, 1 ) <= delta ) 384 return true; 385 } 386 else 387 { 388 k++; 389 return true; 390 } 391 } 392 } 393 if (k == 0) 394 k++; 395 b.nextpoint(k); 396 l++; 397 if (l > bound) 398 { 399 l= 1; 400 k++; 401 if (k > tmax (F.level(), G.level()) - 1) 402 return false; 403 b.nextpoint (k); 404 } 405 if( count++ > maxeval ) 406 return false; 407 } 408 } 409 344 410 static CanonicalForm 345 411 ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG, REvaluation & b, … … 347 413 { 348 414 bool isRat= isOn (SW_RATIONAL); 349 if (!isRat)350 On (SW_RATIONAL);351 415 CanonicalForm F, G, f, g, d, Fb, Gb, Db, Fbt, Gbt, Dbt, B0, B, D0, lcF, lcG, 352 416 lcD, cand, result; 353 417 CFArray DD( 1, 2 ), lcDD( 1, 2 ); 354 int degF, degG, delta, t ;418 int degF, degG, delta, t, count, maxeval; 355 419 REvaluation bt; 356 420 bool gcdfound = false; 357 421 Variable x = Variable(1); 358 modpk bound; 359 360 F= FF; 361 G= GG; 422 count= 0; 423 maxeval= 200; 424 int o, l; 425 o= 0; 426 l= 1; 427 428 if (!isRat) 429 On (SW_RATIONAL); 430 F= FF*bCommonDen (FF); 431 G= GG*bCommonDen (GG); 432 if (!isRat) 433 Off (SW_RATIONAL); 362 434 363 435 CFMap M,N; … … 367 439 if (best_level == 0) 368 440 { 369 if (!isRat) 370 Off (SW_RATIONAL); 441 DEBDECLEVEL( cerr, "ezgcd" ); 371 442 return G.genOne(); 372 443 } … … 374 445 F= M (F); 375 446 G= M (G); 376 377 447 378 448 DEBINCLEVEL( cerr, "ezgcd" ); … … 380 450 DEBOUTLN( cerr, "GG = " << GG ); 381 451 f = content( F, x ); g = content( G, x ); d = gcd( f, g ); 452 d /= icontent (d); 382 453 DEBOUTLN( cerr, "f = " << f ); 383 454 DEBOUTLN( cerr, "g = " << g ); … … 386 457 { 387 458 DEBDECLEVEL( cerr, "ezgcd" ); 388 if (!isRat)389 Off (SW_RATIONAL);390 459 if(F.mvar()==G.mvar()) 391 460 d*=gcd(F,G); 392 461 return N (d); 393 462 } 394 else if ( gcd_test_one( F, G, false ) ) 463 464 int maxNumVars= tmax (getNumVars (F), getNumVars (G)); 465 int sizeF= size (F); 466 int sizeG= size (G); 467 468 469 if (!isRat) 470 On (SW_RATIONAL); 471 if (sizeF/maxNumVars > 500 && sizeG/maxNumVars > 500) 472 { 473 Off(SW_USE_EZGCD); 474 result=gcd( F, G ); 475 On(SW_USE_EZGCD); 476 if (!isRat) 477 Off (SW_RATIONAL); 478 result /= icontent (result); 479 DEBDECLEVEL( cerr, "ezgcd" ); 480 return N (d*result); 481 } 482 483 if ( gcd_test_one( F, G, false ) ) 395 484 { 396 485 DEBDECLEVEL( cerr, "ezgcd" ); … … 404 493 degF = degree( F, x ); degG = degree( G, x ); 405 494 t = tmax( F.level(), G.level() ); 406 //bound = findBound( F, G, lcF, lcG, degF, degG );407 495 if ( ! internal ) 408 496 b = REvaluation( 2, t, IntRandom( 25 ) ); … … 413 501 DEBOUTLN( cerr, "F = " << F ); 414 502 DEBOUTLN( cerr, "G = " << G ); 415 findeval( F, G, Fb, Gb, Db, b, delta, degF, degG ); 503 if (!findeval( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, 504 o, 25, l)) 505 { 506 Off(SW_USE_EZGCD); 507 result=gcd( F, G ); 508 On(SW_USE_EZGCD); 509 if (!isRat) 510 Off (SW_RATIONAL); 511 DEBDECLEVEL( cerr, "ezgcd" ); 512 result /= icontent (result); 513 return N (d*result); 514 } 416 515 DEBOUTLN( cerr, "found evaluation b = " << b ); 417 516 DEBOUTLN( cerr, "F(b) = " << Fb ); … … 432 531 { 433 532 bt = b; 434 findeval( F, G, Fbt, Gbt, Dbt, bt, delta + 1, degF, degG ); 533 if (!findeval( F, G, Fbt, Gbt, Dbt, bt, delta, degF, degG, maxeval, count, 534 o, 25,l )) 535 { 536 Off(SW_USE_EZGCD); 537 result=gcd( F, G ); 538 On(SW_USE_EZGCD); 539 if (!isRat) 540 Off (SW_RATIONAL); 541 DEBDECLEVEL( cerr, "ezgcd" ); 542 result /= icontent (result); 543 return N (d*result); 544 } 435 545 int dd=degree( Dbt ); 436 546 if ( dd /*degree( Dbt )*/ == 0 ) … … 515 625 if (!isRat) 516 626 Off (SW_RATIONAL); 627 DEBDECLEVEL( cerr, "ezgcd" ); 628 result /= icontent (result); 517 629 return N (d*result); 518 630 } … … 535 647 if (!isRat) 536 648 Off (SW_RATIONAL); 649 DEBDECLEVEL( cerr, "ezgcd" ); 650 result /= icontent (result); 537 651 return N (d*result); 538 652 } … … 549 663 /// ---> A9 550 664 DEBDECLEVEL( cerr, "ezgcd" ); 665 cand *= bCommonDen (cand); 551 666 if (!isRat) 552 667 Off (SW_RATIONAL); 668 cand /= icontent (cand); 553 669 return N (d*cand); 554 670 }
Note: See TracChangeset
for help on using the changeset viewer.