Changeset c30347 in git
- Timestamp:
- Dec 19, 2007, 3:27:14 PM (16 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 5a01219e1920f1b747aebaf636aa8c5b8f61b714
- Parents:
- 1758fb8f662065e47c332dbd6c4688e8a2dd973c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
r1758fb rc30347 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.5 7 2007-12-07 11:26:57Singular Exp $ */2 /* $Id: cf_gcd.cc,v 1.58 2007-12-19 14:27:14 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 89 89 icontent ( const CanonicalForm & f, const CanonicalForm & c ) 90 90 { 91 if ( f.inCoeffDomain() ) 92 return gcd( f, c ); 93 else { 91 if ( f.inBaseDomain() ) 92 { 93 if (c.isZero()) return abs(f); 94 return bgcd( f, c ); 95 } 96 else if ( f.inCoeffDomain() ) 97 return gcd(f,c); 98 else 99 { 94 100 CanonicalForm g = c; 95 101 for ( CFIterator i = f; i.hasTerms() && ! g.isOne(); i++ ) … … 469 475 int mp, cc, p1, pe; 470 476 mp = f.level()+1; 477 #if 0 478 if (( getCharacteristic() == 0 ) 479 && (f.level() >4) 480 && (g.level() >4) 481 && isOn( SW_USE_CHINREM_GCD) 482 && (!f.isUnivariate()) 483 && (!g.isUnivariate()) 484 && (isPurePoly_m(f)) 485 && (isPurePoly_m(g)) 486 ) 487 { 488 return chinrem_gcd( f, g ); 489 } 490 #endif 471 491 cf_prepgcd( f, g, cc, p1, pe); 472 492 if ( cc != 0 ) … … 490 510 return d1; 491 511 bool fc_isUnivariate=fc.isUnivariate(); 512 bool fc_and_gc_Univariate=fc_isUnivariate && gc.isUnivariate(); 492 513 if ( getCharacteristic() != 0 ) 493 514 { 494 if (isOn( SW_USE_EZGCD_P ) && (!fc_ isUnivariate))515 if (isOn( SW_USE_EZGCD_P ) && (!fc_and_gc_Univariate)) 495 516 { 496 517 if ( pe == 1 ) … … 509 530 fc = swapvar( fin_ezgcd( fc, gc ), Variable(1), Variable(pe) ); 510 531 } 511 } 532 } 512 533 else if (isOn(SW_USE_GCD_P)) 513 534 { … … 523 544 } 524 545 } 525 else if (!fc_isUnivariate) 526 { 546 else if (!fc_and_gc_Univariate) 547 { 548 if ( 549 isOn(SW_USE_CHINREM_GCD) 550 && (gc.level() >5) 551 && (fc.level() >5) 552 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 553 ) 554 { 555 #if 0 556 if ( p1 == fc.level() ) 557 fc = chinrem_gcd( fc, gc ); 558 else 559 { 560 fc = replacevar( fc, Variable(p1), Variable(mp) ); 561 gc = replacevar( gc, Variable(p1), Variable(mp) ); 562 fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) ); 563 } 564 #else 565 fc = chinrem_gcd( fc, gc); 566 #endif 567 } 527 568 if ( isOn( SW_USE_EZGCD ) ) 528 569 { … … 545 586 else if ( 546 587 isOn(SW_USE_CHINREM_GCD) 547 && (!gc.isUnivariate())548 588 && (isPurePoly_m(fc)) && (isPurePoly_m(gc)) 549 589 ) … … 561 601 fc = chinrem_gcd( fc, gc); 562 602 #endif 603 } 604 else 605 { 606 fc = gcd_poly_0( fc, gc ); 563 607 } 564 608 } … … 1040 1084 i--; 1041 1085 } 1086 //printf("try p=%d\n",p); 1042 1087 setCharacteristic( p ); 1043 Dp = gcd ( mapinto( f ), mapinto( g ) );1088 Dp = gcd_poly( mapinto( f ), mapinto( g ) ); 1044 1089 Dp /=Dp.lc(); 1045 1090 setCharacteristic( 0 ); 1046 1091 dp_deg=totaldegree(Dp); 1047 1092 if ( dp_deg == 0 ) 1093 { 1094 //printf(" -> 1\n"); 1048 1095 return CanonicalForm(1); 1096 } 1049 1097 if ( q.isZero() ) 1050 1098 { … … 1063 1111 else if ( dp_deg < d_deg ) 1064 1112 { 1113 //printf(" were all bad, try more\n"); 1065 1114 // all previous p's are bad primes 1066 1115 q = p; 1067 1116 D = mapinto( Dp ); 1068 1117 d_deg=dp_deg; 1118 } 1119 else 1120 { 1121 //printf(" was bad, try more\n"); 1069 1122 } 1070 1123 //else dp_deg > d_deg: bad prime … … 1081 1134 if ( fdivides( Dn, f ) && fdivides( Dn, g ) ) 1082 1135 { 1136 //printf(" -> success\n"); 1083 1137 return Dn; 1084 1138 } … … 1087 1141 else 1088 1142 { // try other method 1143 //printf("try other gcd\n"); 1089 1144 Off(SW_USE_CHINREM_GCD); 1090 1145 D=gcd_poly( f, g );
Note: See TracChangeset
for help on using the changeset viewer.