Changeset c992ec1 in git for factory/cf_gcd.cc
- Timestamp:
- Oct 9, 2007, 2:41:24 PM (16 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 4da73c16285930c8b101412fa10d07ba70bfac19
- Parents:
- 0d3e2453c08b0a31b6349f7428d44e2d675e9757
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
r0d3e24 rc992ec1 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.5 2 2007-09-26 15:07:16Singular Exp $ */2 /* $Id: cf_gcd.cc,v 1.53 2007-10-09 12:41:24 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 501 501 } 502 502 } 503 else if ( 504 isOn(SW_USE_CHINREM_GCD) 505 && (!fc.isUnivariate()) && (!gc.isUnivariate()) 506 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 507 ) 508 { 509 if ( p1 == fc.level() ) 510 fc = chinrem_gcd( fc, gc ); 511 else 512 { 513 fc = replacevar( fc, Variable(p1), Variable(mp) ); 514 gc = replacevar( gc, Variable(p1), Variable(mp) ); 515 fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) ); 516 } 517 //fc = chinrem_gcd( fc, gc); 518 } 519 else if ( isOn( SW_USE_EZGCD ) && !fc.isUnivariate() ) 520 { 521 if ( pe == 1 ) 503 else if (!fc.isUnivariate()) 504 { 505 if ( isOn( SW_USE_EZGCD ) ) 506 { 507 if ( pe == 1 ) 522 508 fc = ezgcd( fc, gc ); 523 else if ( pe > 0 )// no variable at position 1524 {509 else if ( pe > 0 )// no variable at position 1 510 { 525 511 fc = replacevar( fc, Variable(pe), Variable(1) ); 526 512 gc = replacevar( gc, Variable(pe), Variable(1) ); 527 513 fc = replacevar( ezgcd( fc, gc ), Variable(1), Variable(pe) ); 528 }529 else530 {514 } 515 else 516 { 531 517 pe = -pe; 532 518 fc = swapvar( fc, Variable(pe), Variable(1) ); 533 519 gc = swapvar( gc, Variable(pe), Variable(1) ); 534 520 fc = swapvar( ezgcd( fc, gc ), Variable(1), Variable(pe) ); 521 } 535 522 } 536 } 537 else 538 { 539 fc = gcd_poly_0( fc, gc ); 523 else if ( 524 isOn(SW_USE_CHINREM_GCD) 525 && (!gc.isUnivariate()) 526 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 527 ) 528 { 529 #if 0 530 if ( p1 == fc.level() ) 531 fc = chinrem_gcd( fc, gc ); 532 else 533 { 534 fc = replacevar( fc, Variable(p1), Variable(mp) ); 535 gc = replacevar( gc, Variable(p1), Variable(mp) ); 536 fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) ); 537 } 538 #else 539 fc = chinrem_gcd( fc, gc); 540 #endif 541 } 542 } 543 else 544 { 545 fc = gcd_poly_0( fc, gc ); 540 546 } 541 547 if ( d1.degree() > 0 ) 542 548 fc *= d1; 543 549 return fc; 544 550 } … … 982 988 } 983 989 984 #define GCD_CHINES_MIN_TRIES 3985 990 CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG ) 986 991 { 987 992 CanonicalForm f, g, cg, cl, q, Dp, newD, D, newq; 988 int p, i, n,dp_deg, d_deg;;993 int p, i, dp_deg, d_deg;; 989 994 990 995 CanonicalForm cd = bCommonDen( FF ); … … 1004 1009 cl = f.lc()* g.lc(); 1005 1010 1006 n=GCD_CHINES_MIN_TRIES;1007 1011 while ( true ) 1008 1012 { … … 1015 1019 } 1016 1020 setCharacteristic( p ); 1017 n--;1018 1021 Dp = gcd( mapinto( f ), mapinto( g ) ); 1019 1022 Dp /=Dp.lc(); … … 1038 1041 else if ( dp_deg < d_deg ) 1039 1042 { 1040 n=GCD_CHINES_MIN_TRIES;1041 1043 // all previous p's are bad primes 1042 1044 q = p; … … 1048 1050 if ( i >= 0 ) 1049 1051 { 1050 if (n<=0) 1052 CanonicalForm Dn= Farey(D,q); 1053 int is_rat=isOn(SW_RATIONAL); 1054 On(SW_RATIONAL); 1055 CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL) 1056 if (!is_rat) Off(SW_RATIONAL); 1057 Dn *=cd; 1058 //Dn /=vcontent(Dn,Variable(1)); 1059 if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1051 1060 { 1052 CanonicalForm Dn= Farey(D,q); 1053 int is_rat=isOn(SW_RATIONAL); 1054 On(SW_RATIONAL); 1055 CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL) 1056 if (!is_rat) Off(SW_RATIONAL); 1057 Dn *=cd; 1058 //Dn /=vcontent(Dn,Variable(1)); 1059 if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1060 { 1061 return Dn; 1062 } 1061 return Dn; 1062 } 1063 1063 //else: try more primes 1064 } 1065 } 1066 else 1067 { 1064 } 1065 else 1066 { // try other method 1068 1067 Off(SW_USE_CHINREM_GCD); 1069 1068 D=gcd_poly( f, g );
Note: See TracChangeset
for help on using the changeset viewer.