Changeset 38e7b3 in git
- Timestamp:
- May 15, 2007, 4:46:49 PM (17 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 10697c5f8efbddd9473d4c6b1643df3543bb6c50
- Parents:
- c3c515358fdfb7f2eec3dccc57840e2480316ab9
- Location:
- libfac
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/charset/alg_factor.cc
rc3c515 r38e7b3 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: alg_factor.cc,v 1.1 6 2006-05-1614:46:48 Singular Exp $";5 static char * rcsid = "$Id: alg_factor.cc,v 1.17 2007-05-15 14:46:48 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 448 448 // the heart of the algorithm: the one from Trager 449 449 static CFFList 450 alg_factor( const CanonicalForm & f, const CFList & Astar, const Variable & vminpoly, const Varlist & oldord, const CFList & as){ 450 alg_factor( const CanonicalForm & f, const CFList & Astar, const Variable & vminpoly, const Varlist & oldord, const CFList & as) 451 { 451 452 CFFList L, Factorlist; 452 453 CanonicalForm R, Rstar, s, g, h; … … 455 456 DEBINCLEVEL(CERR,"alg_factor"); 456 457 DEBOUTLN(CERR, "alg_factor: f= ", f); 458 457 459 //out_cf("start alg_factor:",f,"\n"); 458 460 substlist= simpleextension(Astar, vminpoly, Rstar); … … 504 506 if ( !Factorlist.getFirst().factor().inCoeffDomain() ) 505 507 Factorlist.insert(CFFactor(1,1)); 506 if ( Factorlist.length() == 2 && Factorlist.getLast().exp()== 1){ // irreduzibel (first entry is a constant) 508 if ( Factorlist.length() == 2 && Factorlist.getLast().exp()== 1) 509 { // irreduzibel (first entry is a constant) 507 510 L.append(CFFactor(f,1)); 508 511 } 509 else{ 512 else 513 { 510 514 DEBOUTLN(CERR, "alg_factor: g= ", g); 511 515 CanonicalForm gnew= g(s,s.mvar()); 512 516 DEBOUTLN(CERR, "alg_factor: gnew= ", gnew); 513 517 g=gnew; 514 for ( CFFListIterator i=Factorlist; i.hasItem(); i++){ 518 for ( CFFListIterator i=Factorlist; i.hasItem(); i++) 519 { 515 520 CanonicalForm fnew=i.getItem().factor(); 516 521 fnew= fnew(s,s.mvar()); … … 522 527 DEBOUTLN(CERR, "alg_factor: fnew= ", fnew); 523 528 } 524 if (degree(i.getItem().factor()) > 0 ){ 529 if (degree(i.getItem().factor()) > 0 ) 530 { 525 531 // undo linear transformation!!!! and then gcd! 526 532 //CERR << "algcd(" << g << "," << fnew << ",as" << as << ")" << "\n"; 527 //out_cf(" algcdg=",g,"\n");528 //out_cf(" algcdfnew=",fnew,"\n");533 //out_cf("g=",g,"\n"); 534 //out_cf("fnew=",fnew,"\n"); 529 535 //h= algcd(g,fnew, as, oldord); 530 536 //if (as.length() >1) … … 537 543 DEBOUTLN(CERR, " alg_factor: h= ", h); 538 544 DEBOUTLN(CERR, " alg_factor: oldord= ", oldord); 539 if ( degree(h) > 0 ){ //otherwise it's a constant 545 if ( degree(h) > 0 ) 546 { //otherwise it's a constant 547 //CanonicalForm c=LC(h,g.mvar()); 548 //out_cf("new lc h:",c,"\n"); 549 //h= divide(h,c,as); 550 //out_cf("new factor h/c:",h,"\n"); 540 551 g= divide(g, h,as); 541 552 DEBOUTLN(CERR, "alg_factor: g/h= ", g); 542 553 DEBOUTLN(CERR, "alg_factor: s= ", s); 543 554 DEBOUTLN(CERR, "alg_factor: substlist= ", substlist); 555 //out_cf("new g:",g,"\n"); 544 556 L.append(CFFactor(h,1)); 545 557 } 558 //else printf("degree <=1\n"); 546 559 } 547 560 } … … 817 830 /* 818 831 $Log: not supported by cvs2svn $ 832 Revision 1.16 2006/05/16 14:46:48 Singular 833 *hannes: gcc 4.1 fixes 834 819 835 Revision 1.15 2005/10/17 13:16:18 Singular 820 836 *hannes: code cleanup -
libfac/charset/csutil.cc
rc3c515 r38e7b3 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: csutil.cc,v 1.1 3 2006-06-19 13:37:47Singular Exp $";4 static char * rcsid = "$Id: csutil.cc,v 1.14 2007-05-15 14:46:48 Singular Exp $"; 5 5 ///////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 202 202 203 203 CanonicalForm 204 divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as){ 204 divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as) 205 { 205 206 CanonicalForm r,m,q; 206 207 … … 224 225 225 226 static CanonicalForm 226 myfitting( const CanonicalForm &f ){ 227 myfitting( const CanonicalForm &f ) 228 { 227 229 CanonicalForm rem=f; 228 230 229 if ( !(rem.isZero()) ){ 231 if ( !(rem.isZero()) ) 232 { 230 233 if ( getCharacteristic() > 0 ) 231 234 return num((rem/lc(rem))); 232 else{ 235 else 236 { 233 237 On(SW_RATIONAL); 234 238 CanonicalForm temp= mapinto(rem); … … 270 274 271 275 static CanonicalForm 272 premasb( const CanonicalForm & f, const CFList & as){ 276 premasb( const CanonicalForm & f, const CFList & as) 277 { 273 278 CanonicalForm remd=f; 274 279 CFList AS=as; 275 280 276 if ( as.length() > 1 ){ 281 if ( as.length() > 1 ) 282 { 277 283 AS.removeFirst(); // get rid of first elem 278 284 CanonicalForm elem; 279 while ( ! AS.isEmpty() ){ // thats true for at least the first iteration 285 while ( ! AS.isEmpty() ) 286 { // thats true for at least the first iteration 280 287 elem= AS.getLast(); 281 288 remd= Prem(remd,elem); … … 291 298 292 299 CFList 293 remsetb( const CFList & ps, const CFList & as){ 300 remsetb( const CFList & ps, const CFList & as) 301 { 294 302 CFList output; 295 303 CanonicalForm elem; 296 for (CFListIterator i=ps; i.hasItem(); i++){ 304 for (CFListIterator i=ps; i.hasItem(); i++) 305 { 297 306 elem= premasb(i.getItem(),as); 298 307 if ( elem != elem.genZero() ) output.append(elem); … … 305 314 // replace the power of factors of polys in as by 1 if any 306 315 static CFList 307 nopower( const CanonicalForm & init ){ 316 nopower( const CanonicalForm & init ) 317 { 308 318 CFFList sqrfreelist;// = Factorize(init);//SqrFree(init); 309 319 CFList output; … … 317 327 // CERR << "nopower: count is " << count << "\n";} 318 328 if ( count > 1 ) sqrfreelist = CFFList( CFFactor(init,1)); 319 else { 329 else 330 { 320 331 sqrfreelist = Factorize(init); 321 332 //sqrfreelist.removeFirst(); 322 333 } 323 for ( CFFListIterator i=sqrfreelist; i.hasItem(); i++ ){ 334 for ( CFFListIterator i=sqrfreelist; i.hasItem(); i++ ) 335 { 324 336 elem=i.getItem().factor(); 325 337 if ( cls(elem) > 0 ) output.append(elem); … … 363 375 CFListIterator j ; 364 376 365 for ( int J=1; J<= n ; J++ ){ 377 for ( int J=1; J<= n ; J++ ) 378 { 366 379 testlist.append(CanonicalForm(Variable(J))); 367 380 } … … 370 383 371 384 // remove already removed factors 372 for ( j = Remembern.FS2 ; j.hasItem(); j++ ){ 385 for ( j = Remembern.FS2 ; j.hasItem(); j++ ) 386 { 373 387 testelem = j.getItem(); 374 while ( 1 ){ 388 while ( 1 ) 389 { 375 390 test = mydivremt(r,testelem,a,b); 376 391 if ( test && b == r.genZero() ) r = a; … … 380 395 381 396 // Let's look if we have other canditates to remove 382 for ( j = testlist ; j.hasItem(); j++ ){ 397 for ( j = testlist ; j.hasItem(); j++ ) 398 { 383 399 testelem = j.getItem(); 384 400 // if ( testelem != r && testelem != r.mvar() ){ 385 if ( testelem != r ){ 386 while ( 1 ){ 401 if ( testelem != r ) 402 { 403 while ( 1 ) 404 { 387 405 test = divremt(r,testelem,a,b); 388 if ( test && b == r.genZero() ){ 406 if ( test && b == r.genZero() ) 407 { 389 408 Remembern.FS2= Union(Remembern.FS2, CFList(testelem)); 390 409 r = a; … … 404 423 // all irreducible nonconstant factors of a set of polynomials 405 424 CFList 406 factorps( const CFList &ps ){ 425 factorps( const CFList &ps ) 426 { 407 427 CFList qs; 408 428 CFFList q; 409 429 CanonicalForm elem; 410 430 411 for ( CFListIterator i=ps; i. hasItem(); i++ ){ 431 for ( CFListIterator i=ps; i. hasItem(); i++ ) 432 { 412 433 q=Factorize(i.getItem()); 413 434 q.removeFirst(); 414 435 // Next can be simplified ( first (already removed) elem in q is the only constant 415 for ( CFFListIterator j=q; j.hasItem(); j++ ){ 436 for ( CFFListIterator j=q; j.hasItem(); j++ ) 437 { 416 438 elem = j.getItem().factor(); 417 439 if ( getNumVars(elem) > 0 ) … … 424 446 // the initial of poly f wrt to the order of the variables 425 447 static CanonicalForm 426 inital( const CanonicalForm &f ){ 448 inital( const CanonicalForm &f ) 449 { 427 450 CanonicalForm leadcoeff; 428 451 429 452 if ( cls(f) == 0 ) {return f.genOne(); } 430 else { 453 else 454 { 431 455 leadcoeff = LC(f,lvar(f)); 432 456 // if ( leadcoeff != 0 ) … … 873 897 /* 874 898 $Log: not supported by cvs2svn $ 899 Revision 1.13 2006/06/19 13:37:47 Singular 900 *hannes: more CS renamed 901 875 902 Revision 1.12 2006/05/16 14:46:49 Singular 876 903 *hannes: gcc 4.1 fixes -
libfac/factor/Factor.cc
rc3c515 r38e7b3 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.2 3 2006-05-16 14:46:49Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.24 2007-05-15 14:46:48 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 /////////////////////////////////////////////////////////////////////////////// … … 343 343 if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less 344 344 if ( SqrFreeTest(g,1) ) // poly is sqrfree 345 if ( mygcd(g,g.deriv()) == 1 ) // Discriminante != 0345 if ( gcd(g,g.deriv()) == 1 ) // Discriminante != 0 346 346 return 1; 347 347 return 0; … … 431 431 /////////////////////////////////////////////////////////////// 432 432 static int 433 try_specializePoly(const CanonicalForm & f, const Variable & Extension, int deg, SFormList & Substitutionlist, int ii,int j){ 433 try_specializePoly(const CanonicalForm & f, const Variable & Extension, int deg, SFormList & Substitutionlist, int ii,int j) 434 { 434 435 int ok,i= ii; 435 436 CanonicalForm ff= f; … … 440 441 } 441 442 442 if ( degree(Extension) > 0 ){ // working over Extensions 443 if ( degree(Extension) > 0 ) 444 { // working over Extensions 443 445 DEBOUTLN(CERR, "try_specializePoly: working over Extensions: ", Extension); 444 AlgExtGenerator g(Extension); 445 for ( int k=i ; k<j ; k++ ){ // try to find specialization for all 446 // variables (# = k ) beginning with the 446 if (Extension.level() > 0) 447 { 448 // AlgExtGenerator g(Extension,minpoly ); 449 // for ( int k=i ; k<j ; k++ ) // try to find specialization for all 450 // { // variables (# = k ) beginning with the 451 // // starting value i 452 // ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g ); 453 // if ( ! ok ) return 0; // we failed 454 // } 455 printf("libfac: try_specializePoly: extension level >0\n"); 456 return 0; // we failed 457 } 458 else 459 { 460 AlgExtGenerator g(Extension); 461 for ( int k=i ; k<j ; k++ ) // try to find specialization for all 462 { // variables (# = k ) beginning with the 447 463 // starting value i 448 ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g ); 449 if ( ! ok ) return 0; // we failed 464 ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g ); 465 if ( ! ok ) return 0; // we failed 466 } 450 467 } 451 468 } … … 658 675 ff = f.deriv(); 659 676 TIMING_START(discr_time); 660 ffuni = mygcd(f,ff);677 ffuni = gcd(f,ff); 661 678 TIMING_END(discr_time); 662 679 if ( !(ffuni.isOne()) ){ //discriminante nonzero: split poly … … 692 709 lt = LC(f); 693 710 DEBOUTLN(CERR, "Leading term: ", lt); 694 if ( lt != f.genOne() ){ 711 if ( lt != f.genOne() ) 712 { 695 713 // make the polynomial monic in the main variable 696 714 ff = make_monic(f,lt); ffuni = ff; … … 702 720 success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, alpha, Substitutionlist,UnivariateFactorlist); 703 721 DEBOUTLN(CERR, "Returned from evaluate: success: ", success); 704 for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ ){ 722 for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ ) 723 { 705 724 DEBOUTLN(CERR, "Substituting ", ii.getItem().factor()); 706 725 DEBOUTLN(CERR, " with value: ", ii.getItem().exp()); 707 726 } 708 727 709 if ( success==0 ){ // evalute wasn't successfull 728 if ( success==0 ) // evalute wasn't successfull 729 { 710 730 success= specializePoly(ffuni,Extension,degree(ff),Substitutionlist,1,getNumVars(compress(ff,m))); 711 731 DEBOUTLN(CERR, "Returned from specializePoly: success: ", success); 712 if (success == 0 ){ // No spezialisation could be found 732 if (success == 0 ) // No spezialisation could be found 733 { 713 734 #ifdef HAVE_SINGULAR_ERROR 714 735 WarnS("libfac: Factorize: ERROR: Not able to find a valid specialization!"); … … 731 752 ffuni = substitutePoly(ff,Substitutionlist); 732 753 // We now have an univariat poly; factorize that 733 if ( degree(Extension) == 0 ){ 754 if ( degree(Extension) == 0 ) 755 { 734 756 DEBOUTMSG(CERR, "Univ. Factorization over the ground field"); 735 757 UnivariateFactorlist = factorize(ffuni,1); // univ. poly is sqr-free! 736 758 } 737 else{ 759 else 760 { 738 761 DEBOUTLN(CERR, "Univ. Factorization over extension of degree ", 739 762 degree(getMipo(Extension,'x')) ); … … 748 771 } 749 772 } 750 else{ 773 else 774 { 751 775 ffuni = substitutePoly(ff,Substitutionlist); 752 776 } 753 777 TIMING_END(evaluate_time); 754 if (UnivariateFactorlist.length() == 1){ // poly is irreduzibel 778 if (UnivariateFactorlist.length() == 1) 779 { // poly is irreduzibel 755 780 DEBOUTLN(CERR, "Univ. poly is irreduzible: ", UnivariateFactorlist); 756 781 Outputlist.append(CFFactor(F,1)); 757 782 return Outputlist; 758 783 } 759 else{ // we have factors 784 else 785 { // we have factors 760 786 DEBOUTSL(CERR); 761 787 DEBOUT(CERR, "Univariate poly has " , UnivariateFactorlist.length()); … … 812 838 /////////////////////////////////////////////////////////////// 813 839 int find_mvar(const CanonicalForm &f); 814 CFFList 815 Factorize(const CanonicalForm & F, int is_SqrFree ){840 CFFList Factorize(const CanonicalForm & F, int is_SqrFree ) 841 { 816 842 CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2; 817 843 ListIterator<CFFactor> i,j; … … 828 854 DEBOUTMSG(CERR, rcsid); 829 855 DEBOUTLN(CERR, "Called with F= ", F); 830 if ( getCharacteristic() == 0 ) { // char == 0 856 if ( getCharacteristic() == 0 ) 857 { // char == 0 831 858 TIMING_START(factorize_time); 832 859 //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n"; … … 858 885 /////// 859 886 // if ( ! SqrFreeTest(F) ){ 860 if ( ! is_SqrFree ){ 887 if ( ! is_SqrFree ) 888 { 861 889 TIMING_START(sqrfree_time); 862 890 SqrFreeList = InternalSqrFree(F) ; // first sqrfree the polynomial … … 874 902 SqrFreeList.append(CFFactor(F,1)); 875 903 DEBOUTLN(CERR, "InternalSqrFreeList= ", SqrFreeList); 876 for ( i=SqrFreeList; i.hasItem(); i++ ){ 904 for ( i=SqrFreeList; i.hasItem(); i++ ) 905 { 877 906 DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor()); 878 907 // We need a compress on each list item ! Maybe we have less variables! … … 882 911 Outputlist.append( CFFactor(g,1) ) ; 883 912 else// a real polynomial 884 if ( g.isUnivariate() ){ 913 if ( g.isUnivariate() ) 914 { 885 915 Intermediatelist=factorize(g,1); // poly is sqr-free! 886 916 for ( j=Intermediatelist; j.hasItem(); j++ ) … … 888 918 Outputlist.append( CFFactor( m(j.getItem().factor()),exp*j.getItem().exp())); 889 919 } 890 else{ // multivariate polynomial 891 if ( g.isHomogeneous() ){ 920 else 921 { // multivariate polynomial 922 if ( g.isHomogeneous() ) 923 { 892 924 DEBOUTLN(CERR, "Poly is homogeneous! : ", g); 893 925 // Now we can substitute one variable to 1, factorize and then … … 911 943 DEBOUTLN(CERR, "Outputlist is ", Outputlist); 912 944 for ( i=Outputlist; i.hasItem(); i++ ) 913 if ( level(i.getItem().factor()) > 0 ){ 945 if ( level(i.getItem().factor()) > 0 ) 946 { 914 947 unit = lc(i.getItem().factor()); 915 if ( getNumVars(unit) == 0 ){ // a constant; possibly 1 948 if ( getNumVars(unit) == 0 ) 949 { // a constant; possibly 1 916 950 Outputlist2.append(CFFactor(i.getItem().factor()/unit , i.getItem().exp())); 917 951 g *=power(i.getItem().factor()/unit,i.getItem().exp()); 918 952 } 919 else{ 953 else 954 { 920 955 Outputlist2.append(i.getItem()); 921 956 g *=power(i.getItem().factor(),i.getItem().exp()); … … 959 994 /////////////////////////////////////////////////////////////// 960 995 CFFList 961 Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree ){ 996 Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree ) 997 { 962 998 CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2; 963 999 ListIterator<CFFactor> i,j; … … 1132 1168 /* 1133 1169 $Log: not supported by cvs2svn $ 1170 Revision 1.23 2006/05/16 14:46:49 Singular 1171 *hannes: gcc 4.1 fixes 1172 1134 1173 Revision 1.22 2006/04/28 13:46:29 Singular 1135 1174 *hannes: better tests for 0, 1 -
libfac/factor/MVMultiHensel.cc
rc3c515 r38e7b3 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1. 9 2006-05-1614:46:49 Singular Exp $";4 // static char * rcsid = "$Id: MVMultiHensel.cc,v 1.10 2007-05-15 14:46:49 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 29 29 #ifdef SINGULAR 30 30 #define HAVE_SINGULAR_ERROR 31 #ifndef NOSTREAMIO 32 void out_cf(char *s1,const CanonicalForm &f,char *s2); 33 #endif 31 34 #endif 32 35 33 36 #ifdef HAVE_SINGULAR_ERROR 34 extern "C" { void WerrorS(char *); } 37 extern "C" 38 { 39 void WerrorS(char *); 40 void Werror(const char *fmt, ...); 41 } 35 42 #endif 36 43 … … 97 104 ia[ix].calculated=false; 98 105 ia[ix].poly=0; 99 } 106 } 100 107 } 101 108 // internal data representation … … 111 118 /////////////////////////////////////////////////////////////// 112 119 static DiophantForm 113 diophant( int levelU , const CanonicalForm & F1 , const CanonicalForm & F2 , int i , RememberArray & A, RememberArray & B ) { 120 diophant( int levelU , const CanonicalForm & F1 , const CanonicalForm & F2 , int i , RememberArray & A, RememberArray & B ) 121 { 114 122 DiophantForm Retvalue; 115 123 CanonicalForm s,t,q,r; … … 121 129 // Did we solve the diophantine equation yet? 122 130 // If so, return the calculated values 123 if (A.checksize(i) && A[i].calculated && B[i].calculated ){ 131 if (A.checksize(i) && A[i].calculated && B[i].calculated ) 132 { 124 133 Retvalue.One=A[i].poly; 125 134 Retvalue.Two=B[i].poly; … … 128 137 129 138 // Degrees ok? degree(F1,mainvar) + degree(F2,mainvar) <= i ? 130 if ( (degree(F1,levelU) + degree(F2,levelU) ) <= i ) { 139 if ( (degree(F1,levelU) + degree(F2,levelU) ) <= i ) 140 { 131 141 #ifdef HAVE_SINGULAR_ERROR 132 WerrorS("libfac: diophant ERROR: degree too large! "); 142 Werror("libfac: diophant ERROR: degree too large! (%d + %d <= %d)",degree(F1,levelU), degree(F2,levelU), i); 143 //out_cf("F1:",F1,"\n"); 144 //out_cf("F2:",F2,"\n"); 133 145 #else 134 146 #ifndef NOSTREAMIO … … 143 155 } 144 156 145 if ( i == 0 ) { // call the extended gcd 157 if ( i == 0 ) 158 { // call the extended gcd 146 159 r=extgcd(F1,F2,s,t); 147 160 // check if gcd(F1,F2) <> 1 , i.e. F1 and F2 are not relatively prime 148 if ( ! r.isOne() ){ 161 if ( ! r.isOne() ) 162 { 149 163 #ifdef HAVE_SINGULAR_ERROR 150 164 WerrorS("libfac: diophant ERROR: F1 and F2 are not relatively prime! "); 165 //out_cf("F1:",F1,"\n"); 166 //out_cf("F2:",F2,"\n"); 151 167 #else 152 168 #ifndef NOSTREAMIO … … 162 178 Retvalue.One = s; Retvalue.Two = t; 163 179 } 164 else { // recursively call diophant 180 else 181 { // recursively call diophant 165 182 Retvalue=diophant(levelU,F1,F2,i-1,A,B); 166 183 Retvalue.One *= x; // createVar(levelU,1); … … 168 185 // Check degrees. 169 186 170 if ( degree(Retvalue.One,levelU) > degree(F2,levelU) ){ 187 if ( degree(Retvalue.One,levelU) > degree(F2,levelU) ) 188 { 171 189 // Make degree(Retvalue.one,mainvar) < degree(F2,mainvar) 172 190 divrem(Retvalue.One,F2,q,r); 173 191 Retvalue.One = r; Retvalue.Two += F1*q; 174 192 } 175 else { 176 if ( degree(Retvalue.Two,levelU) >= degree(F1,levelU) ){ 193 else 194 { 195 if ( degree(Retvalue.Two,levelU) >= degree(F1,levelU) ) 196 { 177 197 // Make degree(Retvalue.Two,mainvar) <= degree(F1,mainvar) 178 198 divrem(Retvalue.Two,F1,q,r); … … 430 450 /* 431 451 $Log: not supported by cvs2svn $ 452 Revision 1.9 2006/05/16 14:46:49 Singular 453 *hannes: gcc 4.1 fixes 454 432 455 Revision 1.8 2002/07/30 15:11:19 Singular 433 456 *hannes: minor cleanups -
libfac/factor/SqrFree.cc
rc3c515 r38e7b3 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1.1 0 2006-05-16 14:46:50Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.11 2007-05-15 14:46:49 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 /////////////////////////////////////////////////////////////////////////////// … … 149 149 // Next: it would be best to have a *univariate* gcd-test which returns 150 150 // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials ) 151 g = mygcd(f,g);151 g = gcd(f,g); 152 152 if ( g.isOne() || (-g).isOne() ) return 1; 153 153 else … … 182 182 // Next: it would be best to have a *multivariate* gcd-test which returns 183 183 // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials ) 184 g= mygcd(f,g);184 g= gcd(f,g); 185 185 if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ; 186 186 else return 0 ; … … 294 294 } 295 295 g = f.deriv(); 296 DEBOUTLN(CERR, "calculating mygcd of ", f);296 DEBOUTLN(CERR, "calculating gcd of ", f); 297 297 DEBOUTLN(CERR, " and ", g); 298 h = mygcd(f,pp(g)); h /= lc(h);299 DEBOUTLN(CERR," mygcd(f,g)= ",h);298 h = gcd(f,pp(g)); h /= lc(h); 299 DEBOUTLN(CERR,"gcd(f,g)= ",h); 300 300 if ( (h.isOne()) || ( h==f) || ((-h).isOne()) || getNumVars(h)==0 ) { // no common factor 301 301 Outputlist= myappend(Outputlist,CFFactor(f,1)) ; … … 415 415 /* 416 416 $Log: not supported by cvs2svn $ 417 Revision 1.10 2006/05/16 14:46:50 Singular 418 *hannes: gcc 4.1 fixes 419 417 420 Revision 1.9 2006/04/28 13:46:29 Singular 418 421 *hannes: better tests for 0, 1 -
libfac/factor/helpstuff.h
rc3c515 r38e7b3 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: helpstuff.h,v 1. 3 1997-09-12 07:19:57Singular Exp $4 // $Id: helpstuff.h,v 1.4 2007-05-15 14:46:49 Singular Exp $ 5 5 //////////////////////////////////////////////////////////// 6 6 #ifndef HELPSTUFF_H … … 27 27 return (a>b ? a:b); 28 28 } 29 //////////////////30 // For testing //31 //////////////////32 #ifdef SPARSEGCD33 #include "gcd.h"34 #define mygcd(f,g) \35 ((CanonicalForm) sparsemod( f, g ))36 #else37 #define mygcd(f,g) \38 ((CanonicalForm) gcd( f, g ))39 #endif40 41 29 #endif /* HELPSTUFF_H */ 42 30 … … 44 32 /* 45 33 $Log: not supported by cvs2svn $ 34 Revision 1.3 1997/09/12 07:19:57 Singular 35 * hannes/michael: libfac-0.3.0 36 46 37 Revision 1.2 1997/04/25 22:23:49 michael 47 38 Version for libfac-0.2.1 -
libfac/factor/test.cc
rc3c515 r38e7b3 1 //static char rcsid[] = "@(#) $Id: test.cc,v 1. 2 1997-06-09 15:56:11Singular Exp $";1 //static char rcsid[] = "@(#) $Id: test.cc,v 1.3 2007-05-15 14:46:49 Singular Exp $"; 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // CLAP - Includes … … 27 27 // cout << SqrFree(f) << endl << endl; 28 28 //cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl; 29 //cout << " mygcd(f,f.deriv())= mygcd(" << f << "," << f.deriv() << ")= " << mygcd(f,f.deriv()) << endl;29 //cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl; 30 30 Factorlist = Factorize( f ); 31 31 cout << Factorlist ;//<< endl;
Note: See TracChangeset
for help on using the changeset viewer.