Changeset e89e56 in git for libfac/factor
- Timestamp:
- Mar 17, 2008, 6:44:17 PM (16 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 85194f264939ff85dd7731d524a483b21f35f5ac
- Parents:
- ca847b0e390392983ef3461c16980b5defee8e0c
- Location:
- libfac/factor
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/factor/Factor.cc
rca847b re89e56 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.4 1 2008-02-22 12:16:03Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.42 2008-03-17 17:44:16 Singular Exp $ "; 4 4 static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de \nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you."; 5 5 /////////////////////////////////////////////////////////////////////////////// … … 190 190 191 191 retvalue= mydivremt(num,denum,a,b); 192 if ( retvalue && b .isZero() ) // num/denum from FFdomain192 if ( retvalue && b == num.genZero() ) // num/denum from FFdomain 193 193 return a; 194 194 else // num/denum is rational … … 257 257 numerator= numerator(x*lt,levelF); // x <- x*lt 258 258 denumerator= power(lt,degree(F,levelF)-1); // == lt^(1-degree(F,x) 259 while ( is_rational(numerator, denumerator).isZero())259 while (numerator.genZero() == is_rational(numerator, denumerator)) 260 260 numerator*= lt; 261 261 intermediate= is_rational(numerator,denumerator); … … 270 270 intermediate*= j.getItem().factor(); 271 271 test1= mydivremt( intermediate,F,a,b); 272 if ( test1 && b .isZero() ) // Yupp!272 if ( test1 && b == intermediate.genZero() ) // Yupp! 273 273 { 274 274 IntermediateList.append(CFFactor(1/a,1)); … … 288 288 test= content(numerator,x); 289 289 test1= mydivremt(denumerator,test,a,b); 290 if ( test1 && b .isZero() ) // Yupp!290 if ( test1 && b == numerator.genZero() ) // Yupp! 291 291 { 292 292 save_denumerator*= a; … … 308 308 // save_denumerator should be a multiple of the leading coeff 309 309 test1= mydivremt(save_denumerator,lt,a,b); 310 if ( test1 && b .isZero() ) // Yupp!310 if ( test1 && b == save_denumerator.genZero() ) // Yupp! 311 311 // We have to multiply one of the factors with 312 312 // the multiplicity of the save_denumerator <-> lc 313 313 // the following will do what we want 314 Returnlist= UnionCFFL( CFFList(CFFactor(1/a,1)),Returnlist) ;314 Returnlist= myUnion( CFFList(CFFactor(1/a,1)),Returnlist) ; 315 315 else 316 316 { … … 363 363 if ( degree(g) == deg ) // degrees match 364 364 if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less 365 if ( isSqrFree(g) ) // poly is sqrfree365 if ( SqrFreeTest(g,1) ) // poly is sqrfree 366 366 if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0 367 367 return 1; … … 440 440 return find_irreducible( degree_of_Extension, gen, Variable(1) ); 441 441 } 442 443 442 444 443 /////////////////////////////////////////////////////////////// … … 720 719 Outputlist_b = Factorized(ffuni,alpha); 721 720 DEBOUTLN(CERR, "Outputlist_b = ", Outputlist_b); 722 Outputlist = UnionCFFL(Outputlist_a, Outputlist_b);721 Outputlist = myUnion(Outputlist_a, Outputlist_b); 723 722 // have to back-swapvar the factors.... 724 723 for ( CFFListIterator i=Outputlist; i.hasItem(); i++ ){ … … 925 924 // (If gcd is fast...) 926 925 /////// 927 // if ( ! isSqrFree(F) ){926 // if ( ! SqrFreeTest(F) ){ 928 927 if ( ! is_SqrFree ) 929 928 { 930 929 TIMING_START(sqrfree_time); 931 SqrFreeList = sqrFree(F,0,false) ; // first sqrfree the polynomial 932 // Ex.: char=p f= x^p*(y+1); 933 // InternalSqrFree(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) . 930 SqrFreeList = SqrFreeMV(F) ; // first sqrfree the polynomial 931 // don't use sqrFree(F), factory's internal sqrFree for multiv. 932 // Polynomials; it's wrong!! Ex.: char=p f= x^p*(y+1); 933 // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) . 934 934 TIMING_END(sqrfree_time); 935 935 … … 941 941 else 942 942 SqrFreeList.append(CFFactor(F,1)); 943 DEBOUTLN(CERR, "SqrFree List= ", SqrFreeList);943 DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList); 944 944 for ( i=SqrFreeList; i.hasItem(); i++ ) 945 945 { … … 977 977 for ( j=Intermediatelist; j.hasItem(); j++ ) 978 978 //Normally j.getItem().exp() should be 1 979 Outputlist= appendCFFL( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));979 Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp())); 980 980 } 981 981 } … … 1066 1066 libfac_interruptflag=0; 1067 1067 CFFList iF=Factorize(F,minpoly); 1068 if ((libfac_interruptflag==0) ||(iF.isEmpty()))1068 if ((libfac_interruptflag==0)&&(!iF.isEmpty())) 1069 1069 H=iF; 1070 1070 else … … 1174 1174 { 1175 1175 CFList as(minpoly); 1176 CFFList sqF=sqrFree(F ,0,false); // sqrFreeZ1176 CFFList sqF=sqrFree(F); // sqrFreeZ 1177 1177 CFFList G,H; 1178 1178 CanonicalForm fac; … … 1224 1224 // (If gcd is fast...) 1225 1225 /////// 1226 // if ( ! isSqrFree(F) ){1226 // if ( ! SqrFreeTest(F) ){ 1227 1227 if ( ! is_SqrFree ) 1228 1228 { 1229 1229 TIMING_START(sqrfree_time); 1230 SqrFreeList = sqrFree(F, minpoly) ; // first sqrfree the polynomial 1231 // Ex.: char=p f= x^p*(y+1); 1232 // InternalSqrFree(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) . 1230 SqrFreeList = SqrFreeMV(F, minpoly) ; // first sqrfree the polynomial 1231 // don't use sqrFree(F), factory's internal sqrFree for multiv. 1232 // Polynomials; it's wrong!! Ex.: char=p f= x^p*(y+1); 1233 // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) . 1233 1234 TIMING_END(sqrfree_time); 1234 1235 … … 1240 1241 else 1241 1242 SqrFreeList.append(CFFactor(F,1)); 1242 DEBOUTLN(CERR, "SqrFree List= ", SqrFreeList);1243 DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList); 1243 1244 for ( i=SqrFreeList; i.hasItem(); i++ ) 1244 1245 { … … 1280 1281 for ( j=Intermediatelist; j.hasItem(); j++ ) 1281 1282 //Normally j.getItem().exp() should be 1 1282 Outputlist= appendCFFL( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));1283 Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp())); 1283 1284 } 1284 1285 } … … 1330 1331 /* 1331 1332 $Log: not supported by cvs2svn $ 1332 Revision 1.40 2008/01/25 14:19:40 Singular1333 *hannes: SqrFreeTest -> isSqrFree1334 1335 Revision 1.39 2008/01/22 09:51:37 Singular1336 *hannes: sqrFree/InternalSqrFree -> factory1337 1338 1333 Revision 1.38 2008/01/07 13:34:56 Singular 1339 1334 *hannes: omse optiomzations(isOne) -
libfac/factor/MVMultiHensel.cc
rca847b re89e56 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1.1 6 2008-02-22 12:16:03Singular Exp $";4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1.17 2008-03-17 17:44:16 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 334 334 { 335 335 CanonicalForm V,Fk=F,Gk=G,Rk,W,D,S; 336 int levelU=level(U), degU= totaldegree(U,1,levelU); // degree(U,{x_1,..,x_(level(U)-1)})336 int levelU=level(U), degU=subvardegree(U,levelU); // degree(U,{x_1,..,x_(level(U)-1)}) 337 337 DiophantForm Retvalue; 338 338 RememberArray A(degree(F,levelU)+degree(G,levelU)+1); … … 502 502 CanonicalForm a,b; 503 503 // we add a division test now for intermediat.One and intermediat.Two 504 if ( mydivremt (mF,intermediat.One,a,b) && b .isZero() )504 if ( mydivremt (mF,intermediat.One,a,b) && b == mF.genZero() ) 505 505 Retlistinter.append(CFFactor(intermediat.One,1) ); 506 if ( mydivremt (mF,intermediat.Two,a,b) && b .isZero() )506 if ( mydivremt (mF,intermediat.Two,a,b) && b == mF.genZero() ) 507 507 Retlistinter.append(CFFactor(intermediat.Two,1) ); 508 508 … … 520 520 /* 521 521 $Log: not supported by cvs2svn $ 522 Revision 1.15 2008/01/22 09:51:37 Singular523 *hannes: sqrFree/InternalSqrFree -> factory524 525 522 Revision 1.14 2007/06/14 14:16:35 Singular 526 523 *hannes: Factorize2 etc. -
libfac/factor/SqrFree.cc
rca847b re89e56 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1.1 4 2008-01-25 14:19:40Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.15 2008-03-17 17:44:16 Singular Exp $"; 5 5 static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de .\n Please include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you."; 6 6 /////////////////////////////////////////////////////////////////////////////// … … 48 48 49 49 static inline CFFactor 50 Powerup( const CFFactor & F , int exp=1){ 50 Powerup( const CFFactor & F , int exp=1) 51 { 51 52 return CFFactor(F.factor(), exp*F.exp()) ; 52 53 } 53 54 54 55 static CFFList 55 Powerup( const CFFList & Inputlist , int exp=1 ){ 56 Powerup( const CFFList & Inputlist , int exp=1 ) 57 { 56 58 CFFList Outputlist; 57 59 … … 67 69 /////////////////////////////////////////////////////////////// 68 70 static CanonicalForm 69 PthRoot( const CanonicalForm & f ){ 71 PthRoot( const CanonicalForm & f ) 72 { 70 73 CanonicalForm RES, R = f; 71 74 int n= max(level(R),getNumVars(R)), p= getCharacteristic(); 72 75 73 if (n==0){ // constant 76 if (n==0) 77 { // constant 74 78 if (R.inExtension()) // not in prime field; f over |F(q=p^k) 75 79 { 76 80 R = power(R,Powerup(p,getGFDegree() - 1)) ; 77 } 81 } 78 82 // if f in prime field, do nothing 79 83 return R; … … 93 97 /////////////////////////////////////////////////////////////// 94 98 static CanonicalForm 95 PthRoot( const CanonicalForm & f ,const CanonicalForm & mipo){ 99 PthRoot( const CanonicalForm & f ,const CanonicalForm & mipo) 100 { 96 101 CanonicalForm RES, R = f; 97 102 int n= max(level(R),getNumVars(R)), p= getCharacteristic(); 98 103 int mipodeg=-1; 99 104 if (f.level()==mipo.level()) mipodeg=mipo.degree(); 100 else if ((f.level()==1) &&( mipo.level()!=-1000000))105 else if ((f.level()==1) &&(!mipo.isZero())) 101 106 { 102 107 Variable t; … … 111 116 { 112 117 R = power(R,Powerup(p,getGFDegree() - 1)) ; 113 } 118 } 114 119 else if ((f.level()==mipo.level()) 115 ||((f.level()==1) &&( mipo.level()!=-1000000)))120 ||((f.level()==1) &&(!mipo.isZero()))) 116 121 { 117 122 R = power(R,Powerup(p,mipodeg - 1)) ; … … 130 135 131 136 /////////////////////////////////////////////////////////////// 137 // A uni/multivariate SqrFreeTest routine. // 138 // Cheaper to run if all you want is a test. // 139 // Works for charcteristic 0 and q=p^m // 140 // Returns 1 if poly r is SqrFree, 0 if SqrFree will do some // 141 // kind of factorization. // 142 // Would be much more effcient iff we had *good* // 143 // uni/multivariate gcd's and/or gcdtest's // 144 /////////////////////////////////////////////////////////////// 145 int 146 SqrFreeTest( const CanonicalForm & r, int opt) 147 { 148 CanonicalForm f=r, g; 149 int n=level(f); 150 151 if (getNumVars(f)==0) return 1 ; // a constant is SqrFree 152 if ( f.isUnivariate() ) { 153 g= f.deriv(); 154 if ( getCharacteristic() > 0 && g.isZero() ) return 0 ; 155 // Next: it would be best to have a *univariate* gcd-test which returns 156 // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials ) 157 g = gcd(f,g); 158 if ( g.isOne() || (-g).isOne() ) return 1; 159 else 160 if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!! 161 else return 0 ; 162 } 163 else 164 { // multivariate case 165 for ( int k=1; k<=n; k++ ) 166 { 167 g = swapvar(f,k,n); g = content(g); 168 // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : opt helps 169 if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) ) { 170 if ( opt==0 ) return 0; 171 else { 172 if ( SqrFreeTest(g,1) == 0 ) return 0; 173 g = swapvar(g,k,n); 174 f /=g ; 175 } 176 } 177 } 178 // Now f is primitive 179 n = level(f); // maybe less indeterminants 180 // if ( totaldegree(f) <= 1 ) return 1; 181 182 // Let`s look if it is a Pth root 183 if ( getCharacteristic() > 0 ) 184 for (int k=1; k<=n; k++ ) 185 { 186 g=swapvar(f,k,n); g=g.deriv(); 187 if ( ! g.isZero() ) break ; 188 else if ( k==n) return 0 ; // really is Pth root 189 } 190 g = f.deriv() ; 191 // Next: it would be best to have a *multivariate* gcd-test which returns 192 // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials ) 193 g= gcd(f,g); 194 if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ; 195 else return 0 ; 196 } 197 #ifdef HAVE_SINGULAR_ERROR 198 WerrorS("libfac: ERROR: SqrFreeTest: we should never fall trough here!"); 199 #else 200 #ifndef NOSTREAMIO 201 CERR << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n" 202 << rcsid << errmsg << "\n"; 203 #endif 204 #endif 205 return 0; 206 } 207 208 /////////////////////////////////////////////////////////////// 132 209 // A uni/multivariate SqrFree routine.Works for polynomials // 133 210 // which don\'t have a constant as the content. // … … 136 213 // needs not to be 1 !!!!! // 137 214 /////////////////////////////////////////////////////////////// 138 215 static CFFList 216 SqrFreed( const CanonicalForm & r , const CanonicalForm &mipo=0) 217 { 218 CanonicalForm h, g, f = r; 219 CFFList Outputlist; 220 int n = level(f); 221 222 DEBINCLEVEL(CERR, "SqrFreed"); 223 DEBOUTLN(CERR, "Called with r= ", r); 224 if (getNumVars(f)==0 ) 225 { // just a constant; return it 226 Outputlist= myappend(Outputlist,CFFactor(f,1)); 227 return Outputlist ; 228 } 229 230 // We look if we do have a content; if so, SqrFreed the content 231 // and continue computations with pp(f) 232 for (int k=1; k<=n; k++) 233 { 234 if ((mipo.isZero())/*||(k!=1)*/) 235 { 236 g = swapvar(f,k,n); g = content(g); 237 if ( ! (g.isOne() || (-g).isOne() || degree(g)==0 )) 238 { 239 g = swapvar(g,k,n); 240 DEBOUTLN(CERR, "We have a content: ", g); 241 Outputlist = myUnion(SqrFreeMV(g,mipo),Outputlist); // should we add a 242 // SqrFreeTest(g) first ? 243 DEBOUTLN(CERR, "Outputlist is now: ", Outputlist); 244 f /=g; 245 DEBOUTLN(CERR, "f is now: ", f); 246 } 247 } 248 } 249 250 // Now f is primitive; Let`s look if f is univariate 251 if ( f.isUnivariate() ) 252 { 253 DEBOUTLN(CERR, "f is univariate: ", f); 254 g = content(g); 255 if ( ! (g.isOne() || (-g).isOne() ) ) 256 { 257 Outputlist= myappend(Outputlist,CFFactor(g,1)) ; 258 f /= g; 259 } 260 Outputlist = Union(sqrFree(f),Outputlist) ; 261 DEBOUTLN(CERR, "Outputlist after univ. sqrFree(f) = ", Outputlist); 262 DEBDECLEVEL(CERR, "SqrFreed"); 263 return Outputlist ; 264 } 265 266 // Linear? 267 if ( totaldegree(f) <= 1 ) 268 { 269 Outputlist= myappend(Outputlist,CFFactor(f,1)) ; 270 DEBDECLEVEL(CERR, "SqrFreed"); 271 return Outputlist ; 272 } 273 274 // is it Pth root? 275 n=level(f); // maybe less indeterminants 276 g= f.deriv(); 277 if ( getCharacteristic() > 0 && g.isZero() ) 278 { // Pth roots only apply to char > 0 279 for (int k=1; k<=n; k++) 280 { 281 if ((mipo.isZero())/*||(k!=1)*/) 282 { 283 g=swapvar(f,k,n) ; 284 g = g.deriv(); 285 286 if ( ! g.isZero() ) 287 { // can`t be Pth root 288 CFFList Outputlist2= SqrFreed(swapvar(f,k,n)); 289 for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++) 290 { 291 Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp())); 292 } 293 return Outputlist; 294 } 295 } 296 } 297 // really is Pth power 298 DEBOUTLN(CERR, "f is a p'th root: ", f); 299 CFMap m; 300 g = compress(f,m); 301 if (mipo.isZero()) 302 f = m(PthRoot(g)); 303 else 304 f = m(PthRoot(g,mipo)); 305 DEBOUTLN(CERR, " that is : ", f); 306 // now : Outputlist union ( SqrFreed(f) )^getCharacteristic() 307 Outputlist=myUnion(Powerup(SqrFreeMV(f),getCharacteristic()),Outputlist); 308 DEBDECLEVEL(CERR, "SqrFreed"); 309 return Outputlist ; 310 } 311 g = f.deriv(); 312 DEBOUTLN(CERR, "calculating gcd of ", f); 313 DEBOUTLN(CERR, " and ", g); 314 h = gcd(f,pp(g)); h /= lc(h); 315 DEBOUTLN(CERR,"gcd(f,g)= ",h); 316 if ( (h.isOne()) || ( h==f) || ((-h).isOne()) || getNumVars(h)==0 ) 317 { // no common factor 318 Outputlist= myappend(Outputlist,CFFactor(f,1)) ; 319 DEBOUTLN(CERR, "Outputlist= ", Outputlist); 320 DEBDECLEVEL(CERR, "SqrFreed"); 321 return Outputlist ; 322 } 323 else 324 { // we can split into two nontrivial pieces 325 f /= h; // Now we have split the poly into f and h 326 g = lc(f); 327 if ( g != f.genOne() && getNumVars(g) == 0 ) 328 { 329 Outputlist= myappend(Outputlist,CFFactor(g,1)) ; 330 f /= g; 331 } 332 DEBOUTLN(CERR, "Split into f= ", f); 333 DEBOUTLN(CERR, " and h= ", h); 334 // For char > 0 the polys f and h can have Pth roots; so we need a test 335 // Test is disabled because timing is the same 336 337 // if ( SqrFreeTest(f,0) ) 338 // Outputlist= myappend(Outputlist,CFFactor(f,1)) ; 339 // else 340 Outputlist=myUnion(Outputlist, SqrFreeMV(f)); 341 // if ( SqrFreeTest(h,0) ) 342 // Outputlist= myappend(Outputlist,CFFactor(h,1)) ; 343 // else 344 Outputlist=myUnion(Outputlist,SqrFreeMV(h)); 345 DEBOUTLN(CERR, "Returning list ", Outputlist); 346 DEBDECLEVEL(CERR, "SqrFreed"); 347 return Outputlist ; 348 } 349 #ifdef HAVE_SINGULAR_ERROR 350 WerrorS("libfac: ERROR: SqrFreed: we should never fall trough here!"); 351 #else 352 #ifndef NOSTREAMIO 353 CERR << "\nlibfac: ERROR: SqrFreed: we should never fall trough here!\n" 354 << rcsid << errmsg << "\n"; 355 #endif 356 #endif 357 DEBDECLEVEL(CERR, "SqrFreed"); 358 return Outputlist; // for safety purpose 359 } 360 361 /////////////////////////////////////////////////////////////// 362 // The user front-end for the SqrFreed routine. // 363 // Input can have a constant as content // 364 /////////////////////////////////////////////////////////////// 139 365 CFFList 140 SqrFree(const CanonicalForm & r ){ 141 CFFList outputlist, sqrfreelist = sqrFree(r,0,false); 366 SqrFreeMV( const CanonicalForm & r , const CanonicalForm & mipo ) 367 { 368 CanonicalForm g=icontent(r), f = r; 369 CFFList Outputlist, Outputlist2; 370 371 DEBINCLEVEL(CERR, "SqrFreeMV"); 372 DEBOUTMSG(CERR, rcsid); 373 DEBOUTLN(CERR,"Called with f= ", f); 374 375 // Take care of stupid users giving us constants 376 if ( getNumVars(f) == 0 ) 377 { // a constant ; Exp==1 even if f==0 378 Outputlist= myappend(Outputlist,CFFactor(f,1)); 379 } 380 else 381 { 382 // Now we are sure: we have a nonconstant polynomial 383 g = lc(f); 384 while ( getNumVars(g) != 0 ) g=content(g); 385 if ( ! g.isOne() ) Outputlist= myappend(Outputlist,CFFactor(g,1)) ; 386 f /= g; 387 if ( getNumVars(f) != 0 ) // a real polynomial 388 { 389 if (!mipo.isZero()) 390 Outputlist=myUnion(SqrFreed(f,mipo),Outputlist) ; 391 else 392 Outputlist=myUnion(SqrFreed(f),Outputlist) ; 393 } 394 } 395 DEBOUTLN(CERR,"Outputlist = ", Outputlist); 396 for ( CFFListIterator i=Outputlist; i.hasItem(); i++ ) 397 if ( getNumVars(i.getItem().factor()) > 0 ) 398 Outputlist2.append(i.getItem()); 399 400 DEBOUTLN(CERR,"Outputlist2 = ", Outputlist2); 401 DEBDECLEVEL(CERR, "SqrFreeMV"); 402 return Outputlist2 ; 403 } 404 405 CFFList SqrFree(const CanonicalForm & r ) 406 { 407 CFFList outputlist, sqrfreelist = SqrFreeMV(r); 142 408 CFFListIterator i; 143 409 CanonicalForm elem; … … 146 412 DEBINCLEVEL(CERR, "SqrFree"); 147 413 148 if ( sqrfreelist.length() < 2 ){ 414 if ( sqrfreelist.length() < 2 ) 415 { 149 416 DEBDECLEVEL(CERR, "SqrFree"); 150 417 return sqrfreelist; 151 418 } 152 for ( int j=1; j<=n; j++ ){ 419 for ( int j=1; j<=n; j++ ) 420 { 153 421 elem =1; 154 for ( i = sqrfreelist; i.hasItem() ; i++ ){ 422 for ( i = sqrfreelist; i.hasItem() ; i++ ) 423 { 155 424 if ( i.getItem().exp() == j ) elem *= i.getItem().factor(); 156 425 } … … 171 440 /* 172 441 $Log: not supported by cvs2svn $ 173 Revision 1.13 2008/01/22 09:51:37 Singular174 *hannes: sqrFree/InternalSqrFree -> factory175 176 Revision 1.12 2008/01/07 13:34:56 Singular177 *hannes: omse optiomzations(isOne)178 179 Revision 1.11 2007/05/15 14:46:49 Singular180 *hannes: factorize in Zp(a)[x...]181 182 442 Revision 1.10 2006/05/16 14:46:50 Singular 183 443 *hannes: gcc 4.1 fixes -
libfac/factor/SqrFree.h
rca847b re89e56 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: SqrFree.h,v 1. 6 2008-01-25 14:19:40Singular Exp $4 // $Id: SqrFree.h,v 1.7 2008-03-17 17:44:16 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef SQRFREE_H … … 9 9 /*BEGINPUBLIC*/ 10 10 // CFFList SqrFree( const CanonicalForm & f ) ; 11 CFFList SqrFreeMV( const CanonicalForm & f , const CanonicalForm & mipo=0) ; 11 12 /*ENDPUBLIC*/ 13 int SqrFreeTest( const CanonicalForm & r, int opt=1) ; 12 14 CFFList SqrFree( const CanonicalForm & f ) ; 13 15 #endif /* SQRFREE_H */ … … 16 18 /* 17 19 $Log: not supported by cvs2svn $ 18 Revision 1.5 2008/01/22 09:51:37 Singular19 *hannes: sqrFree/InternalSqrFree -> factory20 21 20 Revision 1.4 2002/08/19 11:11:34 Singular 22 21 * hannes/pfister: alg_gcd etc. -
libfac/factor/Truefactor.cc
rca847b re89e56 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.1 3 2008-02-22 12:16:03Singular Exp $";4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.14 2008-03-17 17:44:16 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // Factory - Includes … … 229 229 CFFactor factor; 230 230 CFFList L,FAC,E_all; 231 int c,r = PiList.length(),degU, onemore,M, h = totaldegree(Ua,1,levelU) + 1;231 int c,r = PiList.length(),degU, onemore,M, h = subvardegree(Ua,levelU) + 1; 232 232 ListIterator<CFFactor> i; 233 233 … … 241 241 //CERR << " 1:" << change_poly(factor.factor(),SubstitutionList,1) <<"\n"; 242 242 c= mydivremt(U,test_f,a,b); 243 if ( c && b .isZero() && !hasAlgVar(test_f))243 if ( c && b == U.genZero() && !hasAlgVar(test_f)) 244 244 // factor.getFactor() divides U 245 245 { … … 450 450 /* 451 451 $Log: not supported by cvs2svn $ 452 Revision 1.12 2008/01/22 09:51:37 Singular453 *hannes: sqrFree/InternalSqrFree -> factory454 455 452 Revision 1.11 2008/01/07 13:34:56 Singular 456 453 *hannes: omse optiomzations(isOne) -
libfac/factor/helpstuff.cc
rca847b re89e56 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // static char * rcsid = "$Id: helpstuff.cc,v 1. 6 2008-01-22 09:51:37 Singular Exp $";4 // static char * rcsid = "$Id: helpstuff.cc,v 1.7 2008-03-17 17:44:17 Singular Exp $"; 5 5 //////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 12 12 13 13 bool 14 mydivremt ( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b ) 15 { 14 mydivremt ( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b ){ 16 15 bool retvalue; 17 16 CanonicalForm aa,bb; … … 24 23 25 24 void 26 mydivrem( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b ) 27 { 25 mydivrem( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b ){ 28 26 bool retvalue; 29 27 CanonicalForm aa,bb; … … 32 30 if ( aa==bb ) { b=bb; } 33 31 else { b=aa; } 32 } 33 34 // Now some procedures used in SqrFree and in Factor 35 /////////////////////////////////////////////////////////////// 36 /////////////////////////////////////////////////////////////// 37 // We have to include a version of <CFFList>.append(CFFactor)// 38 // and Union( CFFList, CFFList) // 39 // because we have to look for multiplicities in SqrFree. // 40 // e.g.: SqrFree( f^3 ) with char <> 3 // 41 /////////////////////////////////////////////////////////////// 42 CFFList 43 myappend( const CFFList & Inputlist, const CFFactor & TheFactor){ 44 CFFList Outputlist ; 45 CFFactor copy; 46 CFFListIterator i; 47 int exp=0; 48 49 for ( i=Inputlist ; i.hasItem() ; i++ ){ 50 copy = i.getItem(); 51 if ( copy.factor() == TheFactor.factor() ) 52 exp += copy.exp(); 53 else 54 Outputlist.append(copy); 55 } 56 Outputlist.append( CFFactor(TheFactor.factor(), exp + TheFactor.exp())); 57 return Outputlist; 58 } 59 60 CFFList 61 myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2){ 62 CFFList Outputlist; 63 CFFListIterator i; 64 65 for ( i=Inputlist1 ; i.hasItem() ; i++ ) 66 Outputlist = myappend(Outputlist, i.getItem() ); 67 for ( i=Inputlist2 ; i.hasItem() ; i++ ) 68 Outputlist = myappend(Outputlist, i.getItem() ); 69 70 return Outputlist; 71 } 72 73 int 74 Powerup( const int base , const int exp){ 75 int retvalue=1; 76 if ( exp == 0 ) return retvalue ; 77 else for ( int i=1 ; i <= exp; i++ ) retvalue *= base ; 78 79 return retvalue; 34 80 } 35 81 … … 80 126 81 127 /////////////////////////////////////////////////////////////// 128 // Return the deg of F in the Variables x_1,..,x_(levelF-1) // 129 /////////////////////////////////////////////////////////////// 130 int 131 subvardegree( const CanonicalForm & F, int levelF ){ 132 int n=0,m=degree(F,levelF),newn=0; 133 134 for ( int k=0; k<=m; k++ ){ 135 newn = totaldegree( F[k] ); 136 if ( newn > n ) n=newn; 137 } 138 return n; 139 } 140 141 /////////////////////////////////////////////////////////////// 82 142 // Change poly: x_i <- x_i +- a_i for i= 1,..,level(f)-1 // 83 143 /////////////////////////////////////////////////////////////// … … 115 175 /* 116 176 $Log: not supported by cvs2svn $ 117 Revision 1.5 2007/05/25 12:59:05 Singular118 *hannes: fdivides2119 120 177 Revision 1.4 2001/06/19 15:29:04 Singular 121 178 *hannes: optim. -
libfac/factor/helpstuff.h
rca847b re89e56 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: helpstuff.h,v 1. 5 2008-01-22 09:51:37 Singular Exp $4 // $Id: helpstuff.h,v 1.6 2008-03-17 17:44:17 Singular Exp $ 5 5 //////////////////////////////////////////////////////////// 6 6 #ifndef HELPSTUFF_H … … 12 12 /////////////////////////////////////////////////////////////// 13 13 CanonicalForm mod_power( const CanonicalForm & f, int k, int levelU); 14 int subvardegree( const CanonicalForm & F, int levelF ); 14 15 CanonicalForm change_poly( const CanonicalForm & f , const SFormList & Substitutionlist, int directionback ); 15 16 … … 17 18 // Now some procedures used in SqrFree and in Factor 18 19 /////////////////////////////////////////////////////////////// 19 inline int min ( const int a, const int b ) 20 { 20 CFFList myappend( const CFFList & Inputlist, const CFFactor & TheFactor) ; 21 CFFList myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2); 22 int Powerup( const int base , const int exp=1); 23 inline int min ( const int a, const int b ){ 21 24 return (a<=b ? a:b); 22 25 } 23 inline int max ( const int a, const int b ) 24 { 26 inline int max ( const int a, const int b ){ 25 27 return (a>b ? a:b); 26 28 } 29 27 30 #endif /* HELPSTUFF_H */ 28 31 … … 30 33 /* 31 34 $Log: not supported by cvs2svn $ 32 Revision 1.4 2007/05/15 14:46:49 Singular33 *hannes: factorize in Zp(a)[x...]34 35 35 Revision 1.3 1997/09/12 07:19:57 Singular 36 36 * hannes/michael: libfac-0.3.0
Note: See TracChangeset
for help on using the changeset viewer.