Changeset 034eec in git
- Timestamp:
- Jan 20, 2004, 4:39:52 PM (19 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 0ae61c6dbdc8ee3e150c56f17b9989cada5fd83c
- Parents:
- 02da1e214204d265d3630b6f20cffc2ee0c7b979
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
r02da1e r034eec 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.2 2 2004-01-19 11:27:46Singular Exp $ */2 /* $Id: cf_factor.cc,v 1.23 2004-01-20 15:39:52 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 160 160 #endif 161 161 162 staticbool isPurePoly(const CanonicalForm & f)162 bool isPurePoly(const CanonicalForm & f) 163 163 { 164 164 if (f.level()<=0) return false; -
factory/cf_gcd.cc
r02da1e r034eec 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_gcd.cc,v 1.2 2 2004-01-19 11:26:20Singular Exp $ */2 /* $Id: cf_gcd.cc,v 1.23 2004-01-20 15:39:52 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 19 19 20 20 #ifdef HAVE_NTL 21 #include <NTL/ZZX.h> 21 22 #include "NTLconvert.h" 23 bool isPurePoly(const CanonicalForm & f); 22 24 #endif 23 25 … … 144 146 extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b ) 145 147 { 146 CanonicalForm contf = content( f ); 147 CanonicalForm contg = content( g ); 148 149 CanonicalForm p0 = f / contf, p1 = g / contg; 150 CanonicalForm f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r; 151 152 while ( ! p1.isZero() ) { 153 divrem( p0, p1, q, r ); 154 p0 = p1; p1 = r; 155 r = g0 - g1 * q; 156 g0 = g1; g1 = r; 157 r = f0 - f1 * q; 158 f0 = f1; f1 = r; 159 } 160 CanonicalForm contp0 = content( p0 ); 161 a = f0 / ( contf * contp0 ); 162 b = g0 / ( contg * contp0 ); 163 p0 /= contp0; 164 if ( p0.sign() < 0 ) { 165 p0 = -p0; 166 a = -a; 167 b = -b; 168 } 169 return p0; 148 #ifdef HAVE_NTL 149 if (isOn(SW_USE_NTL_GCD) && ( getCharacteristic() > 0 ) 150 && isPurePoly(f) && isPurePoly(g)) 151 { 152 zz_pContext ccc(getCharacteristic()); 153 ccc.restore(); 154 zz_p::init(getCharacteristic()); 155 zz_pX F1=convertFacCF2NTLzzpX(f); 156 zz_pX G1=convertFacCF2NTLzzpX(g); 157 zz_pX R; 158 zz_pX A,B; 159 XGCD(R,A,B,F1,G1); 160 a=convertNTLzzpX2CF(A,f.mvar()); 161 b=convertNTLzzpX2CF(B,f.mvar()); 162 return convertNTLzzpX2CF(R,f.mvar()); 163 } 164 #endif 165 CanonicalForm contf = content( f ); 166 CanonicalForm contg = content( g ); 167 168 CanonicalForm p0 = f / contf, p1 = g / contg; 169 CanonicalForm f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r; 170 171 while ( ! p1.isZero() ) { 172 divrem( p0, p1, q, r ); 173 p0 = p1; p1 = r; 174 r = g0 - g1 * q; 175 g0 = g1; g1 = r; 176 r = f0 - f1 * q; 177 f0 = f1; f1 = r; 178 } 179 CanonicalForm contp0 = content( p0 ); 180 a = f0 / ( contf * contp0 ); 181 b = g0 / ( contg * contp0 ); 182 p0 /= contp0; 183 if ( p0.sign() < 0 ) { 184 p0 = -p0; 185 a = -a; 186 b = -b; 187 } 188 return p0; 170 189 } 171 190 //}}} … … 175 194 { 176 195 #ifdef HAVE_NTL 177 if (isOn(SW_USE_NTL_GCD) )196 if (isOn(SW_USE_NTL_GCD) && isPurePoly(F) && isPurePoly(G)) 178 197 { 179 198 if ( getCharacteristic() > 0 ) … … 295 314 C = gcd( Ci, Ci1 ); 296 315 pi1 = pi1 / Ci1; pi = pi / Ci; 297 if ( pi.isUnivariate() && pi1.isUnivariate() ) { 298 if ( modularflag ) 299 return gcd_poly_univar0( pi, pi1, true ) * C; 300 } 301 else 302 if ( gcd_test_one( pi1, pi, true ) ) 303 return C; 316 if ( pi.isUnivariate() && pi1.isUnivariate() ) 317 { 318 if ( modularflag 319 #ifdef HAVE_NTL 320 || (isOn(SW_USE_NTL_GCD) && isPurePoly(pi) && isPurePoly(pi1)) 321 #endif 322 ) 323 return gcd_poly_univar0( pi, pi1, true ) * C; 324 } 325 else if ( gcd_test_one( pi1, pi, true ) ) 326 return C; 304 327 delta = degree( pi, v ) - degree( pi1, v ); 305 328 Hi = power( LC( pi1, v ), delta );
Note: See TracChangeset
for help on using the changeset viewer.