Changeset 639047e in git for libfac/charset
- Timestamp:
- Aug 19, 2002, 1:11:34 PM (22 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 6acb298d347b4b82e942caa7518a2625dc747c1e
- Parents:
- b1476d0550d3e358e0fcafec0719ae421300980e
- Location:
- libfac/charset
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/charset/alg_factor.cc
rb1476d0 r639047e 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: alg_factor.cc,v 1. 9 2002-07-30 15:16:19 Singular Exp $";5 static char * rcsid = "$Id: alg_factor.cc,v 1.10 2002-08-19 11:11:29 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 19 19 // some CC's need this: 20 20 #include "alg_factor.h" 21 22 //void out_cf(char *s1,const CanonicalForm &f,char *s2); 21 23 22 24 #ifdef ALGFACTORDEBUG … … 360 362 } 361 363 364 CanonicalForm alg_lc(const CanonicalForm &f) 365 { 366 if (f.inCoeffDomain()) return f; 367 if (f.level()>0) 368 { 369 return alg_lc(f.LC()); 370 } 371 } 372 362 373 // the heart of the algorithm: the one from Trager 363 374 static CFFList … … 369 380 DEBINCLEVEL(cout,"alg_factor"); 370 381 DEBOUTLN(cout, "alg_factor: f= ", f); 382 //out_cf("start alg_factor:",f,"\n"); 371 383 substlist= simpleextension(Astar, vminpoly, Rstar); 372 384 DEBOUTLN(cout, "alg_factor: substlist= ", substlist); … … 375 387 376 388 sqrf_norm(f, Rstar, vminpoly, s, g, R ); 389 //out_cf("sqrf_norm R:",R,"\n"); 390 //out_cf("sqrf_norm s:",s,"\n"); 391 //out_cf("sqrf_norm g:",g,"\n"); 377 392 DEBOUTLN(cout, "alg_factor: g= ", g); 378 393 DEBOUTLN(cout, "alg_factor: s= ", s); … … 429 444 // undo linear transformation!!!! and then gcd! 430 445 //cout << "algcd(" << g << "," << fnew << ",as" << as << ")" << endl; 431 h= algcd(g,fnew, as, oldord); 446 //out_cf("algcd g=",g,"\n"); 447 //out_cf("algcd fnew=",fnew,"\n"); 448 //h= algcd(g,fnew, as, oldord); 449 //if (as.length() >1) 450 // h= algcd(g,fnew, as, oldord); 451 //else 452 h=alg_gcd(g,fnew,as); 453 //out_cf(" -> algcd=",algcd(g,fnew, as, oldord),"\n"); 454 //out_cf(" -> alg_gcd=",alg_gcd(g,fnew,as),"\n"); 432 455 //cout << "algcd result:" << h << endl; 433 456 DEBOUTLN(cout, " alg_factor: h= ", h); … … 446 469 if (degree(g, f.mvar())>0){ L.append(CFFactor(g,1)); } 447 470 } 448 DEBOUTLN(cout, "alg_factor: L= ", L); 471 CFFList LL; 472 if (getCharacteristic()>0) 473 { 474 CFFListIterator i=L; 475 CanonicalForm c_fac=1; 476 CanonicalForm c; 477 for(;i.hasItem(); i++ ) 478 { 479 CanonicalForm ff=i.getItem().factor(); 480 c=alg_lc(ff); 481 int e=i.getItem().exp(); 482 ff/=c; 483 if (!ff.isOne()) LL.append(CFFactor(ff,e)); 484 while (e>0) { c_fac*=c;e--; } 485 } 486 if (!c_fac.isOne()) LL.insert(CFFactor(c_fac,1)); 487 } 488 else 489 { 490 LL=L; 491 } 492 //CFFListIterator i=LL; 493 //for(;i.hasItem(); i++ ) 494 // out_cf("end alg_f:",i.getItem().factor(),"\n"); 495 //printf("end alg_factor\n"); 496 DEBOUTLN(cout, "alg_factor: L= ", LL); 449 497 DEBDECLEVEL(cout,"alg_factor"); 450 return L ;498 return LL; 451 499 } 452 500 … … 597 645 // This is for now. we need alg_sqrfree implemented! 598 646 //cout << "algcd(" << f << "," << f.deriv() << " as:" << Astar <<endl; 599 CanonicalForm Fgcd= algcd(f,f.deriv(),Astar,gcdord); 647 //CanonicalForm Fgcd= algcd(f,f.deriv(),Astar,gcdord); 648 CanonicalForm Fgcd; 649 //if (Astar.length() >1) 650 // Fgcd= algcd(f,f.deriv(),Astar,gcdord); 651 //else 652 Fgcd= alg_gcd(f,f.deriv(),Astar); 653 //out_cf("algcd:",algcd(f,f.deriv(),Astar,gcdord),"\n"); 654 //out_cf("alg_gcd:",alg_gcd(f,f.deriv(),Astar),"\n"); 600 655 // cout << "algcd result:" << Fgcd << endl; 601 656 if ( Fgcd == 0 ) DEBOUTMSG(cerr, "WARNING: p'th root ?"); … … 683 738 /* 684 739 $Log: not supported by cvs2svn $ 740 Revision 1.9 2002/07/30 15:16:19 Singular 741 *hannes: fix for alg. extension 742 685 743 Revision 1.8 2001/08/06 08:32:53 Singular 686 744 * hannes: code cleanup -
libfac/charset/algfactor.cc
rb1476d0 r639047e 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 static char * rcsid = "$Id: algfactor.cc,v 1. 5 2001-06-27 13:58:05Singular Exp $";5 static char * rcsid = "$Id: algfactor.cc,v 1.6 2002-08-19 11:11:30 Singular Exp $"; 6 6 //////////////////////////////////////////////////////////// 7 7 // FACTORY - Includes … … 354 354 DEBOUT(cout, ",", fp(substback,vf)); 355 355 DEBOUT(cout, ") over K_r wrt ", vf); 356 fp= algcd(g,fp(substback,vf), as, oldord); 356 fp=alg_gcd(g,fp(substback,vf), as); 357 //fp= algcd(g,fp(substback,vf), as, oldord); 357 358 DEBOUTLN(cout, " = ", fp); 358 359 if ( degree(fp,vf) > 0 ){ //otherwise it's a constant … … 372 373 DEBOUT(cout, ",", fp(substback,vf)); 373 374 DEBOUT(cout, ") over K_r wrt ", vf); 374 fp= algcd(g,fp(substback,vf), as, oldord); 375 fp= alg_gcd(g,fp(substback,vf), as); 376 //fp= algcd(g,fp(substback,vf), as, oldord); 375 377 DEBOUTLN(cout, " = ", fp); 376 378 if ( degree(fp,vf) > 0 ){ //otherwise it's a constant … … 448 450 /* 449 451 $Log: not supported by cvs2svn $ 452 Revision 1.5 2001/06/27 13:58:05 Singular 453 *hannes/GP: debug newfactoras, char_series, ... 454 450 455 Revision 1.4 2001/06/21 14:57:04 Singular 451 456 *hannes/GP: Factorize, newfactoras, ... -
libfac/charset/algfactor.h
rb1476d0 r639047e 3 3 // emacs edit mode for this file is -*- C++ -*- 4 4 //////////////////////////////////////////////////////////// 5 // $Id: algfactor.h,v 1. 2 1997-09-12 07:19:39Singular Exp $5 // $Id: algfactor.h,v 1.3 2002-08-19 11:11:30 Singular Exp $ 6 6 //////////////////////////////////////////////////////////// 7 7 … … 16 16 CFFList cfactor(const CanonicalForm & f, const CFList & as, int success ); 17 17 /*BEGINPUBLIC*/ 18 int hasVar(const CanonicalForm &f, const Variable &v); 18 19 /*ENDPUBLIC*/ 19 20 -
libfac/charset/charset.cc
rb1476d0 r639047e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: charset.cc,v 1. 9 2001-08-08 14:26:54Singular Exp $";4 static char * rcsid = "$Id: charset.cc,v 1.10 2002-08-19 11:11:31 Singular Exp $"; 5 5 ///////////////////////////////////////////////////////////// 6 6 // FACTORY - Includes … … 540 540 DEBOUT(cout, "irras: factoring: ", elem); 541 541 if ( degree(elem) > 1 ) // linear poly's are irreduzible 542 { 542 543 qs = Factorize(elem); 544 } 543 545 else{ 544 546 qs=(CFFactor(elem,1)); … … 581 583 break; 582 584 } 583 else584 {585 #ifdef HAVE_SINGULAR_ERROR586 WarnS("libfac: Factoring over algebraic function field required!");587 #else588 #ifndef NOSTREAMIO589 cerr << "libfac: Factoring over algebraic function field!" << endl;590 #endif591 #endif592 }593 585 } 594 586 } … … 602 594 /* 603 595 $Log: not supported by cvs2svn $ 596 Revision 1.9 2001/08/08 14:26:54 Singular 597 *hannes: Dan's HAVE_SINGULAR_ERROR 598 604 599 Revision 1.8 2001/08/06 08:32:53 Singular 605 600 * hannes: code cleanup -
libfac/charset/csutil.cc
rb1476d0 r639047e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: csutil.cc,v 1. 6 2002-01-21 09:11:07Singular Exp $";4 static char * rcsid = "$Id: csutil.cc,v 1.7 2002-08-19 11:11:31 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); 17 extern CanonicalForm alg_lc(const CanonicalForm &f); 18 extern int hasAlgVar(const CanonicalForm &f); 16 19 17 20 static bool … … 651 654 } 652 655 656 #if 0 657 static CanonicalForm alg_lc(const CanonicalForm &f, const CFList as) 658 { 659 for(CFListIterator i=as; i.hasItem(); i++) 660 { 661 if (f.mvar()==i.getItem().mvar()) return f; 662 } 663 if (f.level()>0) 664 { 665 return alg_lc(f.LC(),as); 666 } 667 return CanonicalForm(1); 668 } 669 #endif 670 671 CanonicalForm alg_gcd(const CanonicalForm & fff, const CanonicalForm &ggg, 672 const CFList &as) 673 { 674 //out_cf("alg_gcd(",fff," , "); 675 //out_cf("",ggg,")\n"); 676 CanonicalForm f=fff; 677 CanonicalForm g=ggg; 678 CanonicalForm res; 679 // does as appear in f and g ? 680 bool has_alg_var=false; 681 for ( CFListIterator j=as;j.hasItem(); j++ ) 682 { 683 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 } 687 if (!has_alg_var) 688 { 689 if ((hasAlgVar(f)) 690 || (hasAlgVar(g))) 691 { 692 Varlist ord; 693 for ( CFListIterator j=as;j.hasItem(); j++ ) 694 ord.append(j.getItem().mvar()); 695 res=algcd(f,g,as,ord); 696 } 697 else 698 res=gcd(f,g); 699 //out_cf("gcd=",res,"\n"); 700 return res; 701 } 702 703 int mvf=f.level(); 704 int mvg=g.level(); 705 if (mvg > mvf) 706 { 707 CanonicalForm tmp=f; f=g; g=tmp; 708 int tmp2=mvf; mvf=mvg; mvg=tmp2; 709 } 710 if (g.inBaseDomain() || f.inBaseDomain()) 711 { 712 //printf("const\n"); 713 return CanonicalForm(1); 714 } 715 716 // gcd of all coefficients: 717 CFIterator i=f; 718 CanonicalForm c_gcd=i.coeff(); i++; 719 while( i.hasTerms()) 720 { 721 c_gcd=alg_gcd(i.coeff(),c_gcd,as); 722 if (c_gcd.inBaseDomain()) break; 723 i++; 724 } 725 //printf("f.mvar=%d (%d), g.mvar=%d (%d)\n",f.level(),mvf,g.level(),mvg); 726 if (mvf!=mvg) // => mvf > mvg 727 { 728 res=alg_gcd(g,c_gcd,as); 729 //out_cf("alg_gcd1=",res,"\n"); 730 return res; 731 } 732 if (!c_gcd.inBaseDomain()) 733 { 734 i=g; 735 while( i.hasTerms()) 736 { 737 c_gcd=alg_gcd(i.coeff(),c_gcd,as); 738 if (c_gcd.inBaseDomain()) break; 739 i++; 740 } 741 } 742 743 f/=c_gcd; 744 g/=c_gcd; 745 746 CanonicalForm r=1; 747 CFList gg; 748 while (!(r.isZero())) 749 { 750 //printf("f.mvar=%d, g.mvar=%d\n",f.level(),g.level()); 751 gg=as; 752 gg.append(g); 753 //out_cf("Prem(",f," , "); 754 //out_cf("",g,")\n"); 755 if (g.inCoeffDomain()) r=0; 756 else if (g.level()==f.level()) r=Prem(f,gg); 757 else 758 { 759 // g and f have different levels 760 return c_gcd; 761 } 762 //out_cf("->",r,"\n"); 763 f=g; 764 g=r; 765 } 766 if (degree(f,Variable(mvg))==0) 767 { 768 // remark: mvf == mvg == f.level() ==g.level() 769 //out_cf("c_gcd=",c_gcd,"\n"); 770 return c_gcd; 771 } 772 //out_cf("f=",f,"\n"); 773 i=f; 774 CanonicalForm k=i.coeff(); i++; 775 //out_cf("k=",k,"\n"); 776 while( i.hasTerms()) 777 { 778 if (k.inCoeffDomain()) break; 779 k=alg_gcd(i.coeff(),k,as); 780 //out_cf("k=",k,"\n"); 781 i++; 782 } 783 f/=k; 784 res=c_gcd*f; 785 CanonicalForm r_lc=alg_lc(res); 786 res/=r_lc; 787 //CanonicalForm r_lc=alg_lc(res,as); 788 //res/=r_lc; 789 //out_cf("alg_gcd2=",res,"\n"); 790 return res; 791 } 792 653 793 /* 654 794 $Log: not supported by cvs2svn $ 795 Revision 1.6 2002/01/21 09:11:07 Singular 796 * hannes: handle empty set in removecontent 797 655 798 Revision 1.5 2001/06/21 14:57:04 Singular 656 799 *hannes/GP: Factorize, newfactoras, ... -
libfac/charset/csutil.h
rb1476d0 r639047e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: csutil.h,v 1. 3 1997-09-12 07:19:42 Singular Exp $4 // $Id: csutil.h,v 1.4 2002-08-19 11:11:32 Singular Exp $ 5 5 //////////////////////////////////////////////////////////// 6 6 … … 9 9 10 10 #include <factory.h> 11 #include "algfactor.h" 11 12 #include <tmpl_inst.h> 12 13 … … 53 54 CanonicalForm Prem( const CanonicalForm &f, const CFList &L ); 54 55 CFList Prem( const CFList &AS, const CFList &L ); 56 CanonicalForm alg_gcd(const CanonicalForm &, const CanonicalForm &, const CFList &); 55 57 /*ENDPUBLIC*/ 56 58 CanonicalForm divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as); … … 79 81 /* 80 82 $Log: not supported by cvs2svn $ 83 Revision 1.3 1997/09/12 07:19:42 Singular 84 * hannes/michael: libfac-0.3.0 85 81 86 Revision 1.3 1997/04/25 22:51:48 michael 82 87 Version for libfac-0.2.1
Note: See TracChangeset
for help on using the changeset viewer.