Changeset e2ca88 in git
- Timestamp:
- May 16, 2006, 4:46:50 PM (17 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 55abfc3008e047e8f26beaeb76b5bab66cfe8288
- Parents:
- dbcf42a937f51948f4de74902429b68c1b54592b
- Location:
- libfac
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/charset/alg_factor.cc
rdbcf42a re2ca88 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: alg_factor.cc,v 1.1 5 2005-10-17 13:16:18 Singular Exp $";5 static char * rcsid = "$Id: alg_factor.cc,v 1.16 2006-05-16 14:46:48 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 122 122 int delta; 123 123 124 DEBOUTLN( cout, "resultante: called f= ", f);125 DEBOUTLN( cout, "resultante: called g= ", g);126 DEBOUTLN( cout, "resultante: called v= ", v);124 DEBOUTLN( CERR, "resultante: called f= ", f); 125 DEBOUTLN( CERR, "resultante: called g= ", g); 126 DEBOUTLN( CERR, "resultante: called v= ", v); 127 127 if ( f.mvar() < v || g.mvar() < v ){ 128 DEBOUTMSG( cout, "resultante: f.mvar() < v || g.mvar() < v");128 DEBOUTMSG(CERR, "resultante: f.mvar() < v || g.mvar() < v"); 129 129 return 1; 130 130 } 131 131 132 132 if ( f.degree( v ) < 1 || g.degree( v ) < 1 ){ 133 DEBOUTMSG( cout, "resultante: f.degree( v ) < 1 || g.degree( v ) < 1");133 DEBOUTMSG(CERR, "resultante: f.degree( v ) < 1 || g.degree( v ) < 1"); 134 134 // If deg(F,v) == 0 , then resultante(F,G,v) = F^n, where n=deg(G,v) 135 135 if ( f.degree( v ) < 1 ) return power(f,degree(g,v)); … … 178 178 CFFListIterator i; 179 179 180 DEBOUTLN( cout, "sqrf_norm_sub: f= ", f);181 DEBOUTLN( cout, "sqrf_norm_sub: Palpha= ", Palpha);180 DEBOUTLN(CERR, "sqrf_norm_sub: f= ", f); 181 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 182 182 myrandom.reset(); s=f.mvar()-myrandom.item()*Palpha.mvar(); g=f; 183 183 R= CanonicalForm(0); 184 DEBOUTLN( cout, "sqrf_norm_sub: myrandom s= ", s);184 DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s); 185 185 186 186 // Norm, resultante taken with respect to y 187 187 while ( !sqfreetest ){ 188 DEBOUTLN( cout, "sqrf_norm_sub: Palpha= ", Palpha);188 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 189 189 R = resultante(Palpha, g, y); R= R* bCommonDen(R); 190 DEBOUTLN( cout, "sqrf_norm_sub: R= ", R);190 DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R); 191 191 // sqfree check ; R is a polynomial in K[x] 192 192 if ( getCharacteristic() == 0 ) 193 193 { 194 194 temp= gcd(R, R.deriv(vf)); 195 DEBOUTLN( cout, "sqrf_norm_sub: temp= ", temp);195 DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp); 196 196 if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; } 197 197 else { sqfreetest= 1; } 198 DEBOUTLN( cout, "sqrf_norm_sub: sqfreetest= ", sqfreetest);198 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 199 199 } 200 200 else{ 201 DEBOUTMSG( cout, "Starting SqrFreeTest(R)!");201 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 202 202 // Look at SqrFreeTest! 203 203 // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 ! … … 214 214 else 215 215 testlist= Factorize(R); 216 DEBOUTLN( cout, "testlist= ", testlist);216 DEBOUTLN(CERR, "testlist= ", testlist); 217 217 testlist.removeFirst(); 218 218 sqfreetest=1; 219 219 for ( i=testlist; i.hasItem(); i++) 220 220 if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; } 221 DEBOUTLN( cout, "SqrFreeTest(R)= ", sqfreetest);221 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 222 222 } 223 223 if ( ! sqfreetest ){ 224 224 myrandom.next(); 225 DEBOUTLN( cout, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());225 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); 226 226 if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item())); 227 227 else t= CanonicalForm(myrandom.item()); 228 228 s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution 229 DEBOUTLN( cout, "sqrf_norm_sub: testing s= ", s);229 DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s); 230 230 g= f(f.mvar()-t*Palpha.mvar(), f.mvar()); 231 DEBOUTLN( cout, " gives g= ", g);231 DEBOUTLN(CERR, " gives g= ", g); 232 232 } 233 233 } … … 243 243 CFFListIterator i; 244 244 245 DEBOUTLN( cout, "sqrf_norm_sub: f= ", f);246 DEBOUTLN( cout, "sqrf_norm_sub: Palpha= ", Palpha);245 DEBOUTLN(CERR, "sqrf_norm_sub: f= ", f); 246 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 247 247 myrandom.reset(); s=f.mvar()-myrandom.item()*Palpha.mvar(); g=f; 248 248 R= CanonicalForm(0); 249 DEBOUTLN( cout, "sqrf_norm_sub: myrandom s= ", s);249 DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s); 250 250 251 251 // Norm, resultante taken with respect to y 252 252 while ( !sqfreetest ){ 253 DEBOUTLN( cout, "sqrf_norm_sub: Palpha= ", Palpha);253 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 254 254 R = resultante(Palpha, g, y); R= R* bCommonDen(R); 255 DEBOUTLN( cout, "sqrf_norm_sub: R= ", R);255 DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R); 256 256 // sqfree check ; R is a polynomial in K[x] 257 257 if ( getCharacteristic() == 0 ) 258 258 { 259 259 temp= gcd(R, R.deriv(vf)); 260 DEBOUTLN( cout, "sqrf_norm_sub: temp= ", temp);260 DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp); 261 261 if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; } 262 262 else { sqfreetest= 1; } 263 DEBOUTLN( cout, "sqrf_norm_sub: sqfreetest= ", sqfreetest);263 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 264 264 } 265 265 else{ 266 DEBOUTMSG( cout, "Starting SqrFreeTest(R)!");266 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 267 267 // Look at SqrFreeTest! 268 268 // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 ! … … 279 279 else 280 280 testlist= Factorize(R); 281 DEBOUTLN( cout, "testlist= ", testlist);281 DEBOUTLN(CERR, "testlist= ", testlist); 282 282 testlist.removeFirst(); 283 283 sqfreetest=1; 284 284 for ( i=testlist; i.hasItem(); i++) 285 285 if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; } 286 DEBOUTLN( cout, "SqrFreeTest(R)= ", sqfreetest);286 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 287 287 } 288 288 if ( ! sqfreetest ){ 289 289 myrandom.next(); 290 DEBOUTLN( cout, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());290 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); 291 291 if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item())); 292 292 else t= CanonicalForm(myrandom.item()); 293 293 s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution 294 DEBOUTLN( cout, "sqrf_norm_sub: testing s= ", s);294 DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s); 295 295 g= f(f.mvar()-t*Palpha.mvar(), f.mvar()); 296 DEBOUTLN( cout, " gives g= ", g);296 DEBOUTLN(CERR, " gives g= ", g); 297 297 } 298 298 } … … 304 304 CanonicalForm & R){ 305 305 306 DEBOUTLN( cout, "sqrf_norm: f= ", f);307 DEBOUTLN( cout, "sqrf_norm: Palpha= ", PPalpha);306 DEBOUTLN(CERR, "sqrf_norm: f= ", f); 307 DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha); 308 308 if ( getCharacteristic() == 0 ) { 309 309 IntGenerator myrandom; 310 DEBOUTMSG( cout, "sqrf_norm: no extension, char=0");310 DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0"); 311 311 sqrf_norm_sub(f,PPalpha, myrandom, s,g,R); 312 DEBOUTLN( cout, "sqrf_norm: f= ", f);313 DEBOUTLN( cout, "sqrf_norm: Palpha= ", PPalpha);314 DEBOUTLN( cout, "sqrf_norm: s= ", s);315 DEBOUTLN( cout, "sqrf_norm: g= ", g);316 DEBOUTLN( cout, "sqrf_norm: R= ", R);312 DEBOUTLN(CERR, "sqrf_norm: f= ", f); 313 DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha); 314 DEBOUTLN(CERR, "sqrf_norm: s= ", s); 315 DEBOUTLN(CERR, "sqrf_norm: g= ", g); 316 DEBOUTLN(CERR, "sqrf_norm: R= ", R); 317 317 } 318 318 else if ( degree(Extension) > 0 ){ // working over Extensions 319 DEBOUTLN( cout, "sqrf_norm: degree of extension is ", degree(Extension));319 DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension)); 320 320 AlgExtGenerator myrandom(Extension); 321 321 sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R); … … 323 323 else{ 324 324 FFGenerator myrandom; 325 DEBOUTMSG( cout, "sqrf_norm: degree of extension is 0");325 DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0"); 326 326 sqrf_norm_sub(f,PPalpha, myrandom, s,g,R); 327 327 } … … 396 396 l= l+1; 397 397 if ( gcd0(k,i.getItem()) == 1){ 398 DEBOUTLN( cout, "getextension: gcd == 1, l=",l);398 DEBOUTLN(CERR, "getextension: gcd == 1, l=",l); 399 399 if ( l==length ){ setCharacteristic(charac); return k; } 400 400 } 401 else { DEBOUTMSG( cout, "getextension: Next iteration"); break; }401 else { DEBOUTMSG(CERR, "getextension: Next iteration"); break; } 402 402 } 403 403 k= k+1; l=0; … … 414 414 CanonicalForm s, g; 415 415 416 DEBOUTLN( cout, "simpleextension: Astar= ", Astar);417 DEBOUTLN( cout, "simpleextension: R= ", R);418 DEBOUTLN( cout, "simpleextension: Extension= ", Extension);416 DEBOUTLN(CERR, "simpleextension: Astar= ", Astar); 417 DEBOUTLN(CERR, "simpleextension: R= ", R); 418 DEBOUTLN(CERR, "simpleextension: Extension= ", Extension); 419 419 if ( Astar.length() == 1 ){ R= Astar.getFirst();} 420 420 else{ 421 421 R=Bstar.getFirst(); Bstar.removeFirst(); 422 422 for ( CFListIterator i=Bstar; i.hasItem(); i++){ 423 DEBOUTLN( cout, "simpleextension: f(x)= ", i.getItem());424 DEBOUTLN( cout, "simpleextension: P(x)= ", R);423 DEBOUTLN(CERR, "simpleextension: f(x)= ", i.getItem()); 424 DEBOUTLN(CERR, "simpleextension: P(x)= ", R); 425 425 sqrf_norm(i.getItem(), R, Extension, s, g, R); 426 426 // spielt die Repraesentation eine Rolle? 427 427 // muessen wir die Nachfolger aendern, wenn s != 0 ? 428 DEBOUTLN( cout, "simpleextension: g= ", g);429 if ( s != 0 ) DEBOUTLN( cout, "simpleextension: s= ", s);430 else DEBOUTLN( cout, "simpleextension: s= ", s);431 DEBOUTLN( cout, "simpleextension: R= ", R);428 DEBOUTLN(CERR, "simpleextension: g= ", g); 429 if ( s != 0 ) DEBOUTLN(CERR, "simpleextension: s= ", s); 430 else DEBOUTLN(CERR, "simpleextension: s= ", s); 431 DEBOUTLN(CERR, "simpleextension: R= ", R); 432 432 Returnlist.insert(s); 433 433 } … … 453 453 CFList substlist; 454 454 455 DEBINCLEVEL( cout,"alg_factor");456 DEBOUTLN( cout, "alg_factor: f= ", f);455 DEBINCLEVEL(CERR,"alg_factor"); 456 DEBOUTLN(CERR, "alg_factor: f= ", f); 457 457 //out_cf("start alg_factor:",f,"\n"); 458 458 substlist= simpleextension(Astar, vminpoly, Rstar); 459 DEBOUTLN( cout, "alg_factor: substlist= ", substlist);460 DEBOUTLN( cout, "alg_factor: minpoly Rstar= ", Rstar);461 DEBOUTLN( cout, "alg_factor: vminpoly= ", vminpoly);459 DEBOUTLN(CERR, "alg_factor: substlist= ", substlist); 460 DEBOUTLN(CERR, "alg_factor: minpoly Rstar= ", Rstar); 461 DEBOUTLN(CERR, "alg_factor: vminpoly= ", vminpoly); 462 462 463 463 sqrf_norm(f, Rstar, vminpoly, s, g, R ); … … 465 465 //out_cf("sqrf_norm s:",s,"\n"); 466 466 //out_cf("sqrf_norm g:",g,"\n"); 467 DEBOUTLN( cout, "alg_factor: g= ", g);468 DEBOUTLN( cout, "alg_factor: s= ", s);469 DEBOUTLN( cout, "alg_factor: R= ", R);467 DEBOUTLN(CERR, "alg_factor: g= ", g); 468 DEBOUTLN(CERR, "alg_factor: s= ", s); 469 DEBOUTLN(CERR, "alg_factor: R= ", R); 470 470 Off(SW_RATIONAL); 471 471 Variable X; … … 473 473 { 474 474 // factorize R over alg.extension with X 475 // cout << "alg: "<< X << " mipo=" << getMipo(X,Variable('X')) <<endl;475 //CERR << "alg: "<< X << " mipo=" << getMipo(X,Variable('X')) <<"\n"; 476 476 if (R.isUnivariate()) 477 477 { 478 DEBOUTLN( cout, "alg_factor: factorize( ", R);478 DEBOUTLN(CERR, "alg_factor: factorize( ", R); 479 479 Factorlist = factorize( R, X ); 480 480 } … … 485 485 CanonicalForm mipo=getMipo(X,XX); 486 486 CFList as(mipo); 487 DEBOUTLN( cout, "alg_factor: newfactoras( ", R);487 DEBOUTLN(CERR, "alg_factor: newfactoras( ", R); 488 488 Factorlist = newfactoras(R, as , 1); 489 489 #else 490 490 // factor R over k 491 DEBOUTLN( cout, "alg_factor: Factorize( ", R);491 DEBOUTLN(CERR, "alg_factor: Factorize( ", R); 492 492 Factorlist = Factorize(R); 493 493 #endif … … 497 497 { 498 498 // factor R over k 499 DEBOUTLN( cout, "alg_factor: Factorize( ", R);499 DEBOUTLN(CERR, "alg_factor: Factorize( ", R); 500 500 Factorlist = Factorize(R); 501 501 } 502 502 On(SW_RATIONAL); 503 DEBOUTLN( cout, "alg_factor: Factorize(R)= ", Factorlist);503 DEBOUTLN(CERR, "alg_factor: Factorize(R)= ", Factorlist); 504 504 if ( !Factorlist.getFirst().factor().inCoeffDomain() ) 505 505 Factorlist.insert(CFFactor(1,1)); … … 508 508 } 509 509 else{ 510 DEBOUTLN( cout, "alg_factor: g= ", g);510 DEBOUTLN(CERR, "alg_factor: g= ", g); 511 511 CanonicalForm gnew= g(s,s.mvar()); 512 DEBOUTLN( cout, "alg_factor: gnew= ", gnew);512 DEBOUTLN(CERR, "alg_factor: gnew= ", gnew); 513 513 g=gnew; 514 514 for ( CFFListIterator i=Factorlist; i.hasItem(); i++){ 515 515 CanonicalForm fnew=i.getItem().factor(); 516 516 fnew= fnew(s,s.mvar()); 517 DEBOUTLN( cout, "alg_factor: fnew= ", fnew);518 DEBOUTLN( cout, "alg_factor: substlist= ", substlist);517 DEBOUTLN(CERR, "alg_factor: fnew= ", fnew); 518 DEBOUTLN(CERR, "alg_factor: substlist= ", substlist); 519 519 for ( CFListIterator ii=substlist; ii.hasItem(); ii++){ 520 DEBOUTLN( cout, "alg_factor: item= ", ii.getItem());520 DEBOUTLN(CERR, "alg_factor: item= ", ii.getItem()); 521 521 fnew= fnew(ii.getItem(), ii.getItem().mvar()); 522 DEBOUTLN( cout, "alg_factor: fnew= ", fnew);522 DEBOUTLN(CERR, "alg_factor: fnew= ", fnew); 523 523 } 524 524 if (degree(i.getItem().factor()) > 0 ){ 525 525 // undo linear transformation!!!! and then gcd! 526 // cout << "algcd(" << g << "," << fnew << ",as" << as << ")" << endl;526 //CERR << "algcd(" << g << "," << fnew << ",as" << as << ")" << "\n"; 527 527 //out_cf("algcd g=",g,"\n"); 528 528 //out_cf("algcd fnew=",fnew,"\n"); … … 534 534 //out_cf(" -> algcd=",algcd(g,fnew, as, oldord),"\n"); 535 535 //out_cf(" -> alg_gcd=",alg_gcd(g,fnew,as),"\n"); 536 // cout << "algcd result:" << h << endl;537 DEBOUTLN( cout, " alg_factor: h= ", h);538 DEBOUTLN( cout, " alg_factor: oldord= ", oldord);536 //CERR << "algcd result:" << h << "\n"; 537 DEBOUTLN(CERR, " alg_factor: h= ", h); 538 DEBOUTLN(CERR, " alg_factor: oldord= ", oldord); 539 539 if ( degree(h) > 0 ){ //otherwise it's a constant 540 540 g= divide(g, h,as); 541 DEBOUTLN( cout, "alg_factor: g/h= ", g);542 DEBOUTLN( cout, "alg_factor: s= ", s);543 DEBOUTLN( cout, "alg_factor: substlist= ", substlist);541 DEBOUTLN(CERR, "alg_factor: g/h= ", g); 542 DEBOUTLN(CERR, "alg_factor: s= ", s); 543 DEBOUTLN(CERR, "alg_factor: substlist= ", substlist); 544 544 L.append(CFFactor(h,1)); 545 545 } … … 575 575 // out_cf("end alg_f:",i.getItem().factor(),"\n"); 576 576 //printf("end alg_factor\n"); 577 DEBOUTLN( cout, "alg_factor: L= ", LL);578 DEBDECLEVEL( cout,"alg_factor");577 DEBOUTLN(CERR, "alg_factor: L= ", LL); 578 DEBDECLEVEL(CERR,"alg_factor"); 579 579 return LL; 580 580 } … … 592 592 g= i.getItem(); 593 593 if (g.deriv() == 0 ){ 594 DEBOUTLN( cout, "Inseperable extension detected: ", g);594 DEBOUTLN(CERR, "Inseperable extension detected: ", g); 595 595 for (j=uord; j.hasItem(); j++){ 596 596 if ( degree(g,j.getItem()) > 0 ) vg= j.getItem(); 597 597 } 598 598 // Now we have the highest transzendental in vg; 599 DEBOUTLN( cout, "Transzendental is ", vg);599 DEBOUTLN(CERR, "Transzendental is ", vg); 600 600 CanonicalForm gg=-1*g[0]; 601 601 divrem(gg,vg,q,r); r= gg-q*vg; gg= gg-r; 602 //DEBOUTLN( cout, "q= ", q); DEBOUTLN(cout, "r= ", r);603 DEBOUTLN( cout, " that is ", gg);604 DEBOUTLN( cout, " maps to ", g+gg);602 //DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r); 603 DEBOUTLN(CERR, " that is ", gg); 604 DEBOUTLN(CERR, " maps to ", g+gg); 605 605 One.insert(gg); Two.insert(g+gg); 606 606 // Now transform all remaining polys in as: … … 609 609 if ( x != 0 ){ 610 610 divrem(ii.getItem(), gg, q,r); 611 // cout << ii.getItem() << " divided by " << gg << endl;612 DEBOUTLN( cout, "q= ", q); DEBOUTLN(cout, "r= ", r);611 // CERR << ii.getItem() << " divided by " << gg << "\n"; 612 DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r); 613 613 ii.append(ii.getItem()+q*g); ii.remove(1); 614 DEBOUTLN( cout, "as= ", as);614 DEBOUTLN(CERR, "as= ", as); 615 615 } 616 616 x+= 1; … … 619 619 divrem(F, gg, q,r); 620 620 F= F+q*g; 621 DEBOUTLN( cout, "new F= ", F);621 DEBOUTLN(CERR, "new F= ", F); 622 622 } 623 623 else{ asnew.append(i.getItem()); }// just the identity 624 624 } 625 625 // factor F with minimal polys given in asnew: 626 DEBOUTLN( cout, "Factor F= ", F);627 DEBOUTLN( cout, " with as= ", asnew);626 DEBOUTLN(CERR, "Factor F= ", F); 627 DEBOUTLN(CERR, " with as= ", asnew); 628 628 int success=0; 629 629 CFFList factorlist= newcfactor(F,asnew, success); 630 DEBOUTLN( cout, " gives = ", factorlist);631 DEBOUTLN( cout, "One= ", One);632 DEBOUTLN( cout, "Two= ", Two);630 DEBOUTLN(CERR, " gives = ", factorlist); 631 DEBOUTLN(CERR, "One= ", One); 632 DEBOUTLN(CERR, "Two= ", Two); 633 633 634 634 // Transform back: … … 637 637 ii=One; 638 638 for (i=Two; i.hasItem(); i++){ 639 DEBOUTLN( cout, "Mapping ", i.getItem());640 DEBOUTLN( cout, " to ", ii.getItem());641 DEBOUTLN( cout, " in ", factor);639 DEBOUTLN(CERR, "Mapping ", i.getItem()); 640 DEBOUTLN(CERR, " to ", ii.getItem()); 641 DEBOUTLN(CERR, " in ", factor); 642 642 divrem(factor,i.getItem(),q,r); r=factor -q*i.getItem(); 643 DEBOUTLN( cout, "q= ", q); DEBOUTLN(cout, "r= ", r);643 DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r); 644 644 factor= ii.getItem()*q +r; // 645 645 ii++; … … 664 664 665 665 success=1; 666 DEBINCLEVEL( cout, "newfactoras");667 DEBOUTMSG( cerr, rcsid);668 DEBOUTLN( cout, "newfactoras called with f= ", f);669 DEBOUTLN( cout, " content(f)= ", content(f));670 DEBOUTLN( cout, " as= ", as);671 DEBOUTLN( cout, "newfactoras: cls(vf)= ", cls(vf));672 DEBOUTLN( cout, "newfactoras: cls(as.getLast())= ", cls(as.getLast()));673 DEBOUTLN( cout, "newfactoras: degree(f,vf)= ", degree(f,vf));666 DEBINCLEVEL(CERR, "newfactoras"); 667 DEBOUTMSG(CERR, rcsid); 668 DEBOUTLN(CERR, "newfactoras called with f= ", f); 669 DEBOUTLN(CERR, " content(f)= ", content(f)); 670 DEBOUTLN(CERR, " as= ", as); 671 DEBOUTLN(CERR, "newfactoras: cls(vf)= ", cls(vf)); 672 DEBOUTLN(CERR, "newfactoras: cls(as.getLast())= ", cls(as.getLast())); 673 DEBOUTLN(CERR, "newfactoras: degree(f,vf)= ", degree(f,vf)); 674 674 675 675 // F1: [Test trivial cases] … … 677 677 if ( (cls(vf) <= cls(as.getLast())) || degree(f,vf)<=1 ){ 678 678 // ||( (as.length()==1) && (degree(f,vf)==3) && (degree(as.getFirst()==2)) ) 679 DEBDECLEVEL( cout,"newfactoras");679 DEBDECLEVEL(CERR,"newfactoras"); 680 680 return CFFList(CFFactor(f,1)); 681 681 } … … 700 700 } 701 701 uord= Difference(uord,ord); 702 DEBOUTLN( cout, "Astar is: ", Astar);703 DEBOUTLN( cout, "ord is: ", ord);704 DEBOUTLN( cout, "uord is: ", uord);702 DEBOUTLN(CERR, "Astar is: ", Astar); 703 DEBOUTLN(CERR, "ord is: ", ord); 704 DEBOUTLN(CERR, "uord is: ", uord); 705 705 706 706 // 3) second trivial cases: we already prooved irr. of f over no extensions 707 707 if ( Astar.length() == 0 ){ 708 DEBDECLEVEL( cout,"newfactoras");708 DEBDECLEVEL(CERR,"newfactoras"); 709 709 return CFFList(CFFactor(f,1)); 710 710 } … … 718 718 // polynomials, we don't have transzendentals. 719 719 Varlist newuord=Var_is_in_AS(uord,Astar); 720 DEBOUTLN( cout, "newuord is: ", newuord);720 DEBOUTLN(CERR, "newuord is: ", newuord); 721 721 722 722 CFFList Factorlist; 723 723 Varlist gcdord= Union(ord,newuord); gcdord.append(f.mvar()); 724 724 // This is for now. we need alg_sqrfree implemented! 725 // cout << "algcd(" << f << "," << f.deriv() << " as:" << Astar <<endl;725 //CERR << "algcd(" << f << "," << f.deriv() << " as:" << Astar <<"\n"; 726 726 //CanonicalForm Fgcd= algcd(f,f.deriv(),Astar,gcdord); 727 727 CanonicalForm Fgcd; … … 732 732 //out_cf("algcd:",algcd(f,f.deriv(),Astar,gcdord),"\n"); 733 733 //out_cf("alg_gcd:",alg_gcd(f,f.deriv(),Astar),"\n"); 734 // cout << "algcd result:" << Fgcd << endl;735 if ( Fgcd == 0 ) DEBOUTMSG( cerr, "WARNING: p'th root ?");734 // CERR << "algcd result:" << Fgcd << "\n"; 735 if ( Fgcd == 0 ) DEBOUTMSG(CERR, "WARNING: p'th root ?"); 736 736 if (( degree(Fgcd, f.mvar()) > 0) && (!(f.deriv().isZero())) ){ 737 DEBOUTLN( cout, "Nontrivial GCD found of ", f);737 DEBOUTLN(CERR, "Nontrivial GCD found of ", f); 738 738 CanonicalForm Ggcd= divide(f, Fgcd,Astar); 739 DEBOUTLN( cout, " split into ", Fgcd);740 DEBOUTLN( cout, " and ", Ggcd);739 DEBOUTLN(CERR, " split into ", Fgcd); 740 DEBOUTLN(CERR, " and ", Ggcd); 741 741 Fgcd= pp(Fgcd); Ggcd= pp(Ggcd); 742 DEBDECLEVEL( cout,"newfactoras");742 DEBDECLEVEL(CERR,"newfactoras"); 743 743 return myUnion(newfactoras(Fgcd,as,success) , newfactoras(Ggcd,as,success)); 744 744 } … … 750 750 for (i=Astar; i.hasItem(); i++){degreelist.append(degree(i.getItem()));} 751 751 int extdeg= getextension(degreelist, degree(f)); 752 DEBOUTLN( cout, "Extension needed of degree ", extdeg);752 DEBOUTLN(CERR, "Extension needed of degree ", extdeg); 753 753 754 754 // Now the real stuff! 755 755 if ( newuord.length() == 0 ){ // no transzendentals 756 DEBOUTMSG( cout, "No transzendentals!");756 DEBOUTMSG(CERR, "No transzendentals!"); 757 757 if ( extdeg > 1 ){ 758 758 CanonicalForm MIPO= generate_mipo( extdeg, vminpoly); 759 DEBOUTLN( cout, "Minpoly produced ", MIPO);759 DEBOUTLN(CERR, "Minpoly produced ", MIPO); 760 760 vminpoly= rootOf(MIPO); 761 761 } 762 762 Factorlist= alg_factor(f, Astar, vminpoly, oldord, as); 763 DEBDECLEVEL( cout,"newfactoras");763 DEBDECLEVEL(CERR,"newfactoras"); 764 764 return Factorlist; 765 765 } 766 766 else if ( inseperable(Astar) > 0 ){ // Look if extensions are seperable 767 767 // a) Use Endler 768 DEBOUTMSG( cout, "Inseperable extensions! Using Endler!");768 DEBOUTMSG(CERR, "Inseperable extensions! Using Endler!"); 769 769 CFFList templist= endler(f,Astar, newuord); 770 DEBOUTLN( cout, "Endler gives: ", templist);770 DEBOUTLN(CERR, "Endler gives: ", templist); 771 771 return templist; 772 772 } 773 773 else{ // we are on the save side: Use trager 774 DEBOUTMSG( cout, "Only seperable extensions!");774 DEBOUTMSG(CERR, "Only seperable extensions!"); 775 775 if (extdeg > 1 ){ 776 776 CanonicalForm MIPO=generate_mipo(extdeg, vminpoly ); 777 777 vminpoly= rootOf(MIPO); 778 DEBOUTLN( cout, "Minpoly generated: ", MIPO);779 DEBOUTLN( cout, "vminpoly= ", vminpoly);780 DEBOUTLN( cout, "degree(vminpoly)= ", degree(vminpoly));778 DEBOUTLN(CERR, "Minpoly generated: ", MIPO); 779 DEBOUTLN(CERR, "vminpoly= ", vminpoly); 780 DEBOUTLN(CERR, "degree(vminpoly)= ", degree(vminpoly)); 781 781 } 782 782 Factorlist= alg_factor(f, Astar, vminpoly, oldord, as); 783 DEBDECLEVEL( cout,"newfactoras");783 DEBDECLEVEL(CERR,"newfactoras"); 784 784 return Factorlist; 785 785 } 786 786 } 787 787 else{ // char=0 apply trager directly 788 DEBOUTMSG( cout, "Char=0! Apply Trager!");788 DEBOUTMSG(CERR, "Char=0! Apply Trager!"); 789 789 Variable vminpoly; 790 790 Factorlist= alg_factor(f, Astar, vminpoly, oldord, as); 791 DEBDECLEVEL( cout,"newfactoras");791 DEBDECLEVEL(CERR,"newfactoras"); 792 792 return Factorlist; 793 793 } 794 794 795 DEBDECLEVEL( cout,"newfactoras");795 DEBDECLEVEL(CERR,"newfactoras"); 796 796 return CFFList(CFFactor(f,1)); 797 797 } … … 817 817 /* 818 818 $Log: not supported by cvs2svn $ 819 Revision 1.15 2005/10/17 13:16:18 Singular 820 *hannes: code cleanup 821 819 822 Revision 1.14 2005/07/08 09:18:15 Singular 820 823 *hannes: fixed call of resultant -
libfac/charset/algfactor.cc
rdbcf42a re2ca88 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: algfactor.cc,v 1. 6 2002-08-19 11:11:30Singular Exp $";5 static char * rcsid = "$Id: algfactor.cc,v 1.7 2006-05-16 14:46:48 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 80 80 int nas= AS.length() +1; 81 81 82 DEBOUTLN( cout, "charsetnA: called with ps= ", PS);82 DEBOUTLN(CERR, "charsetnA: called with ps= ", PS); 83 83 while ( ! RS.isEmpty() ) { 84 84 CS = BasicSet( QS ); 85 DEBOUTLN( cout, "charsetnA: CS= ", CS);85 DEBOUTLN(CERR, "charsetnA: CS= ", CS); 86 86 CS=Union(CS,AS); 87 DEBOUTLN( cout, "charsetnA: CS= ", CS);87 DEBOUTLN(CERR, "charsetnA: CS= ", CS); 88 88 Remembern.FS1 = Union(Remembern.FS1, initalset1(CS)); 89 DEBOUTLN( cout, "charsetnA: Remembern.FS1= ", Remembern.FS1);90 DEBOUTLN( cout, "charsetnA: Remembern.FS2= ", Remembern.FS2);89 DEBOUTLN(CERR, "charsetnA: Remembern.FS1= ", Remembern.FS1); 90 DEBOUTLN(CERR, "charsetnA: Remembern.FS2= ", Remembern.FS2); 91 91 RS = CFList(); 92 92 if ( CS.length() == nas && degree(CS.getLast(),vf) > 0 ) { 93 93 CFList D = Difference( QS, CS ); 94 DEBOUT( cout, "charsetnA: Difference( ", QS);95 DEBOUT( cout, " , ", CS);96 DEBOUTLN( cout, " ) = ", D);94 DEBOUT(CERR, "charsetnA: Difference( ", QS); 95 DEBOUT(CERR, " , ", CS); 96 DEBOUTLN(CERR, " ) = ", D); 97 97 for ( CFListIterator i = D; i.hasItem(); ++i ) { 98 98 CanonicalForm r = Prem( i.getItem(), CS ); 99 DEBOUT( cout,"charsetnA: Prem(", i.getItem() );100 DEBOUT( cout, ",", CS);101 DEBOUTLN( cout,") = ", r);99 DEBOUT(CERR,"charsetnA: Prem(", i.getItem() ); 100 DEBOUT(CERR, ",", CS); 101 DEBOUTLN(CERR,") = ", r); 102 102 if ( r != 0 ){ 103 103 //removefactor( r, Remembern ); … … 106 106 } 107 107 if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1)); 108 DEBOUTLN( cout, "charsetnA: RS= ", RS);108 DEBOUTLN(CERR, "charsetnA: RS= ", RS); 109 109 //QS = Union( QS, RS ); 110 110 QS=Union(AS,RS); QS.append(CS.getLast()); 111 DEBOUTLN( cout, "charsetnA: QS= Union(QS,RS)= ", QS);111 DEBOUTLN(CERR, "charsetnA: QS= Union(QS,RS)= ", QS); 112 112 } 113 113 else{ return CFList(CanonicalForm(1)); } 114 114 } 115 DEBOUTLN( cout, "charsetnA: Removed factors: ", Remembern.FS2);116 DEBOUTLN( cout, "charsetnA: Remembern.FS1: ", Remembern.FS1);115 DEBOUTLN(CERR, "charsetnA: Removed factors: ", Remembern.FS2); 116 DEBOUTLN(CERR, "charsetnA: Remembern.FS1: ", Remembern.FS1); 117 117 118 118 return CS; … … 140 140 // nas= as.length()+1; 141 141 142 DEBOUTLN( cout, "algcd called with f= ", f);143 DEBOUTLN( cout, " g= ", g);144 DEBOUTLN( cout, " as= ", as);145 DEBOUTLN( cout, " order= ", order);146 DEBOUTLN( cout, " choosen vf= ", vf);142 DEBOUTLN(CERR, "algcd called with f= ", f); 143 DEBOUTLN(CERR, " g= ", g); 144 DEBOUTLN(CERR, " as= ", as); 145 DEBOUTLN(CERR, " order= ", order); 146 DEBOUTLN(CERR, " choosen vf= ", vf); 147 147 148 148 // check trivial case: 149 149 if ( degree(f, order.getLast())==0 || degree(g, order.getLast())==0) 150 150 { 151 DEBOUTLN( cout, "algcd Result= ", 1);151 DEBOUTLN(CERR, "algcd Result= ", 1); 152 152 return CanonicalForm(1); 153 153 } … … 156 156 PremForm Remembern; 157 157 CFList cs=charsetnA(as,bs,Remembern,vf); 158 DEBOUTLN( cout, "CharSetA((as,bs))= ", cs);158 DEBOUTLN(CERR, "CharSetA((as,bs))= ", cs); 159 159 160 160 // for ( VarlistIterator i=order; i.hasItem() ; i++ ){ 161 // DEBOUTLN( cout, "vf= ", i.getItem());162 // DEBOUTLN( cout, "CharSetA((as,bs))= " , charsetnA(as,bs,Remembern,i.getItem()));161 // DEBOUTLN(CERR, "vf= ", i.getItem()); 162 // DEBOUTLN(CERR, "CharSetA((as,bs))= " , charsetnA(as,bs,Remembern,i.getItem())); 163 163 // } 164 164 … … 180 180 } 181 181 else result= CanonicalForm(1); 182 DEBOUTLN( cout, "algcd Result= ", result);182 DEBOUTLN(CERR, "algcd Result= ", result); 183 183 return result; 184 184 } … … 192 192 CFFList result; 193 193 194 DEBINCLEVEL( cout, "factoras");195 DEBOUTMSG( cerr, rcsid);196 DEBOUTLN( cout, "factoras called with f= ", f);197 DEBOUTLN( cout, " content(f)= ", content(f));198 DEBOUTLN( cout, " as= ", as);199 DEBOUTLN( cout, "factoras: cls(vf)= ", cls(vf));200 DEBOUTLN( cout, "factoras: cls(as.getLast())= ", cls(as.getLast()));201 DEBOUTLN( cout, "factoras: degree(f,vf)= ", degree(f,vf));194 DEBINCLEVEL(CERR, "factoras"); 195 DEBOUTMSG(CERR, rcsid); 196 DEBOUTLN(CERR, "factoras called with f= ", f); 197 DEBOUTLN(CERR, " content(f)= ", content(f)); 198 DEBOUTLN(CERR, " as= ", as); 199 DEBOUTLN(CERR, "factoras: cls(vf)= ", cls(vf)); 200 DEBOUTLN(CERR, "factoras: cls(as.getLast())= ", cls(as.getLast())); 201 DEBOUTLN(CERR, "factoras: degree(f,vf)= ", degree(f,vf)); 202 202 203 203 // F1: [Test trivial cases] … … 208 208 ){ 209 209 success=1; 210 DEBDECLEVEL( cout,"factoras");210 DEBDECLEVEL(CERR,"factoras"); 211 211 return CFFList(CFFactor(f,1)); 212 212 } … … 234 234 } 235 235 uord= Difference(uord,ord); 236 DEBOUTLN( cout, "Astar is: ", Astar);237 DEBOUTLN( cout, "ord is: ", ord);238 DEBOUTLN( cout, "uord is: ", uord);236 DEBOUTLN(CERR, "Astar is: ", Astar); 237 DEBOUTLN(CERR, "ord is: ", ord); 238 DEBOUTLN(CERR, "uord is: ", uord); 239 239 240 240 // 3) second trivial cases 241 241 if ( Astar.length() == 0 ){ 242 242 success=1; 243 DEBDECLEVEL( cout,"factoras");243 DEBDECLEVEL(CERR,"factoras"); 244 244 return CFFList(CFFactor(f,1)); 245 245 } … … 258 258 CanonicalForm substhin=CanonicalForm(vf), substback=CanonicalForm(vf); 259 259 CanonicalForm monom; 260 DEBOUTLN( cout, "substhin= ", substhin);261 DEBOUTLN( cout, "substback= ", substback);260 DEBOUTLN(CERR, "substhin= ", substhin); 261 DEBOUTLN(CERR, "substback= ", substback); 262 262 int j=1; 263 263 for ( VarlistIterator jjj=ord; jjj.hasItem(); jjj++){ … … 267 267 substhin-= monom; substback+= monom; 268 268 } 269 DEBOUTLN( cout, "substhin= ", substhin);270 DEBOUTLN( cout, "substback= ", substback);269 DEBOUTLN(CERR, "substhin= ", substhin); 270 DEBOUTLN(CERR, "substback= ", substback); 271 271 CanonicalForm fstar=f(substhin,vf); 272 DEBOUTLN( cout, "fstar= ", fstar);272 DEBOUTLN(CERR, "fstar= ", fstar); 273 273 274 274 // 7) Set up Variable ordering from ord,vf to vf,ord ! i.e. vf is the variable … … 276 276 Varlist nord=uord; 277 277 nord.append(vf); nord= Union(ord,nord); 278 DEBOUTLN( cout, " nord= ", nord);278 DEBOUTLN(CERR, " nord= ", nord); 279 279 CFList Astarnord= Astar; Astarnord.insert(fstar); 280 DEBOUTLN( cout, " Astarnord= ", Astarnord);280 DEBOUTLN(CERR, " Astarnord= ", Astarnord); 281 281 Astarnord= reorder(nord,Astarnord); 282 DEBOUTLN( cout, "original Astar= ", Astar);283 DEBOUTLN( cout, "reorderd Astar= ", Astarnord);284 DEBOUTLN( cout, " f= ", f);285 DEBOUTLN( cout, " fstar= ", fstar);282 DEBOUTLN(CERR, "original Astar= ", Astar); 283 DEBOUTLN(CERR, "reorderd Astar= ", Astarnord); 284 DEBOUTLN(CERR, " f= ", f); 285 DEBOUTLN(CERR, " fstar= ", fstar); 286 286 287 287 // 8) Compute Charset Cstar of Astar \cup { fstar } wrt. ordering {vf, ord} 288 288 PremForm Remembern; 289 289 CFList Cstar= MCharSetN(Astarnord, Remembern); 290 DEBOUTLN( cout, " Cstar= ", Cstar );291 DEBOUTLN( cout, " Factors removed= ", Remembern.FS2 );292 DEBOUTLN( cout, " Possible Factors considered:= ", Remembern.FS1 );293 DEBOUTLN( cout, " Reorderd Cstar= ", reorder(nord,Cstar));290 DEBOUTLN(CERR, " Cstar= ", Cstar ); 291 DEBOUTLN(CERR, " Factors removed= ", Remembern.FS2 ); 292 DEBOUTLN(CERR, " Possible Factors considered:= ", Remembern.FS1 ); 293 DEBOUTLN(CERR, " Reorderd Cstar= ", reorder(nord,Cstar)); 294 294 295 295 // 9) Compute Delta: the set of all irr. factors (over K_0) of initials of 296 296 // Cstar 297 297 CFList iniset= initalset1(Cstar); 298 DEBOUTLN( cout, "Set of initials: ", iniset);298 DEBOUTLN(CERR, "Set of initials: ", iniset); 299 299 CFFList Delta; 300 300 CFFList temp; … … 306 306 Delta= Union(temp,Delta); 307 307 } 308 DEBOUTLN( cout, "Delta= ", Delta);308 DEBOUTLN(CERR, "Delta= ", Delta); 309 309 310 310 // 10) Compute Psi: the irreduzible factors (over K_0) of the first polynomial … … 315 315 Psi.removeFirst(); 316 316 Psi= myDifference(Psi,Delta); 317 DEBOUTLN( cout, "Psi= ", Psi);317 DEBOUTLN(CERR, "Psi= ", Psi); 318 318 319 319 // F3: [Test quasilinearity] … … 322 322 // else D.nextpoint() -> F2 323 323 if ( isquasilinear(Cstar) ) { 324 DEBOUTLN( cout, "Cstar is quasilinear; going to F4, Cstar= ", Cstar);324 DEBOUTLN(CERR, "Cstar is quasilinear; going to F4, Cstar= ", Cstar); 325 325 goto F4; 326 326 } … … 328 328 Delta= Union(Psi,Delta); 329 329 Psi= CFFList(); 330 DEBOUTMSG( cout, "Psi.length() == 1; going to F4");330 DEBOUTMSG(CERR, "Psi.length() == 1; going to F4"); 331 331 goto F4; 332 332 } 333 333 else{ 334 334 D.nextpoint(); 335 DEBOUTMSG( cout, "Choosing next evaluation point. going to F2");335 DEBOUTMSG(CERR, "Choosing next evaluation point. going to F2"); 336 336 goto F2; 337 337 } … … 341 341 Delta= reorder(nord,Delta); 342 342 Psi= reorder(nord,Psi); 343 DEBOUTLN( cout, "Reordered: Delta= ", Delta);344 DEBOUTLN( cout, " Psi= ", Psi);343 DEBOUTLN(CERR, "Reordered: Delta= ", Delta); 344 DEBOUTLN(CERR, " Psi= ", Psi); 345 345 CanonicalForm fp; 346 346 347 DEBOUTMSG( cout, "Testing Psi: this gives irreducible Factors!");347 DEBOUTMSG(CERR, "Testing Psi: this gives irreducible Factors!"); 348 348 for (jj=Psi; jj.hasItem(); jj++){ 349 349 if ( degree(g,vf) == 1 ) { // g is linear … … 351 351 } 352 352 fp= jj.getItem().factor(); 353 DEBOUT( cout, "Calculating fp= gcd(", g);354 DEBOUT( cout, ",", fp(substback,vf));355 DEBOUT( cout, ") over K_r wrt ", vf);353 DEBOUT(CERR, "Calculating fp= gcd(", g); 354 DEBOUT(CERR, ",", fp(substback,vf)); 355 DEBOUT(CERR, ") over K_r wrt ", vf); 356 356 fp=alg_gcd(g,fp(substback,vf), as); 357 357 //fp= algcd(g,fp(substback,vf), as, oldord); 358 DEBOUTLN( cout, " = ", fp);358 DEBOUTLN(CERR, " = ", fp); 359 359 if ( degree(fp,vf) > 0 ){ //otherwise it's a constant 360 360 g= divide(g, fp,as); 361 DEBOUTLN( cout, "f/fp= ", g);361 DEBOUTLN(CERR, "f/fp= ", g); 362 362 result.append(CFFactor(fp,1)); 363 363 } 364 364 } 365 365 366 DEBOUTMSG( cout, "Testing Delta: this gives Factors (not nec. irreduzible!)");366 DEBOUTMSG(CERR, "Testing Delta: this gives Factors (not nec. irreduzible!)"); 367 367 for (jj=Delta; jj.hasItem(); jj++){ 368 368 if ( degree(g,vf) <= 1 ) { // g is linear (or a constant..) … … 370 370 } 371 371 fp= jj.getItem().factor(); 372 DEBOUT( cout, "Calculating fp= gcd(", g);373 DEBOUT( cout, ",", fp(substback,vf));374 DEBOUT( cout, ") over K_r wrt ", vf);372 DEBOUT(CERR, "Calculating fp= gcd(", g); 373 DEBOUT(CERR, ",", fp(substback,vf)); 374 DEBOUT(CERR, ") over K_r wrt ", vf); 375 375 fp= alg_gcd(g,fp(substback,vf), as); 376 376 //fp= algcd(g,fp(substback,vf), as, oldord); 377 DEBOUTLN( cout, " = ", fp);377 DEBOUTLN(CERR, " = ", fp); 378 378 if ( degree(fp,vf) > 0 ){ //otherwise it's a constant 379 379 g= divide(g, fp,as); 380 DEBOUTLN( cout, "f/fp= ", g);380 DEBOUTLN(CERR, "f/fp= ", g); 381 381 // reduceresult.append(fp); // a facctor but not nec. irreduzible 382 382 result.append(CFFactor(fp,1)); … … 396 396 if ( isquasilinear(Cstar) ){ // Cstar quasilinear => f is irreduzible 397 397 success=1; 398 DEBDECLEVEL( cout,"factoras");398 DEBDECLEVEL(CERR,"factoras"); 399 399 return CFFList(CFFactor(f,1)); 400 400 } 401 401 else { 402 DEBOUTMSG( cout, "Going to F2!");402 DEBOUTMSG(CERR, "Going to F2!"); 403 403 D.nextpoint(); // choose a new set of int's. 404 404 goto F2; … … 408 408 success=1; 409 409 result.append(CFFactor(g,1)); //append the rest 410 DEBDECLEVEL( cout,"factoras");410 DEBDECLEVEL(CERR,"factoras"); 411 411 return result; 412 412 } … … 426 426 success=1; 427 427 for ( CFFListIterator i=Factors; i.hasItem(); i++ ){ 428 CFFList coutput=factoras(i.getItem().factor(),as,csuccess);428 CFFList CERR=factoras(i.getItem().factor(),as,csuccess); 429 429 success= min(success,csuccess); 430 for ( CFFListIterator j= coutput; j.hasItem(); j++)430 for ( CFFListIterator j=CERR; j.hasItem(); j++) 431 431 Output = myappend(Output,CFFactor(j.getItem().factor(),j.getItem().exp()*i.getItem().exp())); 432 432 } … … 450 450 /* 451 451 $Log: not supported by cvs2svn $ 452 Revision 1.6 2002/08/19 11:11:30 Singular 453 * hannes/pfister: alg_gcd etc. 454 452 455 Revision 1.5 2001/06/27 13:58:05 Singular 453 456 *hannes/GP: debug newfactoras, char_series, ... -
libfac/charset/charset.cc
rdbcf42a re2ca88 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: charset.cc,v 1.1 0 2002-08-19 11:11:31Singular Exp $";4 static char * rcsid = "$Id: charset.cc,v 1.11 2006-05-16 14:46:49 Singular Exp $"; 5 5 ///////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes 7 7 #include <factory.h> 8 #ifdef HAVE_IOSTREAM 9 #define CIN std::cin 10 #else 11 #define CIN cin 12 #endif 8 13 // Factor - Includes 9 14 #include <SqrFree.h> … … 55 60 int cb; 56 61 57 DEBOUTLN( cout, "BasicSet: called with ps= ", PS);62 DEBOUTLN(CERR, "BasicSet: called with ps= ", PS); 58 63 if ( PS.length() < 2 ) return PS; 59 64 while ( ! QS.isEmpty() ) { 60 65 b = lowestRank( QS ); 61 66 cb = rank( b ); 62 DEBOUTLN( cout, "BasicSet: choose b = ", b);63 DEBOUTLN( cout, "BasicSet: it's rank = ", cb);67 DEBOUTLN(CERR, "BasicSet: choose b = ", b); 68 DEBOUTLN(CERR, "BasicSet: it's rank = ", cb); 64 69 BS=Union(CFList(b),BS);//BS.append( b ); 65 70 if ( rank( b ) == 0 ) … … 76 81 } 77 82 } 78 DEBOUTLN( cout, "BasicSet: returning bs= ", BS);83 DEBOUTLN(CERR, "BasicSet: returning bs= ", BS); 79 84 return BS; 80 85 } … … 109 114 CFList QS = PS, RS = PS, CS, OLDCS; 110 115 111 DEBOUTLN( cout, "MCharSetN: called with ps= ", PS);116 DEBOUTLN(CERR, "MCharSetN: called with ps= ", PS); 112 117 while ( ! RS.isEmpty() ) { 113 118 CS = BasicSet( QS ); 114 119 OLDCS=CS; 115 DEBOUTLN( cout, "MCharSetN: CS= ", CS);120 DEBOUTLN(CERR, "MCharSetN: CS= ", CS); 116 121 // if ( getNumVars(CS.getFirst()) > 1 ){ 117 122 // //CS = removecontent(CS, Remembern); 118 123 // #ifdef MCHARSETNDEBUG 119 // cout << "MCharSetN: CS= " << CS << endl;124 // CERR << "MCharSetN: CS= " << CS << "\n"; 120 125 // #endif 121 126 // } 122 127 Remembern.FS1 = Union(Remembern.FS1, initalset1(CS)); 123 DEBOUTLN( cout, "MCharSetN: Remembern.FS1= ", Remembern.FS1);124 DEBOUTLN( cout, "MCharSetN: Remembern.FS2= ", Remembern.FS2);128 DEBOUTLN(CERR, "MCharSetN: Remembern.FS1= ", Remembern.FS1); 129 DEBOUTLN(CERR, "MCharSetN: Remembern.FS2= ", Remembern.FS2); 125 130 RS = CFList(); 126 131 if ( rank( CS.getFirst() ) != 0 ) { 127 132 CFList D = Difference( QS, CS ); 128 DEBOUT( cout, "MCharSetN: Difference( ", QS);129 DEBOUT( cout, " , ", CS);130 DEBOUTLN( cout, " ) = ", D);131 // cout << "MCharSetN: Difference( " << QS << " , " << CS << " ) = " << D << endl;133 DEBOUT(CERR, "MCharSetN: Difference( ", QS); 134 DEBOUT(CERR, " , ", CS); 135 DEBOUTLN(CERR, " ) = ", D); 136 //CERR << "MCharSetN: Difference( " << QS << " , " << CS << " ) = " << D << "\n"; 132 137 //PremForm Oldremember=Remembern; 133 138 //PremForm Newremember=Remembern; 134 139 for ( CFListIterator i = D; i.hasItem(); ++i ) { 135 140 CanonicalForm r = Prem( i.getItem(), CS ); 136 DEBOUT( cout,"MCharSetN: Prem(", i.getItem() );137 DEBOUT( cout, ",", CS);138 DEBOUTLN( cout,") = ", r);139 // cout << "MCharSetN: Prem("<< i.getItem() << "," << CS << ") = " << r << endl;141 DEBOUT(CERR,"MCharSetN: Prem(", i.getItem() ); 142 DEBOUT(CERR, ",", CS); 143 DEBOUTLN(CERR,") = ", r); 144 //CERR << "MCharSetN: Prem("<< i.getItem() << "," << CS << ") = " << r << "\n"; 140 145 if ( r != 0 ){ 141 146 //removefactor( r, Newremember ); … … 149 154 } 150 155 if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1)); 151 DEBOUTLN( cout, "MCharSetN: RS= ", RS);156 DEBOUTLN(CERR, "MCharSetN: RS= ", RS); 152 157 //QS = Union( QS, RS ); 153 158 QS = Union(OLDCS,RS); 154 DEBOUTLN( cout, "MCharSetN: QS= Union(QS,RS)= ", QS);159 DEBOUTLN(CERR, "MCharSetN: QS= Union(QS,RS)= ", QS); 155 160 } 156 161 else{ return CFList(CanonicalForm(1)); } 157 162 } 158 DEBOUTLN( cout, "MCharSetN: Removed factors: ", Remembern.FS2);159 DEBOUTLN( cout, "MCharSetN: Remembern.FS1: ", Remembern.FS1);163 DEBOUTLN(CERR, "MCharSetN: Removed factors: ", Remembern.FS2); 164 DEBOUTLN(CERR, "MCharSetN: Remembern.FS1: ", Remembern.FS1); 160 165 161 166 return CS; … … 168 173 CFList rs= remsetb(Difference(PS,cs),cs); 169 174 170 DEBOUTLN( cout, "mcharset: cs= ", cs);171 DEBOUTLN( cout, "mcharset: rs= ", rs);175 DEBOUTLN(CERR, "mcharset: cs= ", cs); 176 DEBOUTLN(CERR, "mcharset: rs= ", rs); 172 177 if ( rs.length() > 0 ) 173 178 cs= mcharset(Union(PS,Union(cs,rs)), Remembern); … … 182 187 while ( ! RS.isEmpty() ) { 183 188 CS = BasicSet( QS ); 184 DEBOUTLN( cout, "CharSet: CS= ", CS);189 DEBOUTLN(CERR, "CharSet: CS= ", CS); 185 190 RS = CFList(); 186 191 if ( rank( CS.getFirst() ) != 0 ) { … … 343 348 choosefrom(){ 344 349 int choice; 345 cout<< "choose from qhi! ->";346 cin>> choice;350 CERR << "choose from qhi! ->"; 351 CIN >> choice; 347 352 return choice; 348 353 } … … 353 358 ListCFList output; 354 359 355 cout << "Sort: list to sort is: " << list_to_sort << endl;360 CERR << "Sort: list to sort is: " << list_to_sort << "\n"; 356 361 for (int i=1; i<= number; i++){ 357 cout << " Next elem = "; cin>> nr;362 CERR << " Next elem = "; CIN >> nr; 358 363 output.append(getItemNr(nr,list_to_sort)); 359 364 } … … 379 384 #endif 380 385 381 DEBOUTMSG( cout, rcsid);382 // cout << getCharacteristic() << endl;386 DEBOUTMSG(CERR, rcsid); 387 // CERR << getCharacteristic() << "\n"; 383 388 for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ ) 384 389 if ( level(Ps.getItem() ) > highestlevel ) highestlevel = level(Ps.getItem()) ; 385 390 // for ( int xx=1; xx <= highestlevel; xx++) 386 // cout<< Variable(xx) ;387 // cout << endl;391 // CERR << Variable(xx) ; 392 // CERR << "\n"; 388 393 // for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ ) 389 // cout << Ps.getItem() << ", " ;//<< endl;390 // cout << endl;394 // CERR << Ps.getItem() << ", " ;//<< "\n"; 395 // CERR << "\n"; 391 396 while ( ! qhi.isEmpty() ) { 392 397 qhi=sort(qhi); 393 DEBOUTLN( cout, "qhi is: ", qhi);398 DEBOUTLN(CERR, "qhi is: ", qhi); 394 399 #ifdef EXPERIMENTAL 395 400 choice=choosefrom(); 396 cout <<"/n Choose " << choice << endl;401 CERR <<"/n Choose " << choice << "\n"; 397 402 qs= getItemNr(choice, qhi); 398 403 #else 399 404 qs=qhi.getFirst(); 400 405 #endif 401 DEBOUTLN( cout, "qs is: ", qs);402 DEBOUTLN( cout, "ppi is: ", ppi);406 DEBOUTLN(CERR, "qs is: ", qs); 407 DEBOUTLN(CERR, "ppi is: ", ppi); 403 408 ListCFList ppi1,ppi2; 404 409 select(ppi,qs.length(),ppi1,ppi2); 405 DEBOUTLN( cout, "ppi1 is: ", ppi1);406 DEBOUTLN( cout, "ppi2 is: ", ppi2);410 DEBOUTLN(CERR, "ppi1 is: ", ppi1); 411 DEBOUTLN(CERR, "ppi2 is: ", ppi2); 407 412 qqi = MyUnion(ppi2,qqi); 408 DEBOUTLN( cout, "qqi is: ", qqi);413 DEBOUTLN(CERR, "qqi is: ", qqi); 409 414 if ( nr_of_iteration == 0 ){ nr_of_iteration += 1; ppi = ListCFList(); } 410 415 else{ nr_of_iteration += 1; ppi = MyUnion(ListCFList(qs),ppi1); } 411 DEBOUTLN( cout,"ppi is: ", ppi);416 DEBOUTLN(CERR,"ppi is: ", ppi); 412 417 PremForm Remembern; 413 418 cs = MCharSetN(qs,Remembern); 414 DEBOUTLN( cout, "cs is: ", cs);415 DEBOUTLN( cout, "factorset is: ", Remembern.FS2);419 DEBOUTLN(CERR, "cs is: ", cs); 420 DEBOUTLN(CERR, "factorset is: ", Remembern.FS2); 416 421 cs = removecontent(cs,Remembern); 417 422 factorset=Remembern.FS2; 418 DEBOUTLN( cout, "cs (after removecontent) is: ", cs);419 DEBOUTLN( cout, "factorset is: ", factorset);423 DEBOUTLN(CERR, "cs (after removecontent) is: ", cs); 424 DEBOUTLN(CERR, "factorset is: ", factorset); 420 425 // Hier: removecontent einfuegen!!!! 421 426 if ( cls(cs.getFirst()) > 0 ){ … … 426 431 // INTERRUPTHANDLER 427 432 428 DEBOUTLN( cout, "ts is: ", ts);429 DEBOUTLN( cout, "ts2 is: ", ts2);433 DEBOUTLN(CERR, "ts is: ", ts); 434 DEBOUTLN(CERR, "ts2 is: ", ts2); 430 435 // next is preliminary: should be ==0 431 436 if ( ts2 <= 0 ){ //irreducible 432 437 if ( ! subset(cs,qs) ){ 433 DEBOUTMSG( cout, "cs is not a subset of qs");438 DEBOUTMSG(CERR, "cs is not a subset of qs"); 434 439 cs = charseta(Union(qs,cs)); 435 DEBOUTLN( cout, "new cs is: ", cs);440 DEBOUTLN(CERR, "new cs is: ", cs); 436 441 } 437 442 if ( ! member(cs,pi) ){ 438 443 pi = MyUnion(pi, ListCFList(cs)); 439 DEBOUTMSG( cout, "cs is not a member of pi");440 DEBOUTLN( cout, "pi is: ", pi);444 DEBOUTMSG(CERR, "cs is not a member of pi"); 445 DEBOUTLN(CERR, "pi is: ", pi); 441 446 if ( cls(cs.getFirst()) > 0 ){ 442 447 ts = irras(cs,ts2,reducible); … … 446 451 // INTERRUPTHANDLER 447 452 448 DEBOUTLN( cout, "ts is: ", ts);449 DEBOUTLN( cout, "ts2 is: ", ts2);453 DEBOUTLN(CERR, "ts is: ", ts); 454 DEBOUTLN(CERR, "ts2 is: ", ts2); 450 455 // next is preliminary: should be ==0 451 456 if ( ts2 <= 0 ){ //irreducible 452 457 qsi = MyUnion(qsi,ListCFList(cs)); 453 DEBOUTLN( cout, "qsi is: ", qsi);458 DEBOUTLN(CERR, "qsi is: ", qsi); 454 459 if ( cs.length() == highestlevel ){ 455 DEBOUTLN( cout, "cs.length() == nops(ord) :", cs.length());460 DEBOUTLN(CERR, "cs.length() == nops(ord) :", cs.length()); 456 461 is = factorps(factorset); 457 462 } 458 463 else{ 459 DEBOUT( cout,"cs.length() != nops(ord) :", cs.length());460 DEBOUTLN( cout, " nops(ord)= ", highestlevel);464 DEBOUT(CERR,"cs.length() != nops(ord) :", cs.length()); 465 DEBOUTLN(CERR, " nops(ord)= ", highestlevel); 461 466 is = Union(initalset1(cs),factorps(factorset)); 462 467 } 463 DEBOUTLN( cout, "is is: ", is);468 DEBOUTLN(CERR, "is is: ", is); 464 469 iss = adjoin(is,qs,qqi); 465 DEBOUTLN( cout, "iss is: ", iss);470 DEBOUTLN(CERR, "iss is: ", iss); 466 471 } 467 472 } … … 469 474 } 470 475 else{ 471 DEBOUTMSG( cout, "cs is a member of pi");476 DEBOUTMSG(CERR, "cs is a member of pi"); 472 477 iss = adjoin(factorps(factorset),qs,qqi); } 473 DEBOUTLN( cout, "iss is: ", iss);474 DEBOUTLN( cout, " factorps(factorset)= ", factorps(factorset));475 DEBOUTLN( cout, " qs= ", qs);476 DEBOUTLN( cout, " qqi= ", qqi);478 DEBOUTLN(CERR, "iss is: ", iss); 479 DEBOUTLN(CERR, " factorps(factorset)= ", factorps(factorset)); 480 DEBOUTLN(CERR, " qs= ", qs); 481 DEBOUTLN(CERR, " qqi= ", qqi); 477 482 } 478 483 // next is preliminary: should be !=0 479 484 if ( ts2 > 0 ){ 480 485 is = factorps(factorset); 481 DEBOUTLN( cout, "is is: ", is);486 DEBOUTLN(CERR, "is is: ", is); 482 487 if ( ts2 > 1 ){ 483 488 // setup cst: need it later for adjoinb … … 491 496 } 492 497 else{ iss = adjoin(Union(is,ts),qs,qqi); } 493 DEBOUTLN( cout, "iss is: ", iss);498 DEBOUTLN(CERR, "iss is: ", iss); 494 499 } 495 500 } 496 501 else{ 497 502 iss = adjoin(factorps(factorset),qs,qqi); 498 DEBOUTMSG( cout, "case: cs is a constant.");499 DEBOUTLN( cout, " qs = ", qs);500 DEBOUTLN( cout, " qqi = ", qqi);501 DEBOUTLN( cout, " iss = adjoin(factorps(factorset),qs,qqi) = ",iss);503 DEBOUTMSG(CERR, "case: cs is a constant."); 504 DEBOUTLN(CERR, " qs = ", qs); 505 DEBOUTLN(CERR, " qqi = ", qqi); 506 DEBOUTLN(CERR, " iss = adjoin(factorps(factorset),qs,qqi) = ",iss); 502 507 } 503 508 if ( qhi.length() > 1 ){ qhi.removeFirst(); qhi = MyUnion(qhi,iss); } 504 509 else{ qhi = iss; } 505 DEBOUTLN( cout, "iss is: ", iss);510 DEBOUTLN(CERR, "iss is: ", iss); 506 511 } 507 512 if ( ! qsi.isEmpty() ){ 508 DEBOUTLN( cout, "qsi before contract= ", qsi);513 DEBOUTLN(CERR, "qsi before contract= ", qsi); 509 514 if ( opt == 0 ){ 510 515 return contract( qsi ); … … 534 539 535 540 ja = 0; 536 DEBOUTLN( cout, "irras: called with: AS= ", AS);541 DEBOUTLN(CERR, "irras: called with: AS= ", AS); 537 542 for ( i=AS; i.hasItem(); i++ ){ 538 543 elem = i.getItem(); 539 544 nr += 1; 540 DEBOUT( cout, "irras: factoring: ", elem);545 DEBOUT(CERR, "irras: factoring: ", elem); 541 546 if ( degree(elem) > 1 ) // linear poly's are irreduzible 542 547 { … … 547 552 qs.insert(CFFactor(CanonicalForm(1),1)); 548 553 } 549 DEBOUTLN( cout, " = ", qs);554 DEBOUTLN(CERR, " = ", qs); 550 555 // INTERRUPTHANDLER 551 556 if ( interrupt_handle() ) return CFList() ; … … 553 558 qs.removeFirst(); 554 559 if ( (qs.length() >= 2 ) || (qs.getFirst().exp() > 1)){ 555 DEBOUTLN( cout, "irras: Setting ind=0, ja= ", nr);560 DEBOUTLN(CERR, "irras: Setting ind=0, ja= ", nr); 556 561 ja=nr; ind=0; reducible= elem; 557 562 break; … … 559 564 // else{ as.append(elem) ; } 560 565 } 561 // cout << "ind= " << ind << endl;566 // CERR << "ind= " << ind << "\n"; 562 567 if ( (ind == 1) ){ //&& ( as.length() > 1) ){ 563 568 if ( irreducible(AS) ){ // as quasilinear? => irreducible! 564 569 ja = 0; 565 DEBOUTLN( cout, "as is irreducible. as= ", AS);570 DEBOUTLN(CERR, "as is irreducible. as= ", AS); 566 571 } 567 572 else { … … 572 577 if ( degree(i.getItem()) > 1 ){// search for a non linear elem 573 578 elem=i.getItem(); 574 // cout << "f= " << elem << endl;575 // cout << "as= " << as << endl;579 // CERR << "f= " << elem << "\n"; 580 // CERR << "as= " << as << "\n"; 576 581 qs= newfactoras(elem,as,success); 577 // cout << "irras:newfactoras qs= " << qs << endl;582 // CERR << "irras:newfactoras qs= " << qs << "\n"; 578 583 // qs= factoras(elem,as,success); 579 // cout << "irras:factoras qs= " << qs << endl;584 // CERR << "irras:factoras qs= " << qs << "\n"; 580 585 if ( qs.length() > 1 || qs.getFirst().exp() > 1 ){ //found elem is reducible 581 586 reducible=elem; … … 594 599 /* 595 600 $Log: not supported by cvs2svn $ 601 Revision 1.10 2002/08/19 11:11:31 Singular 602 * hannes/pfister: alg_gcd etc. 603 596 604 Revision 1.9 2001/08/08 14:26:54 Singular 597 605 *hannes: Dan's HAVE_SINGULAR_ERROR -
libfac/charset/csutil.cc
rdbcf42a re2ca88 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: csutil.cc,v 1.1 1 2006-05-16 13:48:13Singular Exp $";4 static char * rcsid = "$Id: csutil.cc,v 1.12 2006-05-16 14:46:49 Singular Exp $"; 5 5 ///////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 48 48 f = i.getItem(); ++i; 49 49 while ( i.hasItem() ) { 50 // cout<< "comparing " << f << " and " << i.getItem()51 // << " == " << lowerRank( i.getItem(), f, ind ) << endl;50 //CERR << "comparing " << f << " and " << i.getItem() 51 // << " == " << lowerRank( i.getItem(), f, ind ) << "\n"; 52 52 if ( lowerRank( i.getItem(), f, ind ) ) { 53 53 if ( ind ){ … … 56 56 57 57 // Have to further compare number of terms! 58 // cout<< "compare terms! f= " << Flist.length() << " item= "59 // << Itemlist.length() << endl;58 //CERR << "compare terms! f= " << Flist.length() << " item= " 59 // << Itemlist.length() <<"\n"; 60 60 if ( Itemlist.length() < Flist.length()) f = i.getItem(); 61 61 ind=0; … … 129 129 else { l = 1; } 130 130 while ( ( dg <= df ) && ( ff != ff.genZero()) ){ 131 // cout << "Start gcd..." << endl;131 // CERR << "Start gcd..." << "\n"; 132 132 test = gcd(l,LC(ff)); 133 // cout << "gcd(" << l << "," << LC(ff) << ")= " << test << endl;133 //CERR << "gcd(" << l << "," << LC(ff) << ")= " << test << "\n"; 134 134 lu = l/test; lv = LC(ff)/test; 135 135 t = power(v,df-dg) * gg * lv; … … 216 216 else 217 217 r= Sprem(ff,f,m,q); //result in q, ignore r,m 218 // cout << "r= " << r << " , m= " << m << " , q= " << q << endl;218 //CERR << "r= " << r << " , m= " << m << " , q= " << q << "\n"; 219 219 r= Prem(q,as); 220 // cout << "r= " << r << endl;220 //CERR << "r= " << r << "\n"; 221 221 //out_cf(" ->",r,"\n"); 222 222 return r; … … 233 233 On(SW_RATIONAL); 234 234 CanonicalForm temp= mapinto(rem); 235 // cout << "temp= " << temp << endl;236 // cout << "lc(temp)= " << lc(temp) << endl;237 // cout << "temp/lc(temp)= " << temp/lc(temp) << endl;238 // cout << "num(rem/lc(rem))= " << num(rem/lc(rem)) << endl;235 // CERR << "temp= " << temp << "\n"; 236 // CERR << "lc(temp)= " << lc(temp) << "\n"; 237 // CERR << "temp/lc(temp)= " << temp/lc(temp) << "\n"; 238 // CERR << "num(rem/lc(rem))= " << num(rem/lc(rem)) << "\n"; 239 239 temp= bCommonDen(temp/lc(temp))*(temp/lc(temp)); 240 240 Off(SW_RATIONAL); … … 252 252 CFListIterator i = L; 253 253 for ( i.lastItem(); i.hasItem(); i-- ){ 254 // cout<< " PREM: Prem(" << rem << "," ;254 //CERR << " PREM: Prem(" << rem << "," ; 255 255 rem = Prem( rem, i.getItem() ); 256 // cout << " PREM: Prem(" << rem << "," << i.getItem() << ") = " << rem << endl;256 //CERR << " PREM: Prem(" << rem << "," << i.getItem() << ") = " << rem << "\n"; 257 257 } 258 258 return myfitting(rem); … … 314 314 if (!(j.coeff().isOne()) ) count += 1; 315 315 // if ( init != 1 ){ 316 // cout << "nopower: f is " << init << endl;317 // cout << "nopower: count is " << count << endl;}316 // CERR << "nopower: f is " << init << "\n"; 317 // CERR << "nopower: count is " << count << "\n";} 318 318 if ( count > 1 ) sqrfreelist = CFFList( CFFactor(init,1)); 319 319 else { … … 395 395 } 396 396 } 397 // cout << "Remembern.FS1 = " << Remembern.FS1 << endl;398 // cout << "Remembern.FS2 = " << Remembern.FS2 << endl;397 // CERR << "Remembern.FS1 = " << Remembern.FS1 << "\n"; 398 // CERR << "Remembern.FS2 = " << Remembern.FS2 << "\n"; 399 399 // Remembern.FS1 = Difference(Remembern.FS1, Remembern.FS2); 400 // cout << " New Remembern.FS1 = " << Remembern.FS1 << endl;400 // CERR << " New Remembern.FS1 = " << Remembern.FS1 << "\n"; 401 401 } 402 402 … … 529 529 // AS is given by AS = { A1, A2, .. Ar }, d_i = degree(Ai) 530 530 531 DEBOUTMSG( cout, rcsid);531 DEBOUTMSG(CERR, rcsid); 532 532 // 1) we test: if d_i > 1, d_j =1 for all j<>i, then AS is irreducible. 533 533 bool deg1=1; … … 604 604 subset( const CFList &PS, const CFList &CS ){ 605 605 606 // cout << "subset: called with: " << PS << " " << CS << endl;606 // CERR << "subset: called with: " << PS << " " << CS << "\n"; 607 607 for ( CFListIterator i=PS; i.hasItem(); i++ ) 608 608 if ( ! member(i.getItem(), CS) ) { 609 // cout << "subset: " << i.getItem() << " is not a member of " << CS << endl;609 // CERR << "subset: " << i.getItem() << " is not a member of " << CS << "\n"; 610 610 return 0; 611 611 } … … 873 873 /* 874 874 $Log: not supported by cvs2svn $ 875 Revision 1.11 2006/05/16 13:48:13 Singular 876 *hannes: gcc 4.1 fix: factory changes 877 875 878 Revision 1.10 2006/04/28 13:45:29 Singular 876 879 *hannes: better tests for 0, 1 -
libfac/charset/reorder.cc
rdbcf42a re2ca88 12 12 ///////////////////////////////////////////////////////////// 13 13 // emacs edit mode for this file is -*- C++ -*- 14 static char * rcsid = "$Id: reorder.cc,v 1. 3 1997-09-12 07:19:44Singular Exp $";14 static char * rcsid = "$Id: reorder.cc,v 1.4 2006-05-16 14:46:49 Singular Exp $"; 15 15 //////////////////////////////////////////////////////////// 16 16 // FACTORY - Includes … … 241 241 while ( gap <= n) gap = __INIT_GAP__ * gap+1; 242 242 gap /= __INIT_GAP__; 243 DEBOUTLN( cout, "gap is ", gap);243 DEBOUTLN(CERR, "gap is ", gap); 244 244 245 245 while ( gap > 0 ){ … … 249 249 if (degord(v[j],temp, PS, A,B,C,D,E,F,G)) break; 250 250 v[j+gap] = v[j]; 251 // cout << "v[" << j+gap << "]= " << v[j+gap] << endl;251 //CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n"; 252 252 } 253 253 v[j+gap] = temp; 254 // cout << "v[" << j+gap << "]= " << v[j+gap] << endl;254 //CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n"; 255 255 } 256 256 gap /= __INIT_GAP__; … … 259 259 for (i=0; i<= n-1; i++) 260 260 output.append(v[i]); 261 DEBOUTLN( cout, "A= ", A); DEBOUTLN(cout, "B= ", B);262 DEBOUTLN( cout, "C= ", C); DEBOUTLN(cout, "D= ", D);263 DEBOUTLN( cout, "E= ", E); DEBOUTLN(cout, "F= ", F);264 DEBOUTLN( cout, "G= ", G);261 DEBOUTLN(CERR, "A= ", A); DEBOUTLN(CERR, "B= ", B); 262 DEBOUTLN(CERR, "C= ", C); DEBOUTLN(CERR, "D= ", D); 263 DEBOUTLN(CERR, "E= ", E); DEBOUTLN(CERR, "F= ", F); 264 DEBOUTLN(CERR, "G= ", G); 265 265 return output; 266 266 } … … 273 273 Varlist oldorder, reorder, difference; 274 274 275 DEBINCLEVEL( cout, "neworder");276 DEBOUTMSG( cout, rcsid);275 DEBINCLEVEL(CERR, "neworder"); 276 DEBOUTMSG(CERR, rcsid); 277 277 TIMING_START(neworder_time); 278 278 279 279 int highest_level= level(get_max_var(PS)); 280 DEBOUTLN( cout, "neworder: highest_level= ", highest_level);281 DEBOUTLN( cout, "neworder: that is variable ", Variable(highest_level));280 DEBOUTLN(CERR, "neworder: highest_level= ", highest_level); 281 DEBOUTLN(CERR, "neworder: that is variable ", Variable(highest_level)); 282 282 283 283 // set up oldorder and first criterion: only_in_one … … 286 286 CFList is_one= only_in_one(PS1, Variable(i)); 287 287 if ( is_one.length() == 1 ){ 288 DEBOUTLN( cout, "Found a variable which is in only one Polynomial: ",288 DEBOUTLN(CERR, "Found a variable which is in only one Polynomial: ", 289 289 Variable(i)); 290 DEBOUTLN( cout, ".... in the Polynomial: ", is_one.getFirst());290 DEBOUTLN(CERR, ".... in the Polynomial: ", is_one.getFirst()); 291 291 reorder.insert(Variable(i)); 292 292 PS1 = Difference(PS1, is_one); 293 DEBOUTLN( cout, "New cutted list is: ", PS1);293 DEBOUTLN(CERR, "New cutted list is: ", PS1); 294 294 } 295 295 else if ( is_one.length() == 0 ){ 296 DEBOUTLN( cout, "Found a variable which is in no polynomial: ",296 DEBOUTLN(CERR, "Found a variable which is in no polynomial: ", 297 297 Variable(i)); 298 DEBOUTMSG( cout, "... assigning it the highest level.");298 DEBOUTMSG(CERR, "... assigning it the highest level."); 299 299 reorder.append(Variable(i)); // assigne it the highest level 300 300 PS1 = Difference(PS1, is_one); … … 302 302 } 303 303 difference = Difference(oldorder,reorder); 304 DEBOUTLN( cout, "Missing variables are: ", difference);304 DEBOUTLN(CERR, "Missing variables are: ", difference); 305 305 // rearrange the ordering of the variables! 306 306 difference = reorderb(difference, PS, highest_level); 307 DEBOUTLN( cout, "second criterion gives: ", difference);307 DEBOUTLN(CERR, "second criterion gives: ", difference); 308 308 reorder = Union(reorder, difference); 309 DEBOUTLN( cout, "old order was: ", oldorder);310 DEBOUTLN( cout, "New order will be: ", Union(reorder, Difference(oldorder,reorder)));311 DEBDECLEVEL( cout, "neworder");309 DEBOUTLN(CERR, "old order was: ", oldorder); 310 DEBOUTLN(CERR, "New order will be: ", Union(reorder, Difference(oldorder,reorder))); 311 DEBDECLEVEL(CERR, "neworder"); 312 312 TIMING_END(neworder_time); 313 313 … … 372 372 v[i]= level(j.getItem()); i++; 373 373 } 374 DEBOUTLN( cout, "reorder: Original ps= ", ps);374 DEBOUTLN(CERR, "reorder: Original ps= ", ps); 375 375 // reorder: 376 376 for (i=1; i <= n; i++) 377 377 ps=swapvar(ps,Variable(v[i]),Variable(n+i)); 378 DEBOUTLN( cout, "reorder: Reorganized ps= ", ps);378 DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 379 379 return ps; 380 380 } … … 390 390 v[i]= level(j.getItem()); i++; 391 391 } 392 DEBOUTLN( cout, "reorder: Original ps= ", ps);392 DEBOUTLN(CERR, "reorder: Original ps= ", ps); 393 393 // reorder: 394 394 for (i=1; i <= n; i++) 395 395 ps=swapvar(ps,Variable(v[i]),Variable(n+i)); 396 DEBOUTLN( cout, "reorder: Reorganized ps= ", ps);396 DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 397 397 return ps; 398 398 } … … 408 408 /* 409 409 $Log: not supported by cvs2svn $ 410 Revision 1.3 1997/09/12 07:19:44 Singular 411 * hannes/michael: libfac-0.3.0 412 410 413 Revision 1.2 1997/04/25 22:53:25 michael 411 414 changed cerr and cout messages for use with Singular -
libfac/factor/Factor.cc
rdbcf42a re2ca88 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.2 2 2006-04-28 13:46:29 Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.23 2006-05-16 14:46:49 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 /////////////////////////////////////////////////////////////////////////////// … … 7 7 #include <factory.h> 8 8 #ifndef NOSTREAMIO 9 #ifdef HAVE_IOSTREAM 10 #include <iostream> 11 #define CERR std::cerr 12 #define CIN std::cin 13 #elif defined(HAVE_IOSTREAM_H) 9 14 #include <iostream.h> 15 #define CERR cerr 16 #define CIN cin 17 #endif 10 18 #endif 11 19 // Factor - Includes … … 106 114 remlc= LC(f,n); mainvar = n; 107 115 if ( totaldegree(remlc)==0 ){ remlc=f.genOne() ; } 108 DEBOUTLN( cout, "remlc= " , remlc);116 DEBOUTLN(CERR, "remlc= " , remlc); 109 117 for ( int i=n-1; i>=1; i-- ){ 110 118 newlc= LC(f,i); 111 119 if ( totaldegree(newlc)==0 ){ newlc=f.genOne() ; } 112 DEBOUTLN( cout, "newlc= " , newlc);120 DEBOUTLN(CERR, "newlc= " , newlc); 113 121 if ( (remlc.isOne()) && (newlc.isOne()) ){ // take care of the degrees 114 122 if ( degree(f,i) < degree(f,mainvar) ){ … … 227 235 else{ // lt is a) a product or b) a sum of terms 228 236 if ( lt_is_product(lt) ){ // case a) 229 DEBOUTLN( cout, "lt_is_product: ", lt);237 DEBOUTLN(CERR, "lt_is_product: ", lt); 230 238 savelc= content(lt) ; // can we simplify to savelc= lc(lt); ? 231 239 while ( getNumVars(savelc) != 0 ) … … 255 263 } 256 264 else{ // case b) 257 DEBOUTLN( cout, "lt_is_sum: ", lt);265 DEBOUTLN(CERR, "lt_is_sum: ", lt); 258 266 CanonicalForm save_denumerator= 1; 259 267 for ( i=TheList; i.hasItem(); i++ ){ … … 272 280 #else 273 281 #ifndef NOSTREAMIO 274 cerr<< "libfac: ERROR: not_monic1: case lt is a sum.\n"275 << rcsid << errmsg << endl;282 CERR << "libfac: ERROR: not_monic1: case lt is a sum.\n" 283 << rcsid << errmsg << "\n"; 276 284 #endif 277 285 #endif … … 291 299 #else 292 300 #ifndef NOSTREAMIO 293 cerr<< "libfac: ERROR: not_monic2: case lt is a sum.\n"294 << rcsid << errmsg << endl;301 CERR << "libfac: ERROR: not_monic2: case lt is a sum.\n" 302 << rcsid << errmsg << "\n"; 295 303 #endif 296 304 #endif … … 299 307 } 300 308 } 301 DEBOUTLN( cout,"Returnlist: ", Returnlist);309 DEBOUTLN(CERR,"Returnlist: ", Returnlist); 302 310 return Returnlist; 303 311 } … … 354 362 Variable x(nr_of_variable); 355 363 356 DEBOUTLN( cout, "specialize_variable: called with: ", f);364 DEBOUTLN(CERR, "specialize_variable: called with: ", f); 357 365 for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){ 358 DEBOUTLN( cout, " specialize_variable: trying: ", Extgenerator.item());366 DEBOUTLN(CERR, " specialize_variable: trying: ", Extgenerator.item()); 359 367 g= f( Extgenerator.item(), x ); 360 DEBOUTLN( cout, " specialize_variable: resulting g= ", g);368 DEBOUTLN(CERR, " specialize_variable: resulting g= ", g); 361 369 if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){ 362 370 Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair … … 373 381 Variable x(nr_of_variable); 374 382 375 DEBOUTLN( cout, "specialize_variable: called with: ", f);383 DEBOUTLN(CERR, "specialize_variable: called with: ", f); 376 384 for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){ 377 DEBOUTLN( cout, " specialize_variable: trying: ", Extgenerator.item());385 DEBOUTLN(CERR, " specialize_variable: trying: ", Extgenerator.item()); 378 386 g= f( Extgenerator.item(), x ); 379 DEBOUTLN( cout, " specialize_variable: resulting g= ", g);387 DEBOUTLN(CERR, " specialize_variable: resulting g= ", g); 380 388 if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){ 381 389 Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair … … 402 410 #else 403 411 #ifndef NOSTREAMIO 404 cerr<< "libfac: evaluate: " << Extension << " not inFF() or inGF() !"405 << endl;412 CERR << "libfac: evaluate: " << Extension << " not inFF() or inGF() !" 413 << "\n"; 406 414 #endif 407 415 #endif … … 433 441 434 442 if ( degree(Extension) > 0 ){ // working over Extensions 435 DEBOUTLN( cout, "try_specializePoly: working over Extensions: ", Extension);443 DEBOUTLN(CERR, "try_specializePoly: working over Extensions: ", Extension); 436 444 AlgExtGenerator g(Extension); 437 445 for ( int k=i ; k<j ; k++ ){ // try to find specialization for all … … 444 452 else{ // working over the ground-field 445 453 FFGenerator g; 446 DEBOUTMSG( cout, "try_specializePoly: working over the ground-field.");454 DEBOUTMSG(CERR, "try_specializePoly: working over the ground-field."); 447 455 for ( int k=i ; k<j ; k++ ){ 448 456 ok= specialize_variable( ff, deg, Substitutionlist, k, j, g ); … … 475 483 #else 476 484 #ifndef NOSTREAMIO 477 cerr<< "libfac: spezializePoly ERROR: Working over given extension-field not yet implemented!\n"478 << rcsid << errmsg << endl;485 CERR << "libfac: spezializePoly ERROR: Working over given extension-field not yet implemented!\n" 486 << rcsid << errmsg << "\n"; 479 487 #endif 480 488 #endif … … 511 519 #else 512 520 #ifndef NOSTREAMIO 513 cerr<< "libfac: evaluate: " << Extension << " not inFF() or inGF() !"514 << endl;521 CERR << "libfac: evaluate: " << Extension << " not inFF() or inGF() !" 522 << "\n"; 515 523 #endif 516 524 #endif … … 610 618 else{ 611 619 if (Extension.level()<0) 612 DEBOUTLN( cout, "Univ. Factorization over extension of degree ",620 DEBOUTLN(CERR, "Univ. Factorization over extension of degree ", 613 621 degree(getMipo(Extension,'x')) ); 614 622 else 615 DEBOUTLN( cout, "Univ. Factorization over extension of level ??",623 DEBOUTLN(CERR, "Univ. Factorization over extension of level ??", 616 624 Extension.level()); 617 625 TIMING_START(evaluate_time); … … 643 651 644 652 if ( oldmainvar != mainvar ){ 645 DEBOUTSL( cout); DEBOUT(cout,"Swapped poly ", F);646 DEBOUT( cout, " in ", f); DEBOUTNL(cout);647 DEBOUTSL( cout); DEBOUT(cout,"Swapped ", oldmainvar );648 DEBOUT( cout, " <-- ", mainvar ); DEBOUT(cout, " Mainvar= ", f.mvar());649 DEBOUTNL( cout);653 DEBOUTSL(CERR); DEBOUT(CERR,"Swapped poly ", F); 654 DEBOUT(CERR, " in ", f); DEBOUTNL(CERR); 655 DEBOUTSL(CERR); DEBOUT(CERR,"Swapped ", oldmainvar ); 656 DEBOUT(CERR, " <-- ", mainvar ); DEBOUT(CERR, " Mainvar= ", f.mvar()); 657 DEBOUTNL(CERR); 650 658 ff = f.deriv(); 651 659 TIMING_START(discr_time); … … 653 661 TIMING_END(discr_time); 654 662 if ( !(ffuni.isOne()) ){ //discriminante nonzero: split poly 655 DEBOUTLN( cout,"Nontrivial GCD of f= ", f);656 DEBOUTLN( cout," and @f= ", ff);657 DEBOUTLN( cout," GCD(f,@f)= ", ffuni);663 DEBOUTLN(CERR,"Nontrivial GCD of f= ", f); 664 DEBOUTLN(CERR," and @f= ", ff); 665 DEBOUTLN(CERR," GCD(f,@f)= ", ffuni); 658 666 ff=f/ffuni; 659 667 CFFList Outputlist_a, Outputlist_b; 660 668 Outputlist_a = Factorized(ff,alpha); 661 DEBOUTLN( cout, "Outputlist_a = ", Outputlist_a);669 DEBOUTLN(CERR, "Outputlist_a = ", Outputlist_a); 662 670 Outputlist_b = Factorized(ffuni,alpha); 663 DEBOUTLN( cout, "Outputlist_b = ", Outputlist_b);671 DEBOUTLN(CERR, "Outputlist_b = ", Outputlist_b); 664 672 Outputlist = myUnion(Outputlist_a, Outputlist_b); 665 673 // have to back-swapvar the factors.... … … 668 676 Outputlist2.append(CFFactor(swapvar(copy.factor(),oldmainvar,mainvar),copy.exp())); 669 677 } 670 DEBOUTLN( cout, "Outputlist2 (a+b swapped) (to return) = ", Outputlist2);678 DEBOUTLN(CERR, "Outputlist2 (a+b swapped) (to return) = ", Outputlist2); 671 679 return Outputlist2; 672 680 } … … 676 684 for ( int i=1; i<=level(F); i++) 677 685 if ( degree(f,Variable(i) ) == 1 ) { //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ? 678 DEBOUTLN( cout, "Trivial case: ", F);686 DEBOUTLN(CERR, "Trivial case: ", F); 679 687 Outputlist.append(CFFactor(F,1)); 680 688 return Outputlist; … … 683 691 // Look at the leading term: 684 692 lt = LC(f); 685 DEBOUTLN( cout, "Leading term: ", lt);693 DEBOUTLN(CERR, "Leading term: ", lt); 686 694 if ( lt != f.genOne() ){ 687 695 // make the polynomial monic in the main variable 688 696 ff = make_monic(f,lt); ffuni = ff; 689 DEBOUTLN( cout, "make_monic returned: ", ff);697 DEBOUTLN(CERR, "make_monic returned: ", ff); 690 698 } 691 699 else{ ff= f; ffuni= ff; } … … 693 701 TIMING_START(evaluate_time); 694 702 success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, alpha, Substitutionlist,UnivariateFactorlist); 695 DEBOUTLN( cout, "Returned from evaluate: success: ", success);703 DEBOUTLN(CERR, "Returned from evaluate: success: ", success); 696 704 for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ ){ 697 DEBOUTLN( cout, "Substituting ", ii.getItem().factor());698 DEBOUTLN( cout, " with value: ", ii.getItem().exp());705 DEBOUTLN(CERR, "Substituting ", ii.getItem().factor()); 706 DEBOUTLN(CERR, " with value: ", ii.getItem().exp()); 699 707 } 700 708 701 709 if ( success==0 ){ // evalute wasn't successfull 702 710 success= specializePoly(ffuni,Extension,degree(ff),Substitutionlist,1,getNumVars(compress(ff,m))); 703 DEBOUTLN( cout, "Returned from specializePoly: success: ", success);711 DEBOUTLN(CERR, "Returned from specializePoly: success: ", success); 704 712 if (success == 0 ){ // No spezialisation could be found 705 713 #ifdef HAVE_SINGULAR_ERROR … … 707 715 #else 708 716 #ifndef NOSTREAMIO 709 cerr<< "libfac: Factorize: ERROR: Not able to find a valid specialization!\n"710 << rcsid << errmsg << endl;717 CERR << "libfac: Factorize: ERROR: Not able to find a valid specialization!\n" 718 << rcsid << errmsg << "\n"; 711 719 #else 712 720 ; … … 724 732 // We now have an univariat poly; factorize that 725 733 if ( degree(Extension) == 0 ){ 726 DEBOUTMSG( cout, "Univ. Factorization over the ground field");734 DEBOUTMSG(CERR, "Univ. Factorization over the ground field"); 727 735 UnivariateFactorlist = factorize(ffuni,1); // univ. poly is sqr-free! 728 736 } 729 737 else{ 730 DEBOUTLN( cout, "Univ. Factorization over extension of degree ",738 DEBOUTLN(CERR, "Univ. Factorization over extension of degree ", 731 739 degree(getMipo(Extension,'x')) ); 732 740 #if 1 … … 745 753 TIMING_END(evaluate_time); 746 754 if (UnivariateFactorlist.length() == 1){ // poly is irreduzibel 747 DEBOUTLN( cout, "Univ. poly is irreduzible: ", UnivariateFactorlist);755 DEBOUTLN(CERR, "Univ. poly is irreduzible: ", UnivariateFactorlist); 748 756 Outputlist.append(CFFactor(F,1)); 749 757 return Outputlist; 750 758 } 751 759 else{ // we have factors 752 DEBOUTSL( cout);753 DEBOUT( cout, "Univariate poly has " , UnivariateFactorlist.length());754 DEBOUT( cout, " factors: ", ffuni);755 DEBOUT( cout, " = ", UnivariateFactorlist); DEBOUTNL(cout);760 DEBOUTSL(CERR); 761 DEBOUT(CERR, "Univariate poly has " , UnivariateFactorlist.length()); 762 DEBOUT(CERR, " factors: ", ffuni); 763 DEBOUT(CERR, " = ", UnivariateFactorlist); DEBOUTNL(CERR); 756 764 757 765 // INTERRUPTHANDLER … … 761 769 TIMING_START(hensel_time); 762 770 Outputlist = MultiHensel(ff,UnivariateFactorlist,Substitutionlist); 763 DEBOUTLN( cout, "Outputlist after MultiHensel: ", Outputlist);771 DEBOUTLN(CERR, "Outputlist after MultiHensel: ", Outputlist); 764 772 TIMING_END(hensel_time); 765 773 … … 770 778 TIMING_START(truefactor_time); 771 779 Outputlist = Truefactors(ff, level(ff), Substitutionlist, Outputlist); 772 DEBOUTLN( cout, "Outputlist after Truefactors: ", Outputlist);780 DEBOUTLN(CERR, "Outputlist after Truefactors: ", Outputlist); 773 781 TIMING_END(truefactor_time); 774 782 … … 779 787 if ( lt != f.genOne() ){ 780 788 Outputlist = not_monic(Outputlist,lt,ff,level(ff)); 781 DEBOUTLN( cout, "not_monic returned: ", Outputlist);789 DEBOUTLN(CERR, "not_monic returned: ", Outputlist); 782 790 } 783 791 … … 817 825 // INTERRUPTHANDLER 818 826 819 DEBINCLEVEL( cout, "Factorize");820 DEBOUTMSG( cout, rcsid);821 DEBOUTLN( cout, "Called with F= ", F);827 DEBINCLEVEL(CERR, "Factorize"); 828 DEBOUTMSG(CERR, rcsid); 829 DEBOUTLN(CERR, "Called with F= ", F); 822 830 if ( getCharacteristic() == 0 ) { // char == 0 823 831 TIMING_START(factorize_time); 824 // cout << "Factoring in char=0 of " << F << " = " << Outputlist << endl;832 //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n"; 825 833 Outputlist= factorize(F); 826 834 // Factorization in char=0 doesn't sometimes return at least two elements!!! 827 835 if ( getNumVars(Outputlist.getFirst().factor()) != 0 ) 828 836 Outputlist.insert(CFFactor(1,1)); 829 // cout << " Factorize in char=0: returning with: " << Outputlist << endl;837 //CERR << " Factorize in char=0: returning with: " << Outputlist << "\n"; 830 838 TIMING_END(factorize_time); 831 DEBDECLEVEL( cout, "Factorize");839 DEBDECLEVEL(CERR, "Factorize"); 832 840 TIMING_PRINT(factorize_time, "\ntime used for factorization : "); 833 841 return Outputlist; … … 865 873 else 866 874 SqrFreeList.append(CFFactor(F,1)); 867 DEBOUTLN( cout, "InternalSqrFreeList= ", SqrFreeList);875 DEBOUTLN(CERR, "InternalSqrFreeList= ", SqrFreeList); 868 876 for ( i=SqrFreeList; i.hasItem(); i++ ){ 869 DEBOUTLN( cout, "Factor under consideration: ", i.getItem().factor());877 DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor()); 870 878 // We need a compress on each list item ! Maybe we have less variables! 871 879 g =compress(i.getItem().factor(),m); … … 882 890 else{ // multivariate polynomial 883 891 if ( g.isHomogeneous() ){ 884 DEBOUTLN( cout, "Poly is homogeneous! : ", g);892 DEBOUTLN(CERR, "Poly is homogeneous! : ", g); 885 893 // Now we can substitute one variable to 1, factorize and then 886 894 // look on the resulting factors and their monomials for … … 901 909 } 902 910 g=1; unit=1; 903 DEBOUTLN( cout, "Outputlist is ", Outputlist);911 DEBOUTLN(CERR, "Outputlist is ", Outputlist); 904 912 for ( i=Outputlist; i.hasItem(); i++ ) 905 913 if ( level(i.getItem().factor()) > 0 ){ … … 928 936 } 929 937 930 DEBDECLEVEL( cout, "Factorize");938 DEBDECLEVEL(CERR, "Factorize"); 931 939 TIMING_END(factorize_time); 932 940 … … 963 971 // INTERRUPTHANDLER 964 972 965 DEBINCLEVEL( cout, "Factorize");966 DEBOUTMSG( cout, rcsid);967 DEBOUTLN( cout, "Called with F= ", F);973 DEBINCLEVEL(CERR, "Factorize"); 974 DEBOUTMSG(CERR, rcsid); 975 DEBOUTLN(CERR, "Called with F= ", F); 968 976 if ( getCharacteristic() == 0 ) 969 977 { // char == 0 970 978 TIMING_START(factorize_time); 971 // cout << "Factoring in char=0 of " << F << " = " << Outputlist << endl;979 //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n"; 972 980 #if 0 973 981 // SHOULD: Outputlist= factorize(F,minpoly); … … 1003 1011 if ( getNumVars(Outputlist.getFirst().factor()) != 0 ) 1004 1012 Outputlist.insert(CFFactor(1,1)); 1005 // cout << " Factorize in char=0: returning with: " << Outputlist << endl;1013 //CERR << " Factorize in char=0: returning with: " << Outputlist << "\n"; 1006 1014 TIMING_END(factorize_time); 1007 DEBDECLEVEL( cout, "Factorize");1015 DEBDECLEVEL(CERR, "Factorize"); 1008 1016 TIMING_PRINT(factorize_time, "\ntime used for factorization : "); 1009 1017 return Outputlist; … … 1041 1049 else 1042 1050 SqrFreeList.append(CFFactor(F,1)); 1043 DEBOUTLN( cout, "InternalSqrFreeList= ", SqrFreeList);1051 DEBOUTLN(CERR, "InternalSqrFreeList= ", SqrFreeList); 1044 1052 for ( i=SqrFreeList; i.hasItem(); i++ ){ 1045 DEBOUTLN( cout, "Factor under consideration: ", i.getItem().factor());1053 DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor()); 1046 1054 // We need a compress on each list item ! Maybe we have less variables! 1047 1055 g =compress(i.getItem().factor(),m); … … 1061 1069 else{ // multivariate polynomial 1062 1070 if ( g.isHomogeneous() ){ 1063 DEBOUTLN( cout, "Poly is homogeneous! : ", g);1071 DEBOUTLN(CERR, "Poly is homogeneous! : ", g); 1064 1072 // Now we can substitute one variable to 1, factorize and then 1065 1073 // look on the resulting factors and their monomials for … … 1080 1088 } 1081 1089 g=1; unit=1; 1082 DEBOUTLN( cout, "Outputlist is ", Outputlist);1090 DEBOUTLN(CERR, "Outputlist is ", Outputlist); 1083 1091 for ( i=Outputlist; i.hasItem(); i++ ) 1084 1092 if ( level(i.getItem().factor()) > 0 ){ … … 1107 1115 } 1108 1116 1109 DEBDECLEVEL( cout, "Factorize");1117 DEBDECLEVEL(CERR, "Factorize"); 1110 1118 TIMING_END(factorize_time); 1111 1119 … … 1124 1132 /* 1125 1133 $Log: not supported by cvs2svn $ 1134 Revision 1.22 2006/04/28 13:46:29 Singular 1135 *hannes: better tests for 0, 1 1136 1126 1137 Revision 1.21 2005/12/12 18:02:03 Singular 1127 1138 *hannes: use sorting option in Factorize -
libfac/factor/MVMultiHensel.cc
rdbcf42a re2ca88 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1. 8 2002-07-30 15:11:19 Singular Exp $";4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1.9 2006-05-16 14:46:49 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes 7 7 #include <factory.h> 8 8 #ifndef NOSTREAMIO 9 #ifdef HAVE_IOSTREAM 10 #include <iostream> 11 #define OSTREAM std::ostream 12 #define ISTREAM std::istream 13 #define CERR std::cerr 14 #define CIN std::cin 15 #elif defined(HAVE_IOSTREAM_H) 9 16 #include <iostream.h> 17 #define OSTREAM ostream 18 #define ISTREAM istream 19 #define CERR cerr 20 #define CIN cin 21 #endif 10 22 #endif 11 23 // Factor - Includes … … 104 116 Variable x(levelU); 105 117 106 DEBOUT( cout, "diophant: called with: ", F1);107 DEBOUT( cout, " ", F2); DEBOUTLN(cout, " ", i);118 DEBOUT(CERR, "diophant: called with: ", F1); 119 DEBOUT(CERR, " ", F2); DEBOUTLN(CERR, " ", i); 108 120 109 121 // Did we solve the diophantine equation yet? … … 121 133 #else 122 134 #ifndef NOSTREAMIO 123 cerr<< "libfac: diophant ERROR: degree too large! "124 << (degree(F1,levelU) + degree(F2,levelU) ) << endl;135 CERR << "libfac: diophant ERROR: degree too large! " 136 << (degree(F1,levelU) + degree(F2,levelU) ) <<"\n"; 125 137 #else 126 138 ; … … 139 151 #else 140 152 #ifndef NOSTREAMIO 141 cerr<< "libfac: diophant ERROR: " << F1 << " and " << F2142 << " are not relatively prime!" << endl;153 CERR << "libfac: diophant ERROR: " << F1 << " and " << F2 154 << " are not relatively prime!" << "\n"; 143 155 #else 144 156 ; … … 176 188 A[i].calculated = true ; B[i].calculated = true ; 177 189 } 178 DEBOUT( cout, "diophant: Returnvalue is: ", Retvalue.One);179 DEBOUTLN( cout, " ", Retvalue.Two);190 DEBOUT(CERR, "diophant: Returnvalue is: ", Retvalue.One); 191 DEBOUTLN(CERR, " ", Retvalue.Two); 180 192 181 193 return Retvalue; … … 193 205 DiophantForm intermediate; 194 206 195 DEBOUT( cout, "make_delta: W= ", W);196 DEBOUTLN( cout, " degree(W,levelU)= ", degree(W,levelU) );207 DEBOUT(CERR, "make_delta: W= ", W); 208 DEBOUTLN(CERR, " degree(W,levelU)= ", degree(W,levelU) ); 197 209 198 210 if ( levelU == level(W) ){ // same level, good … … 206 218 Retvalue = W * intermediate.One; 207 219 } 208 DEBOUTLN( cout, "make_delta: Returnvalue= ", Retvalue);220 DEBOUTLN(CERR, "make_delta: Returnvalue= ", Retvalue); 209 221 return Retvalue; 210 222 } … … 217 229 DiophantForm intermediate; 218 230 219 DEBOUT( cout, "make_square: W= ", W );220 DEBOUTLN( cout, " degree(W,levelU)= ", degree(W,levelU));231 DEBOUT(CERR, "make_square: W= ", W ); 232 DEBOUTLN(CERR, " degree(W,levelU)= ", degree(W,levelU)); 221 233 222 234 if ( levelU == level(W) ){ // same level, good … … 230 242 Retvalue = W * intermediate.Two; 231 243 } 232 DEBOUTLN( cout, "make_square: Returnvalue= ", Retvalue);244 DEBOUTLN(CERR, "make_square: Returnvalue= ", Retvalue); 233 245 234 246 return Retvalue; … … 252 264 RememberArray B(degree(F,levelU)+degree(G,levelU)+1); 253 265 254 DEBOUTLN( cout, "mvhensel called with: U= ", U);255 DEBOUTLN( cout, " F= ", F);256 DEBOUTLN( cout, " G= ", G);257 DEBOUTLN( cout, " degU= ", degU);266 DEBOUTLN(CERR, "mvhensel called with: U= ", U); 267 DEBOUTLN(CERR, " F= ", F); 268 DEBOUTLN(CERR, " G= ", G); 269 DEBOUTLN(CERR, " degU= ", degU); 258 270 259 271 V=change_poly(U,Substitutionlist,0); // change x_i <- x_i + a_i for all i 260 272 Rk = F*G-V; 261 273 #ifdef HENSELDEBUG2 262 cout << "mvhensel: V = " << V << endl263 << " Fk= " << F << endl264 << " Gk= " << G << endl265 << " Rk= " << Rk << endl;274 CERR << "mvhensel: V = " << V << "\n" 275 << " Fk= " << F << "\n" 276 << " Gk= " << G << "\n" 277 << " Rk= " << Rk << "\n"; 266 278 #endif 267 279 for ( int k=2; k<=degU+1; k++){//2; k++){//degU+1; k++){ 268 280 W = mod_power(Rk,k,levelU); 269 281 #ifdef HENSELDEBUG2 270 cout << "mvhensel: Iteration: " << k << endl;271 cout << "mvhensel: W= " << W << endl;282 CERR << "mvhensel: Iteration: " << k << "\n"; 283 CERR << "mvhensel: W= " << W << "\n"; 272 284 #endif 273 285 D = make_delta(levelU,W,F,G,A,B); 274 286 #ifdef HENSELDEBUG2 275 cout << "mvhensel: D= " << D << endl;287 CERR << "mvhensel: D= " << D << "\n"; 276 288 #endif 277 289 S = make_square(levelU,W,F,G,A,B); 278 290 #ifdef HENSELDEBUG2 279 cout << "mvhensel: S= " << S << endl;291 CERR << "mvhensel: S= " << S << "\n"; 280 292 #endif 281 293 Rk += S*D - D*Fk - S*Gk; 282 294 #ifdef HENSELDEBUG2 283 cout << "mvhensel: Rk= " << Rk << endl;295 CERR << "mvhensel: Rk= " << Rk << "\n"; 284 296 #endif 285 297 Fk -= S; 286 298 #ifdef HENSELDEBUG2 287 cout << "mvhensel: Fk= " << Fk << endl;299 CERR << "mvhensel: Fk= " << Fk << "\n"; 288 300 #endif 289 301 Gk -= D; 290 302 #ifdef HENSELDEBUG2 291 cout << "mvhensel: Gk= " << Gk << endl;303 CERR << "mvhensel: Gk= " << Gk << "\n"; 292 304 #endif 293 305 if ( Rk.isZero() ) break; … … 296 308 Retvalue.Two = change_poly(Gk,Substitutionlist,1); 297 309 298 DEBOUTLN( cout, "mvhensel: Retvalue: ", Retvalue.One);299 DEBOUTLN( cout, " ", Retvalue.Two);310 DEBOUTLN(CERR, "mvhensel: Retvalue: ", Retvalue.One); 311 DEBOUTLN(CERR, " ", Retvalue.Two); 300 312 301 313 return Retvalue ; … … 313 325 int n = factorlist.length(); 314 326 315 DEBOUT( cout, "multihensel: called with ", mF);316 DEBOUTLN( cout, " ", factorlist);327 DEBOUT(CERR, "multihensel: called with ", mF); 328 DEBOUTLN(CERR, " ", factorlist); 317 329 318 330 if ( n == 1 ) { … … 329 341 else { // more then two factors 330 342 #ifdef HENSELDEBUG2 331 cout << "multihensel: more than two factors!" << endl;343 CERR << "multihensel: more than two factors!" << "\n"; 332 344 #endif 333 345 Pl=factorlist.getFirst().factor(); factorlist.removeFirst(); … … 336 348 Pr *= i.getItem().factor() ; 337 349 #ifdef HENSELDEBUG2 338 cout<< "multihensel: Pl,Pr, factorlist: " << Pl << " " << Pr339 << " " << factorlist << endl;350 CERR << "multihensel: Pl,Pr, factorlist: " << Pl << " " << Pr 351 << " " << factorlist << "\n"; 340 352 #endif 341 353 intermediat= mvhensel(mF,Pl,Pr,Substitutionlist); … … 364 376 int n = factorlist.length(),h=n/2, k; 365 377 366 DEBOUT( cout, "MultiHensel: called with ", mF);367 DEBOUTLN( cout, " ", factorlist);368 DEBOUT( cout," : n,h = ", n);369 DEBOUTLN( cout," ", h);378 DEBOUT(CERR, "MultiHensel: called with ", mF); 379 DEBOUTLN(CERR, " ", factorlist); 380 DEBOUT(CERR," : n,h = ", n); 381 DEBOUTLN(CERR," ", h); 370 382 371 383 if ( n == 1 ) { … … 386 398 } 387 399 388 DEBOUTLN( cout, "MultiHensel: Ll= ", Ll);389 DEBOUTLN( cout, " factorlist= ", factorlist);400 DEBOUTLN(CERR, "MultiHensel: Ll= ", Ll); 401 DEBOUTLN(CERR, " factorlist= ", factorlist); 390 402 391 403 Pl = 1; Pr = 1; 392 404 for ( i = Ll; i.hasItem(); i++) 393 405 Pl *= i.getItem().factor(); 394 DEBOUTLN( cout, "MultiHensel: Pl= ", Pl);406 DEBOUTLN(CERR, "MultiHensel: Pl= ", Pl); 395 407 for ( i = factorlist; i.hasItem(); i++) 396 408 Pr *= i.getItem().factor(); 397 DEBOUTLN( cout, "MultiHensel: Pr= ", Pr);409 DEBOUTLN(CERR, "MultiHensel: Pr= ", Pr); 398 410 intermediat = mvhensel(mF,Pl,Pr,Substitutionlist); 399 411 // divison test for intermediat.One and intermediat.Two ? … … 418 430 /* 419 431 $Log: not supported by cvs2svn $ 432 Revision 1.8 2002/07/30 15:11:19 Singular 433 *hannes: minor cleanups 434 420 435 Revision 1.7 2001/08/22 14:21:17 Singular 421 436 *hannes: added search for main var to Factorize -
libfac/factor/SqrFree.cc
rdbcf42a re2ca88 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1. 9 2006-04-28 13:46:29Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.10 2006-05-16 14:46:50 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 /////////////////////////////////////////////////////////////////////////////// … … 8 8 #include<factory.h> 9 9 #ifndef NOSTREAMIO 10 #ifdef HAVE_IOSTREAM 11 #include <iostream> 12 #define OSTREAM std::ostream 13 #define ISTREAM std::istream 14 #define CERR std::cerr 15 #define CIN std::cin 16 #elif defined(HAVE_IOSTREAM_H) 10 17 #include <iostream.h> 18 #define OSTREAM ostream 19 #define ISTREAM istream 20 #define CERR cerr 21 #define CIN cin 22 #endif 11 23 #endif 12 24 // Factor - Includes … … 178 190 #else 179 191 #ifndef NOSTREAMIO 180 cerr<< "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n"181 << rcsid << errmsg << endl;192 CERR << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n" 193 << rcsid << errmsg << "\n"; 182 194 #endif 183 195 #endif … … 198 210 int n = level(f); 199 211 200 DEBINCLEVEL( cout, "SqrFreed");201 DEBOUTLN( cout, "Called with r= ", r);212 DEBINCLEVEL(CERR, "SqrFreed"); 213 DEBOUTLN(CERR, "Called with r= ", r); 202 214 if (getNumVars(f)==0 ) { // just a constant; return it 203 215 Outputlist= myappend(Outputlist,CFFactor(f,1)); … … 213 225 if ( ! (g.isOne() || (-g).isOne() || degree(g)==0 )) { 214 226 g = swapvar(g,k,n); 215 DEBOUTLN( cout, "We have a content: ", g);227 DEBOUTLN(CERR, "We have a content: ", g); 216 228 Outputlist = myUnion(InternalSqrFree(g,mipo),Outputlist); // should we add a 217 229 // SqrFreeTest(g) first ? 218 DEBOUTLN( cout, "Outputlist is now: ", Outputlist);230 DEBOUTLN(CERR, "Outputlist is now: ", Outputlist); 219 231 f /=g; 220 DEBOUTLN( cout, "f is now: ", f);232 DEBOUTLN(CERR, "f is now: ", f); 221 233 } 222 234 } … … 225 237 // Now f is primitive; Let`s look if f is univariate 226 238 if ( f.isUnivariate() ) { 227 DEBOUTLN( cout, "f is univariate: ", f);239 DEBOUTLN(CERR, "f is univariate: ", f); 228 240 g = content(g); 229 241 if ( ! (g.isOne() || (-g).isOne() ) ){ … … 232 244 } 233 245 Outputlist = Union(sqrFree(f),Outputlist) ; 234 DEBOUTLN( cout, "Outputlist after univ. sqrFree(f) = ", Outputlist);235 DEBDECLEVEL( cout, "SqrFreed");246 DEBOUTLN(CERR, "Outputlist after univ. sqrFree(f) = ", Outputlist); 247 DEBDECLEVEL(CERR, "SqrFreed"); 236 248 return Outputlist ; 237 249 } … … 240 252 if ( totaldegree(f) <= 1 ) { 241 253 Outputlist= myappend(Outputlist,CFFactor(f,1)) ; 242 DEBDECLEVEL( cout, "SqrFreed");254 DEBDECLEVEL(CERR, "SqrFreed"); 243 255 return Outputlist ; 244 256 } … … 266 278 if ( k==n ) 267 279 { // really is Pth power 268 DEBOUTLN( cout, "f is a p'th root: ", f);280 DEBOUTLN(CERR, "f is a p'th root: ", f); 269 281 CFMap m; 270 282 g = compress(f,m); … … 273 285 else 274 286 f = m(PthRoot(g,mipo)); 275 DEBOUTLN( cout, " that is : ", f);287 DEBOUTLN(CERR, " that is : ", f); 276 288 // now : Outputlist union ( SqrFreed(f) )^getCharacteristic() 277 289 Outputlist=myUnion(Powerup(InternalSqrFree(f),getCharacteristic()),Outputlist); 278 DEBDECLEVEL( cout, "SqrFreed");290 DEBDECLEVEL(CERR, "SqrFreed"); 279 291 return Outputlist ; 280 292 } … … 282 294 } 283 295 g = f.deriv(); 284 DEBOUTLN( cout, "calculating mygcd of ", f);285 DEBOUTLN( cout, " and ", g);296 DEBOUTLN(CERR, "calculating mygcd of ", f); 297 DEBOUTLN(CERR, " and ", g); 286 298 h = mygcd(f,pp(g)); h /= lc(h); 287 DEBOUTLN( cout,"mygcd(f,g)= ",h);299 DEBOUTLN(CERR,"mygcd(f,g)= ",h); 288 300 if ( (h.isOne()) || ( h==f) || ((-h).isOne()) || getNumVars(h)==0 ) { // no common factor 289 301 Outputlist= myappend(Outputlist,CFFactor(f,1)) ; 290 DEBOUTLN( cout, "Outputlist= ", Outputlist);291 DEBDECLEVEL( cout, "SqrFreed");302 DEBOUTLN(CERR, "Outputlist= ", Outputlist); 303 DEBDECLEVEL(CERR, "SqrFreed"); 292 304 return Outputlist ; 293 305 } … … 299 311 f /= g; 300 312 } 301 DEBOUTLN( cout, "Split into f= ", f);302 DEBOUTLN( cout, " and h= ", h);313 DEBOUTLN(CERR, "Split into f= ", f); 314 DEBOUTLN(CERR, " and h= ", h); 303 315 // For char > 0 the polys f and h can have Pth roots; so we need a test 304 316 // Test is disabled because timing is the same … … 312 324 // else 313 325 Outputlist=myUnion(Outputlist,InternalSqrFree(h)); 314 DEBOUTLN( cout, "Returning list ", Outputlist);315 DEBDECLEVEL( cout, "SqrFreed");326 DEBOUTLN(CERR, "Returning list ", Outputlist); 327 DEBDECLEVEL(CERR, "SqrFreed"); 316 328 return Outputlist ; 317 329 } … … 320 332 #else 321 333 #ifndef NOSTREAMIO 322 cerr<< "\nlibfac: ERROR: SqrFreed: we should never fall trough here!\n"323 << rcsid << errmsg << endl;324 #endif 325 #endif 326 DEBDECLEVEL( cout, "SqrFreed");334 CERR << "\nlibfac: ERROR: SqrFreed: we should never fall trough here!\n" 335 << rcsid << errmsg << "\n"; 336 #endif 337 #endif 338 DEBDECLEVEL(CERR, "SqrFreed"); 327 339 return Outputlist; // for safety purpose 328 340 } … … 337 349 CFFList Outputlist, Outputlist2; 338 350 339 DEBINCLEVEL( cout, "InternalSqrFree");340 DEBOUTMSG( cout, rcsid);341 DEBOUTLN( cout,"Called with f= ", f);351 DEBINCLEVEL(CERR, "InternalSqrFree"); 352 DEBOUTMSG(CERR, rcsid); 353 DEBOUTLN(CERR,"Called with f= ", f); 342 354 343 355 // Take care of stupid users giving us constants … … 359 371 } 360 372 } 361 DEBOUTLN( cout,"Outputlist = ", Outputlist);373 DEBOUTLN(CERR,"Outputlist = ", Outputlist); 362 374 for ( CFFListIterator i=Outputlist; i.hasItem(); i++ ) 363 375 if ( getNumVars(i.getItem().factor()) > 0 ) 364 376 Outputlist2.append(i.getItem()); 365 377 366 DEBOUTLN( cout,"Outputlist2 = ", Outputlist2);367 DEBDECLEVEL( cout, "InternalSqrFree");378 DEBOUTLN(CERR,"Outputlist2 = ", Outputlist2); 379 DEBDECLEVEL(CERR, "InternalSqrFree"); 368 380 return Outputlist2 ; 369 381 } … … 376 388 int n=totaldegree(r); 377 389 378 DEBINCLEVEL( cout, "SqrFree");390 DEBINCLEVEL(CERR, "SqrFree"); 379 391 380 392 if ( sqrfreelist.length() < 2 ){ 381 DEBDECLEVEL( cout, "SqrFree");393 DEBDECLEVEL(CERR, "SqrFree"); 382 394 return sqrfreelist; 383 395 } … … 396 408 outputlist.insert(CFFactor(elem,1)); 397 409 398 DEBOUTLN( cout, "SqrFree returns list:", outputlist);399 DEBDECLEVEL( cout, "SqrFree");410 DEBOUTLN(CERR, "SqrFree returns list:", outputlist); 411 DEBDECLEVEL(CERR, "SqrFree"); 400 412 return outputlist; 401 413 } … … 403 415 /* 404 416 $Log: not supported by cvs2svn $ 417 Revision 1.9 2006/04/28 13:46:29 Singular 418 *hannes: better tests for 0, 1 419 405 420 Revision 1.8 2002/08/19 11:11:33 Singular 406 421 * hannes/pfister: alg_gcd etc. -
libfac/factor/Truefactor.cc
rdbcf42a re2ca88 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1. 9 2001-08-08 14:26:56Singular Exp $";4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.10 2006-05-16 14:46:50 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // Factory - Includes 7 7 #include <factory.h> 8 8 #ifndef NOSTREAMIO 9 #ifdef HAVE_IOSTREAM 10 #include <iostream> 11 #define OSTREAM std::ostream 12 #define ISTREAM std::istream 13 #define CERR std::cerr 14 #define CIN std::cin 15 #elif defined(HAVE_IOSTREAM_H) 9 16 #include <iostream.h> 17 #define OSTREAM ostream 18 #define ISTREAM istream 19 #define CERR cerr 20 #define CIN cin 21 #endif 10 22 #endif 11 23 // Factor - Includes … … 78 90 if (f.level()!=0) 79 91 { 80 // cout << "hasAlgVar:" << f.mvar() <<endl;92 //CERR << "hasAlgVar:" << f.mvar() <<"\n"; 81 93 return 1; 82 94 } … … 162 174 CFFList Returnlist; 163 175 164 DEBOUTLN( cout, "Remove_from_List called with L= ",L);165 DEBOUTLN( cout, " and elem= ",elem);176 DEBOUTLN(CERR, "Remove_from_List called with L= ",L); 177 DEBOUTLN(CERR, " and elem= ",elem); 166 178 for ( ListIterator<CFFactor> i = L ; i.hasItem(); i++) 167 179 if ( i.getItem().factor() != elem ) … … 220 232 ListIterator<CFFactor> i; 221 233 222 // cout << "SubstitutionList="<< SubstitutionList<<endl;234 //CERR << "SubstitutionList="<< SubstitutionList<<"\n"; 223 235 // step 1: simply test the generated factors alone 224 236 for ( i= PiList; i.hasItem();i++){ … … 226 238 //CanonicalForm test_f=change_poly(factor.factor(),SubstitutionList,0); 227 239 CanonicalForm test_f=factor.factor(); 228 // cout <<"f:" << factor.factor() << " -> test_f:"<<test_f <<endl;229 // cout << " 1:" << change_poly(factor.factor(),SubstitutionList,1) <<endl;240 //CERR <<"f:" << factor.factor() << " -> test_f:"<<test_f <<"\n"; 241 //CERR << " 1:" << change_poly(factor.factor(),SubstitutionList,1) <<"\n"; 230 242 c= mydivremt(U,test_f,a,b); 231 243 if ( c && b == U.genZero() && !hasAlgVar(test_f)) 232 244 // factor.getFactor() divides U 233 245 { 234 // cout << " teilt:" << test_f <<endl;246 //CERR << " teilt:" << test_f <<"\n"; 235 247 U= a; 236 248 FAC.append(factor); 237 249 } 238 250 else{ 239 // cout << " teilt nicht:" << test_f <<endl;251 //CERR << " teilt nicht:" << test_f <<"\n"; 240 252 L.append(factor); 241 253 } 242 254 } 243 DEBOUTLN( cout,"Truefactors: (step1) L = ", L);244 DEBOUTLN( cout," FAC= ", FAC);255 DEBOUTLN(CERR,"Truefactors: (step1) L = ", L); 256 DEBOUTLN(CERR," FAC= ", FAC); 245 257 246 258 // step 2: Do we have to check combinations? … … 257 269 } 258 270 259 DEBOUTLN( cout,"Truefactors: (step2) M = ", M);260 DEBOUTLN( cout," r = ", r);261 DEBOUTLN( cout," degU= ", degU);271 DEBOUTLN(CERR,"Truefactors: (step2) M = ", M); 272 DEBOUTLN(CERR," r = ", r); 273 DEBOUTLN(CERR," degU= ", degU); 262 274 263 275 // Now do the real work! … … 277 289 // step 5 278 290 E_all = combine(M, L); // generate all combinations of M elements from L 279 DEBOUTLN( cout,"Truefactors: (step5) E_all= ", E_all);291 DEBOUTLN(CERR,"Truefactors: (step5) E_all= ", E_all); 280 292 // select combinations with the degree not to exceed degU: 281 293 E_all = Rightdegree( E_all, degU, levelU ); 282 DEBOUTLN( cout,"Truefactors: (step5) E_all(Rightdegree)= ", E_all);294 DEBOUTLN(CERR,"Truefactors: (step5) E_all(Rightdegree)= ", E_all); 283 295 if ( E_all.length() == 0 ){ 284 296 FAC.append( CFFactor(U,1) ); … … 288 300 factor = i.getItem(); 289 301 Y = Multmod_power( factor.factor(), SubstitutionList, h, levelU); 290 DEBOUTLN( cout, "Truefactors: (step6) Testing Y = ", Y);302 DEBOUTLN(CERR, "Truefactors: (step6) Testing Y = ", Y); 291 303 c = mydivremt(U,Y,a,b); 292 304 // if ( c && b == U.genZero()) { // Y divides U 293 305 if ( c && b.isZero() ){ 294 DEBOUT( cout,"Truefactors: (step6): ",Y );295 DEBOUTLN( cout, " divides ",U);306 DEBOUT(CERR,"Truefactors: (step6): ",Y ); 307 DEBOUTLN(CERR, " divides ",U); 296 308 U = a; 297 309 FAC.append(Y); // Y is a real factor … … 363 375 #else 364 376 #ifndef NOSTREAMIO 365 cerr<< "libfac: ERROR: TakeNorms less then two items remaining! "366 << endl;377 CERR << "libfac: ERROR: TakeNorms less then two items remaining! " 378 << "\n"; 367 379 #else 368 380 ; … … 388 400 } 389 401 else { 390 // cout << "Schade!" << endl;402 //CERR << "Schade!" << "\n"; 391 403 } 392 DEBOUT( cout, "Truefactor: Combined ", n);393 DEBOUTLN( cout, " factors to: ", intermediate);404 DEBOUT(CERR, "Truefactor: Combined ", n); 405 DEBOUTLN(CERR, " factors to: ", intermediate); 394 406 } 395 407 n += 1; … … 409 421 #else 410 422 #ifndef NOSTREAMIO 411 cerr<< "libfac: TakeNorms: somethings wrong with remaining factors!"412 << endl;423 CERR << "libfac: TakeNorms: somethings wrong with remaining factors!" 424 << "\n"; 413 425 #endif 414 426 #endif … … 422 434 /* 423 435 $Log: not supported by cvs2svn $ 436 Revision 1.9 2001/08/08 14:26:56 Singular 437 *hannes: Dan's HAVE_SINGULAR_ERROR 438 424 439 Revision 1.8 2001/08/08 11:59:13 Singular 425 440 *hannes: Dan's NOSTREAMIO changes -
libfac/factor/class.h
rdbcf42a re2ca88 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: class.h,v 1. 5 2000-05-29 08:06:47 pohlExp $4 // $Id: class.h,v 1.6 2006-05-16 14:46:50 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef INCL_CLASS_H … … 10 10 11 11 #ifndef NOSTREAMIO 12 #ifdef HAVE_IOSTREAM 13 #include <iostream> 14 #define OSTREAM std::ostream 15 #define ISTREAM std::istream 16 #elif defined(HAVE_IOSTREAM_H) 12 17 #include <iostream.h> 18 #define OSTREAM ostream 19 #define ISTREAM istream 20 #endif 13 21 #endif 14 22 … … 33 41 // Substitution<T>& operator*= ( const T & f ) { _factor *= f; _exp *= f; return *this; } 34 42 #ifndef NOSTREAMIO 35 void print ( ostream& ) const;36 friend ostream& operator<< ( ostream& os, const Substitution<T> & f )43 void print ( OSTREAM& ) const; 44 friend OSTREAM& operator<< ( OSTREAM & os, const Substitution<T> & f ) 37 45 { 38 46 f.print( os ); … … 53 61 /* 54 62 $Log: not supported by cvs2svn $ 63 Revision 1.5 2000/05/29 08:06:47 pohl 64 no artificial friend 65 55 66 Revision 1.4 1997/09/12 07:19:54 Singular 56 67 * hannes/michael: libfac-0.3.0 -
libfac/factor/debug.h
rdbcf42a re2ca88 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 //////////////////////////////////////////////////////////// 3 // static char * rcsid = "$Id: debug.h,v 1. 3 1997-09-12 07:19:55Singular Exp $" ;3 // static char * rcsid = "$Id: debug.h,v 1.4 2006-05-16 14:46:50 Singular Exp $" ; 4 4 //////////////////////////////////////////////////////////// 5 5 // It is possible to include this file multiple times for different … … 39 39 extern char * deb_level_msg; 40 40 #define DEBINCLEVEL(stream,msg) \ 41 (stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << endl, deb_inc_level())41 (stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << "\n", deb_inc_level()) 42 42 #define DEBDECLEVEL(stream,msg) \ 43 (deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << endl)43 (deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << "\n") 44 44 #define DEBOUTSL(stream) \ 45 45 (stream << deb_level_msg, stream.flush()) … … 47 47 (stream << deb_level_msg << msg << object, stream.flush()) 48 48 #define DEBOUTLN(stream,msg,object) \ 49 (stream << deb_level_msg << msg << object << endl)49 (stream << deb_level_msg << msg << object << "\n") 50 50 #define DEBOUTMSG(stream,msg) \ 51 (stream << deb_level_msg << msg << endl)51 (stream << deb_level_msg << msg << "\n") 52 52 #define DEBOUTNL(stream) \ 53 (stream << endl)53 (stream << "\n") 54 54 #else 55 55 #define DEBINCLEVEL(stream,msg) … … 64 64 /* 65 65 $Log: not supported by cvs2svn $ 66 Revision 1.3 1997/09/12 07:19:55 Singular 67 * hannes/michael: libfac-0.3.0 68 66 69 Revision 1.2 1997/04/25 22:15:33 michael 67 70 Version for libfac-0.2.1 -
libfac/factor/homogfactor.cc
rdbcf42a re2ca88 1 1 /* Copyright 1997 Michael Messollen. All rights reserved. */ 2 2 //////////////////////////////////////////////////////////// 3 // static char * rcsid = "$Id: homogfactor.cc,v 1. 6 2005-12-09 08:36:11Singular Exp $ ";3 // static char * rcsid = "$Id: homogfactor.cc,v 1.7 2006-05-16 14:46:50 Singular Exp $ "; 4 4 //////////////////////////////////////////////////////////// 5 5 // FACTORY - Includes 6 6 #include <factory.h> 7 #ifdef HAVE_IOSTREAM 8 #include <iostream> 9 #define OSTREAM std::ostream 10 #define ISTREAM std::istream 11 #define CERR std::cerr 12 #define CIN std::cin 13 #elif defined(HAVE_IOSTREAM_H) 14 #include <iostream.h> 15 #define OSTREAM ostream 16 #define ISTREAM istream 17 #define CERR cerr 18 #define CIN cin 19 #endif 20 7 21 // Factor - Includes 8 22 #include "tmpl_inst.h" … … 121 135 CFFList 122 136 HomogFactor( const CanonicalForm & g, const CanonicalForm & minpoly, const int Mainvar ){ 123 DEBINCLEVEL( cout, "HomogFactor");137 DEBINCLEVEL(CERR, "HomogFactor"); 124 138 Variable xn = get_max_degree_Variable(g); 125 139 int d_xn = degree(g,xn); … … 127 141 CanonicalForm F = compress(g(1,xn),n); // must compress F! 128 142 129 DEBOUTLN( cout, "xn= ", xn);130 DEBOUTLN( cout, "d_xn= ", d_xn);131 DEBOUTLN( cout, "F= ", F);143 DEBOUTLN(CERR, "xn= ", xn); 144 DEBOUTLN(CERR, "d_xn= ", d_xn); 145 DEBOUTLN(CERR, "F= ", F); 132 146 133 147 // should we do this for low degree polys g ? e.g. quadratic? … … 143 157 Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) ); 144 158 // Now we have uncompressed factors in Homoglist 145 DEBOUTLN( cout, "F factors as: ", Homoglist);159 DEBOUTLN(CERR, "F factors as: ", Homoglist); 146 160 CFFList Unhomoglist; 147 161 CanonicalForm unhomogelem; 148 162 for ( j=Homoglist; j.hasItem(); j++ ){ 149 DEBOUTLN( cout, "Homogenizing ",j.getItem().factor());163 DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 150 164 unhomogelem= homogenize(j.getItem().factor(),xn); 151 DEBOUTLN( cout, " that is ", unhomogelem);165 DEBOUTLN(CERR, " that is ", unhomogelem); 152 166 Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp())); 153 167 d_xn -= degree(unhomogelem,xn)*j.getItem().exp(); 154 168 } 155 DEBOUTLN( cout, "Power of xn to append is ", d_xn);169 DEBOUTLN(CERR, "Power of xn to append is ", d_xn); 156 170 if ( d_xn != 0 ) // have to append xn^(d_xn) 157 171 Unhomoglist.append(CFFactor(CanonicalForm(xn),d_xn)); 158 172 159 DEBDECLEVEL( cout, "HomogFactor");173 DEBDECLEVEL(CERR, "HomogFactor"); 160 174 return Unhomoglist; 161 175 } … … 163 177 /* 164 178 $Log: not supported by cvs2svn $ 179 Revision 1.6 2005/12/09 08:36:11 Singular 180 *hannes: stuff for homog. polys ->factory 181 165 182 Revision 1.5 2005/12/05 15:47:32 Singular 166 183 *hannes: is_homogeneous -> factory: isHomogeneous -
libfac/factor/timing.h
rdbcf42a re2ca88 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // static char * rcsid = "$Id: timing.h,v 1. 3 1997-09-12 07:19:59Singular Exp $";4 // static char * rcsid = "$Id: timing.h,v 1.4 2006-05-16 14:46:50 Singular Exp $"; 5 5 //////////////////////////////////////////////////////////// 6 6 // It is possible to include this file multiple times for different … … 16 16 #include <time.h> 17 17 #include <sys/times.h> 18 #ifdef HAVE_IOSTREAM 19 #include <iostream> 20 #define OSTREAM std::ostream 21 #define ISTREAM std::istream 22 #elif defined(HAVE_IOSTREAM_H) 18 23 #include <iostream.h> 24 #define OSTREAM ostream 25 #define ISTREAM istream 26 #endif 19 27 #define TIMING_START(t) { struct tms timing_ ## t ## _start, timing_ ## t ## _end; \ 20 28 times( &timing_ ## t ## _start ); … … 22 30 timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; } 23 31 #define TIMING_DEFINE_PRINT(t) long timing_ ## t ## _time; \ 24 void timing_print_ ## t ( char * msg ) { cout.setf( ios::fixed, ios::floatfield); cout.precision(2); \25 cout << msg << float(timing_ ## t ## _time) / 60 << " sec" << endl; }32 void timing_print_ ## t ( char * msg ) { CERR.setf( ios::fixed, ios::floatfield); CERR.precision(2); \ 33 CERR << msg << float(timing_ ## t ## _time) / 60 << " sec" << "\n"; } 26 34 #define TIMING_PRINT(t,msg) timing_print_ ## t ( msg ); 27 35 #define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * ); … … 36 44 /* 37 45 $Log: not supported by cvs2svn $ 46 Revision 1.3 1997/09/12 07:19:59 Singular 47 * hannes/michael: libfac-0.3.0 48 38 49 Revision 1.2 1997/04/25 22:13:56 michael 39 50 Version for libfac-0.2.1 -
libfac/test.cc
rdbcf42a re2ca88 1 //static char rcsid[] = "$Id: test.cc,v 1. 3 1997-09-12 07:19:34Singular Exp $";1 //static char rcsid[] = "$Id: test.cc,v 1.4 2006-05-16 14:46:48 Singular Exp $"; 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // Factor - Includes 4 4 #include "factor.h" 5 #ifdef HAVE_IOSTREAM 6 #include <iostream> 7 #define CERR std::cerr 8 #define COUT std::cout 9 #define CIN std::cin 10 #elif defined(HAVE_IOSTREAM_H) 11 #include <iostream.h> 12 #define CERR cerr 13 #define COUT cout 14 #define CIN cin 15 #endif 16 5 17 6 18 … … 21 33 CFFactor copy; 22 34 23 cout << libfac_name <<", Version " << libfac_version << endl;24 // cout<< " Characteristic = ";25 cin>> charac;35 COUT << libfac_name <<", Version " << libfac_version << "\n"; 36 // COUT << " Characteristic = "; 37 CIN >> charac; 26 38 setCharacteristic(charac); 27 39 On(SW_SYMMETRIC_FF); … … 35 47 // 36 48 ////////////////////////////////////////////////////////////// 37 // cout<< " f = ";38 cin>> f;39 cout<< f << " mod " << charac << " = " ;49 // COUT << " f = "; 50 CIN >> f; 51 COUT << f << " mod " << charac << " = " ; 40 52 Factorlist= Factorize( f,0 ); 41 cout << Factorlist ;//<< endl;53 COUT << Factorlist ;//<< "\n"; 42 54 // Ueberpruefen: 43 55 g=1; … … 50 62 } 51 63 if ( (f-g) != f.genZero() ){ 52 cerr << "\nList and f differ: f= " << f << " g= " << g << endl;64 CERR << "\nList and f differ: f= " << f << " g= " << g << "\n"; 53 65 } 54 66 } -
libfac/testcs.cc
rdbcf42a re2ca88 1 // $Id: testcs.cc,v 1. 2 1997-09-12 07:19:35Singular Exp $1 // $Id: testcs.cc,v 1.3 2006-05-16 14:46:48 Singular Exp $ 2 2 3 3 #include <factory.h> 4 4 #include <factor.h> 5 #ifdef HAVE_IOSTREAM 6 #include <iostream> 7 #define COUT std::cout 8 #define CIN std::cin 9 #elif defined(HAVE_IOSTREAM_H) 10 #include <iostream.h> 11 #define COUT cout 12 #define CIN cin 13 #endif 14 5 15 6 16 // testing: Characteristic Sets … … 18 28 int reord=0; // use strategy for reordering? 19 29 int charac; 20 cout << " Characteristic = "; cin>> charac;30 COUT << " Characteristic = "; CIN >> charac; 21 31 setCharacteristic(charac); 22 32 On(SW_SYMMETRIC_FF); 23 33 char vnames[30]; 24 cout << " vnames = "; cin>> vnames;34 COUT << " vnames = "; CIN >> vnames; 25 35 26 36 setVarNames( vnames ); … … 34 44 Varlist betterorder; 35 45 36 cout<< " f[" << i << "] = "; cin >> f;46 COUT << " f[" << i << "] = "; cin >> f; 37 47 while ( f != 0 ) { 38 48 F1.append( f ); i++; 39 cout<< " f[" << i << "] = "; cin >> f;49 COUT << " f[" << i << "] = "; cin >> f; 40 50 } 41 51 F2=F1; 42 cout << endl;52 COUT << "\n"; 43 53 44 cout << "F = " << F1 << endl;54 COUT << "F = " << F1 << "\n"; 45 55 if (reord){ 46 56 betterorder= neworder(F1); 47 cout << "new orderd vars: " << betterorder << endl;57 COUT << "new orderd vars: " << betterorder << "\n"; 48 58 F1=reorder(betterorder,F1); 49 cout << "new F= " << F1 << endl;59 COUT << "new F= " << F1 << "\n"; 50 60 } 51 // cout << "\nUsing Modified CharSet:" << endl;61 // COUT << "\nUsing Modified CharSet:" << "\n"; 52 62 // F2 = MCharSetN( F1, Remembern ); 53 // cout << "MCsN(F) = " << F2 << endl;54 // cout << "Factors removed: " << Remembern.FS2 << endl;55 // cout << "Possible Factors considered: " << Remembern.FS1 << endl;63 // COUT << "MCsN(F) = " << F2 << "\n"; 64 // COUT << "Factors removed: " << Remembern.FS2 << "\n"; 65 // COUT << "Possible Factors considered: " << Remembern.FS1 << "\n"; 56 66 // for ( I = F2; I.hasItem(); I++ ) 57 // cout << " vars: " << getVars( I.getItem() ) << endl;58 cout << "\nUsing IrrCharSeries:" << endl;67 // COUT << " vars: " << getVars( I.getItem() ) << "\n"; 68 COUT << "\nUsing IrrCharSeries:" << "\n"; 59 69 Q= IrrCharSeries( F1 ); 60 cout << "ics(F) = " << Q << endl;70 COUT << "ics(F) = " << Q << "\n"; 61 71 if (reord){ 62 72 Q=reorder(betterorder,Q); 63 cout << "reorderd ics(F) = " << Q << endl;73 COUT << "reorderd ics(F) = " << Q << "\n"; 64 74 } 65 75 }
Note: See TracChangeset
for help on using the changeset viewer.