Changeset 9b25e7e in git
- Timestamp:
- Oct 24, 2002, 7:22:22 PM (21 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 616214197b0dbd8973606076355c2d6ccde48f2f
- Parents:
- e44bd88b22a2439b301aba30f2adc6bb930bbefc
- Location:
- libfac/charset
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/charset/alg_factor.cc
re44bd88 r9b25e7e 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: alg_factor.cc,v 1.1 0 2002-08-19 11:11:29Singular Exp $";5 static char * rcsid = "$Id: alg_factor.cc,v 1.11 2002-10-24 17:22:21 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 20 20 #include "alg_factor.h" 21 21 22 //void out_cf(char *s1,const CanonicalForm &f,char *s2);22 void out_cf(char *s1,const CanonicalForm &f,char *s2); 23 23 24 24 #ifdef ALGFACTORDEBUG … … 198 198 Variable X; 199 199 if (getAlgVar(R,X)) 200 { 200 { 201 201 if (R.isUnivariate()) 202 203 else 202 testlist=factorize( R, X ); 203 else 204 204 testlist= Factorize(R, X, 0); 205 205 } 206 else 206 else 207 207 testlist= Factorize(R); 208 208 DEBOUTLN(cout, "testlist= ", testlist); … … 369 369 return alg_lc(f.LC()); 370 370 } 371 } 371 } 372 372 373 373 // the heart of the algorithm: the one from Trager … … 400 400 //cout << "alg: "<< X << " mipo=" << getMipo(X,Variable('X')) <<endl; 401 401 if (R.isUnivariate()) 402 { 403 DEBOUTLN(cout, "alg_factor: factorize( ", R); 402 404 Factorlist = factorize( R, X ); 405 } 403 406 else 404 407 { … … 407 410 CanonicalForm mipo=getMipo(X,XX); 408 411 CFList as(mipo); 412 DEBOUTLN(cout, "alg_factor: newfactoras( ", R); 409 413 Factorlist = newfactoras(R, as , 1); 410 414 #else 411 415 // factor R over k 416 DEBOUTLN(cout, "alg_factor: Factorize( ", R); 412 417 Factorlist = Factorize(R); 413 418 #endif … … 417 422 { 418 423 // factor R over k 424 DEBOUTLN(cout, "alg_factor: Factorize( ", R); 419 425 Factorlist = Factorize(R); 420 426 } … … 444 450 // undo linear transformation!!!! and then gcd! 445 451 //cout << "algcd(" << g << "," << fnew << ",as" << as << ")" << endl; 446 447 452 //out_cf("algcd g=",g,"\n"); 453 //out_cf("algcd fnew=",fnew,"\n"); 448 454 //h= algcd(g,fnew, as, oldord); 449 455 //if (as.length() >1) 450 456 // h= algcd(g,fnew, as, oldord); 451 452 453 454 457 //else 458 h=alg_gcd(g,fnew,as); 459 //out_cf(" -> algcd=",algcd(g,fnew, as, oldord),"\n"); 460 //out_cf(" -> alg_gcd=",alg_gcd(g,fnew,as),"\n"); 455 461 //cout << "algcd result:" << h << endl; 456 462 DEBOUTLN(cout, " alg_factor: h= ", h); … … 647 653 //CanonicalForm Fgcd= algcd(f,f.deriv(),Astar,gcdord); 648 654 CanonicalForm Fgcd; 649 655 //if (Astar.length() >1) 650 656 // Fgcd= algcd(f,f.deriv(),Astar,gcdord); 651 652 653 654 657 //else 658 Fgcd= alg_gcd(f,f.deriv(),Astar); 659 //out_cf("algcd:",algcd(f,f.deriv(),Astar,gcdord),"\n"); 660 //out_cf("alg_gcd:",alg_gcd(f,f.deriv(),Astar),"\n"); 655 661 // cout << "algcd result:" << Fgcd << endl; 656 662 if ( Fgcd == 0 ) DEBOUTMSG(cerr, "WARNING: p'th root ?"); … … 738 744 /* 739 745 $Log: not supported by cvs2svn $ 746 Revision 1.10 2002/08/19 11:11:29 Singular 747 * hannes/pfister: alg_gcd etc. 748 740 749 Revision 1.9 2002/07/30 15:16:19 Singular 741 750 *hannes: fix for alg. extension -
libfac/charset/csutil.cc
re44bd88 r9b25e7e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: csutil.cc,v 1. 7 2002-08-19 11:11:31Singular Exp $";4 static char * rcsid = "$Id: csutil.cc,v 1.8 2002-10-24 17:22:22 Singular Exp $"; 5 5 ///////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 14 14 // Charset - Includes 15 15 #include "csutil.h" 16 //extern void out_cf(char *s1,const CanonicalForm &f,char *s2);16 extern void out_cf(char *s1,const CanonicalForm &f,char *s2); 17 17 extern CanonicalForm alg_lc(const CanonicalForm &f); 18 18 extern int hasAlgVar(const CanonicalForm &f); … … 660 660 { 661 661 if (f.mvar()==i.getItem().mvar()) return f; 662 } 662 } 663 663 if (f.level()>0) 664 664 { … … 672 672 const CFList &as) 673 673 { 674 CanonicalForm f=fff; 675 CanonicalForm g=ggg; 676 f=Prem(f,as); 677 g=Prem(g,as); 678 if ( f.isZero() ) 679 { 680 if ( g.lc().sign() < 0 ) return -g; 681 else return g; 682 } 683 else if ( g.isZero() ) 684 { 685 if ( f.lc().sign() < 0 ) return -f; 686 else return f; 687 } 674 688 //out_cf("alg_gcd(",fff," , "); 675 689 //out_cf("",ggg,")\n"); 676 CanonicalForm f=fff;677 CanonicalForm g=ggg;678 690 CanonicalForm res; 679 691 // does as appear in f and g ? … … 682 694 { 683 695 Variable v=j.getItem().mvar(); 684 if (hasVar(f,v)) {has_alg_var=true; break;} 685 if (hasVar(g,v)) {has_alg_var=true; break;} 686 } 696 if (hasVar(f,v)) {has_alg_var=true; /*break;*/} 697 if (hasVar(g,v)) {has_alg_var=true; /*break;*/} 698 //out_cf("as:",j.getItem(),"\n"); 699 } 687 700 if (!has_alg_var) 688 701 { … … 698 711 res=gcd(f,g); 699 712 //out_cf("gcd=",res,"\n"); 713 //out_cf("of f=",fff," , "); 714 //out_cf("and g=",ggg,"\n"); 715 700 716 return res; 701 } 717 } 702 718 703 719 int mvf=f.level(); 704 720 int mvg=g.level(); 705 721 if (mvg > mvf) 706 { 722 { 707 723 CanonicalForm tmp=f; f=g; g=tmp; 708 724 int tmp2=mvf; mvf=mvg; mvg=tmp2; 709 } 725 } 710 726 if (g.inBaseDomain() || f.inBaseDomain()) 711 727 { 712 728 //printf("const\n"); 729 //out_cf("of f=",fff," , "); 730 //out_cf("and g=",ggg,"\n"); 713 731 return CanonicalForm(1); 714 } 715 732 } 733 716 734 // gcd of all coefficients: 717 735 CFIterator i=f; … … 728 746 res=alg_gcd(g,c_gcd,as); 729 747 //out_cf("alg_gcd1=",res,"\n"); 748 //out_cf("of f=",fff," , "); 749 //out_cf("and g=",ggg,"\n"); 730 750 return res; 731 751 } 752 // now: mvf==mvg, f.level()==g.level() 732 753 if (!c_gcd.inBaseDomain()) 733 754 { … … 739 760 i++; 740 761 } 741 } 762 } 742 763 743 764 f/=c_gcd; 744 765 g/=c_gcd; 745 766 767 CFList gg; 746 768 CanonicalForm r=1; 747 CFList gg; 748 while (!(r.isZero())) 769 while (1) 749 770 { 750 771 //printf("f.mvar=%d, g.mvar=%d\n",f.level(),g.level()); 751 772 gg=as; 752 gg.append(g);773 if (!g.inCoeffDomain()) gg.append(g); 753 774 //out_cf("Prem(",f," , "); 754 775 //out_cf("",g,")\n"); 755 if (g.inCoeffDomain()) r=0; 776 if (g.inCoeffDomain()|| g.isZero()) 777 { 778 //printf("in coeff domain:"); 779 if (g.isZero()) { //printf("0\n"); 780 i=f; 781 CanonicalForm f_gcd=i.coeff(); i++; 782 while( i.hasTerms()) 783 { 784 f_gcd=alg_gcd(i.coeff(),f_gcd,as); 785 if (f_gcd.inBaseDomain()) break; 786 i++; 787 } 788 f/=f_gcd; 789 return f*c_gcd; 790 } 791 else { //printf("c\n"); 792 return c_gcd;} 793 } 756 794 else if (g.level()==f.level()) r=Prem(f,gg); 757 795 else 758 796 { 797 //printf("diff. level: %d, %d\n", f.level(), g.level()); 759 798 // g and f have different levels 760 return c_gcd; 799 //out_cf("c_gcd=",c_gcd,"\n"); 800 //out_cf("of f=",fff," , "); 801 //out_cf("and g=",ggg,"\n"); 802 return c_gcd; 761 803 } 762 804 //out_cf("->",r,"\n"); … … 764 806 g=r; 765 807 } 766 if (degree(f,Variable(mvg))==0) 808 if (degree(f,Variable(mvg))==0) 767 809 { 768 810 // remark: mvf == mvg == f.level() ==g.level() 769 811 //out_cf("c_gcd=",c_gcd,"\n"); 812 //out_cf("of f=",fff," , "); 813 //out_cf("and g=",ggg,"\n"); 770 814 return c_gcd; 771 } 815 } 772 816 //out_cf("f=",f,"\n"); 773 817 i=f; … … 781 825 i++; 782 826 } 827 //out_cf("end-k=",k,"\n"); 783 828 f/=k; 829 //out_cf("f/k=",f,"\n"); 784 830 res=c_gcd*f; 785 831 CanonicalForm r_lc=alg_lc(res); … … 788 834 //res/=r_lc; 789 835 //out_cf("alg_gcd2=",res,"\n"); 790 return res; 836 // out_cf("of f=",fff," , "); 837 // out_cf("and g=",ggg,"\n"); 838 //return res; 839 //if (res.level()<fff.level() && res.level() < ggg.level()) 840 // return alg_gcd(alg_gcd(fff,res,as),ggg,as); 841 //else 842 return res; 791 843 } 792 844 793 845 /* 794 846 $Log: not supported by cvs2svn $ 847 Revision 1.7 2002/08/19 11:11:31 Singular 848 * hannes/pfister: alg_gcd etc. 849 795 850 Revision 1.6 2002/01/21 09:11:07 Singular 796 851 * hannes: handle empty set in removecontent
Note: See TracChangeset
for help on using the changeset viewer.