Changeset e2ca88 in git for libfac/factor
- Timestamp:
- May 16, 2006, 4:46:50 PM (18 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 55abfc3008e047e8f26beaeb76b5bab66cfe8288
- Parents:
- dbcf42a937f51948f4de74902429b68c1b54592b
- Location:
- libfac/factor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.