- Timestamp:
- Feb 2, 1998, 9:58:49 AM (26 years ago)
- Branches:
- (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
- Children:
- b0c783ccfcf6a8ce8a60e2e650e31f1b523d11cc
- Parents:
- f3b98ad1c11ea4bf6d3b9525f75480b2abf56cac
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_gcd.cc
rf3b98ad r398b15 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.1 6 1998-01-27 10:18:33 pohlExp $ */2 /* $Id: cf_gcd.cc,v 1.17 1998-02-02 08:58:43 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 115 115 //}}} 116 116 117 //{{{ CanonicalForm igcd ( const CanonicalForm & f, const CanonicalForm & g )118 //{{{ docu119 //120 // igcd() - return integer gcd of f and g.121 //122 // Calculates the integer gcd of f and g using the euclidean123 // algorithm if f and g are integers and we are not calculating124 // in Q. Returns one in all other cases. Normalizes result.125 //126 //}}}127 CanonicalForm128 igcd ( const CanonicalForm & f, const CanonicalForm & g )129 {130 CanonicalForm a, b, c, dummy;131 132 if ( f.inZ() && g.inZ() && ! isOn( SW_RATIONAL ) ) {133 if ( f.sign() < 0 ) a = -f; else a = f;134 if ( g.sign() < 0 ) b = -g; else b = g;135 while ( ! b.isZero() ) {136 divrem( a, b, dummy, c );137 a = b;138 b = c;139 }140 return a;141 }142 else143 return 1;144 }145 //}}}146 147 117 //{{{ static CanonicalForm icontent ( const CanonicalForm & f, const CanonicalForm & c ) 148 118 //{{{ docu … … 179 149 { 180 150 return icontent( f, 0 ); 181 }182 //}}}183 184 //{{{ CanonicalForm iextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )185 //{{{ docu186 //187 // iextgcd() - calculate extended integer gcd.188 //189 // Returns gcd(f, g) and a and b sucht that f*a+g*b=gcd(f, g).190 // The gcd is calculated using an extended euclidean polynomial191 // remainder sequence. Normalizes result.192 //193 // Note: be sure you are calculating in Z, and not in Q!194 //195 //}}}196 CanonicalForm197 iextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )198 {199 CanonicalForm p0 = f, p1 = g;200 CanonicalForm f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;201 202 while ( ! p1.isZero() ) {203 divrem( p0, p1, q, r );204 p0 = p1; p1 = r;205 r = g0 - g1 * q;206 g0 = g1; g1 = r;207 r = f0 - f1 * q;208 f0 = f1; f1 = r;209 }210 a = f0;211 b = g0;212 if ( p0.sign() < 0 ) {213 p0 = -p0;214 a = -a;215 b = -b;216 }217 return p0;218 151 } 219 152 //}}} … … 277 210 f = F / cF; 278 211 g = G / cG; 279 c = igcd( cF, cG );212 c = bgcd( cF, cG ); 280 213 } 281 214 cg = gcd( f.lc(), g.lc() ); … … 550 483 else if ( f.inBaseDomain() ) 551 484 if ( g.inBaseDomain() ) 552 return igcd( f, g );485 return bgcd( f, g ); 553 486 else 554 487 return cf_content( g, f ); -
factory/fac_univar.cc
rf3b98ad r398b15 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_univar.cc,v 1.1 5 1997-12-08 18:24:35schmidt Exp $ */2 /* $Id: fac_univar.cc,v 1.16 1998-02-02 08:58:49 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 29 29 30 30 static modpk theModulus; 31 32 // !!! this should be placed in cf_gcd.h33 CanonicalForm34 iextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b );35 36 31 37 32 #ifdef DEBUGOUTPUT … … 537 532 DEBOUTHPRINT( cerr, "D = ", D ); 538 533 lf = lc( f ); 539 (void) iextgcd( pk.getpk(), lf, dummy1, recip_lf );534 (void)bextgcd( pk.getpk(), lf, dummy1, recip_lf ); 540 535 DEBOUTLN( cerr, "recip_lf = " << recip_lf ); 541 536 TIMING_START(fac_combineFactors);
Note: See TracChangeset
for help on using the changeset viewer.