Changeset 639047e in git
- Timestamp:
- Aug 19, 2002, 1:11:34 PM (22 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 6acb298d347b4b82e942caa7518a2625dc747c1e
- Parents:
- b1476d0550d3e358e0fcafec0719ae421300980e
- Location:
- libfac
- Files:
-
- 13 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 -
libfac/factor.h
rb1476d0 r639047e 18 18 //// Note: second argument for Factorize is for internal use only. 19 19 CFFList Factorize( const CanonicalForm & F, int is_SqrFree=0 ) ; 20 CFFList Factorize( const CanonicalForm & F, Variablemipo, int is_SqrFree=0 ) ;20 CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mipo, int is_SqrFree=0 ) ; 21 21 CFFList newfactoras( const CanonicalForm & f, const CFList & as, int success); 22 22 -
libfac/factor/Factor.cc
rb1476d0 r639047e 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.1 3 2002-07-30 17:06:47Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.14 2002-08-19 11:11:32 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 /////////////////////////////////////////////////////////////////////////////// … … 465 465 { 466 466 unilist = factorize(g,Extension); 467 } 467 } 468 468 if (unilist.length() <= minfactors ) { 469 469 minfactors=unilist.length(); … … 521 521 /////////////////////////////////////////////////////////////// 522 522 CFFList 523 Factorized( const CanonicalForm & F, const Variable& alpha, int Mainvar){523 Factorized( const CanonicalForm & F, const CanonicalForm & alpha, int Mainvar){ 524 524 CanonicalForm f,lt,ff,ffuni; 525 Variable Extension=alpha ;525 Variable Extension=alpha.mvar(); 526 526 CFFList Outputlist,UnivariateFactorlist,Outputlist2; 527 527 SFormList Substitutionlist, Evaluationpoint; … … 546 546 TIMING_START(evaluate_time); 547 547 #if 1 548 Outputlist = factorize(F,Extension); 548 if (Extension.level() <0) 549 Outputlist = factorize(F,Extension); 550 else 551 { 552 Variable X=rootOf(alpha); 553 CFFList L=factorize(F,X); 554 CFFListIterator i=L; 555 for(;i.hasItem(); i++ ) 556 { 557 Outputlist.append(CFFactor( 558 replacevar(i.getItem().factor(),X,Extension), 559 i.getItem().exp())); 560 } 561 } 549 562 #else 550 563 Variable X; … … 853 866 swapvar(F,Variable(mv),F.mvar()); 854 867 } 855 868 856 869 DEBDECLEVEL(cout, "Factorize"); 857 870 TIMING_END(factorize_time); … … 874 887 /////////////////////////////////////////////////////////////// 875 888 CFFList 876 Factorize(const CanonicalForm & F, Variableminpoly, int is_SqrFree ){889 Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree ){ 877 890 CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2; 878 891 ListIterator<CFFactor> i,j; … … 889 902 DEBOUTMSG(cout, rcsid); 890 903 DEBOUTLN(cout, "Called with F= ", F); 891 if ( getCharacteristic() == 0 ) { // char == 0 904 if ( getCharacteristic() == 0 ) 905 { // char == 0 892 906 TIMING_START(factorize_time); 893 907 //cout << "Factoring in char=0 of " << F << " = " << Outputlist << endl; 908 #if 0 894 909 // SHOULD: Outputlist= factorize(F,minpoly); 895 910 Outputlist= factorize(F); 911 #else 912 if (minpoly!=0) 913 { 914 CFList as(minpoly); 915 Outputlist = newfactoras( F, as, 1); 916 } 917 else 918 Outputlist=factorize(F); 919 #endif 896 920 // Factorization in char=0 doesn't sometimes return at least two elements!!! 897 921 if ( getNumVars(Outputlist.getFirst().factor()) != 0 ) … … 922 946 if ( ! is_SqrFree ){ 923 947 TIMING_START(sqrfree_time); 924 SqrFreeList = InternalSqrFree(F ) ; // first sqrfree the polynomial948 SqrFreeList = InternalSqrFree(F, minpoly) ; // first sqrfree the polynomial 925 949 // don't use sqrFree(F), factory's internal sqrFree for multiv. 926 950 // Polynomials; it's wrong!! Ex.: char=p f= x^p*(y+1); … … 945 969 else// a real polynomial 946 970 if ( g.isUnivariate() ){ 947 Intermediatelist=factorize(g,minpoly); // poly is sqr-free! 971 Variable alpha=rootOf(minpoly); 972 Intermediatelist=factorize(g,alpha); // poly is sqr-free! 948 973 for ( j=Intermediatelist; j.hasItem(); j++ ) 949 974 //Normally j.getItem().exp() should be 1 950 Outputlist.append( CFFactor( m(j.getItem().factor()),exp*j.getItem().exp())); 975 Outputlist.append( 976 CFFactor( m(replacevar(j.getItem().factor(),alpha,minpoly.mvar())), 977 exp*j.getItem().exp())); 951 978 } 952 979 else{ // multivariate polynomial … … 997 1024 swapvar(F,Variable(mv),F.mvar()); 998 1025 } 999 1026 1000 1027 DEBDECLEVEL(cout, "Factorize"); 1001 1028 TIMING_END(factorize_time); … … 1012 1039 /* 1013 1040 $Log: not supported by cvs2svn $ 1041 Revision 1.13 2002/07/30 17:06:47 Singular 1042 *hannes: uuh - factorize in Q(a)[x] is missing, use Q[a][x]. 1043 1014 1044 Revision 1.12 2002/07/30 15:10:22 Singular 1015 1045 *hannes: added Factorize for alg. ext. -
libfac/factor/Factor.h
rb1476d0 r639047e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: Factor.h,v 1. 4 2002-07-30 15:05:38Singular Exp $4 // $Id: Factor.h,v 1.5 2002-08-19 11:11:33 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef FACTOR_H 7 7 #define FACTOR_H 8 8 CanonicalForm generate_mipo( int degree_of_Extension , const Variable & Extension ); 9 CFFList Factorized( const CanonicalForm & F, const Variable & alpha, int Mainvar=0);9 CFFList Factorized( const CanonicalForm & F, const CanonicalForm & mipo, int Mainvar=0); 10 10 /*BEGINPUBLIC*/ 11 11 CFFList Factorize( const CanonicalForm & F, int is_SqrFree=0 ) ; 12 CFFList Factorize( const CanonicalForm & F, Variablemi, int is_SqrFree=0 ) ;12 CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mi, int is_SqrFree=0 ) ; 13 13 /*ENDPUBLIC*/ 14 14 … … 18 18 /* 19 19 $Log: not supported by cvs2svn $ 20 Revision 1.4 2002/07/30 15:05:38 Singular 21 *hannes: added Factorize for alg. ext. 22 20 23 Revision 1.3 1997/09/12 07:19:47 Singular 21 24 * hannes/michael: libfac-0.3.0 -
libfac/factor/SqrFree.cc
rb1476d0 r639047e 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1. 7 2001-08-08 14:27:38Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.8 2002-08-19 11:11:33 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 /////////////////////////////////////////////////////////////////////////////// … … 35 35 TIMING_DEFINE_PRINT(gcd_time); 36 36 37 38 37 static inline CFFactor 39 38 Powerup( const CFFactor & F , int exp=1){ … … 62 61 if (n==0){ // constant 63 62 if (R.inExtension()) // not in prime field; f over |F(q=p^k) 63 { 64 64 R = power(R,Powerup(p,getGFDegree() - 1)) ; 65 } 65 66 // if f in prime field, do nothing 66 67 return R; … … 71 72 for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++) 72 73 RES += PthRoot( R[i*p] ) * power(x,i); 74 return RES; 75 } 76 77 /////////////////////////////////////////////////////////////// 78 // Compute the Pth root of a polynomial in characteristic p // 79 // f must be a polynomial which we can take the Pth root of. // 80 // Domain is q=p^m , f a uni/multivariate polynomial // 81 /////////////////////////////////////////////////////////////// 82 static CanonicalForm 83 PthRoot( const CanonicalForm & f ,const CanonicalForm & mipo){ 84 CanonicalForm RES, R = f; 85 int n= max(level(R),getNumVars(R)), p= getCharacteristic(); 86 int mipodeg=-1; 87 if (f.level()==mipo.level()) mipodeg=mipo.degree(); 88 else if ((f.level()==1) &&(mipo.level()!=-1000000)) 89 { 90 Variable t; 91 CanonicalForm tt=getMipo(mipo.mvar(),t); 92 mipodeg=degree(tt,t); 93 } 94 95 if ((n==0) 96 ||(mipodeg!=-1)) 97 { // constant 98 if (R.inExtension()) // not in prime field; f over |F(q=p^k) 99 { 100 R = power(R,Powerup(p,getGFDegree() - 1)) ; 101 } 102 else if ((f.level()==mipo.level()) 103 ||((f.level()==1) &&(mipo.level()!=-1000000))) 104 { 105 R = power(R,Powerup(p,mipodeg - 1)) ; 106 R=mod(R, mipo); 107 } 108 // if f in prime field, do nothing 109 return R; 110 } 111 // we assume R is a Pth power here 112 RES = R.genZero(); 113 Variable x(n); 114 for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++) 115 RES += PthRoot( R[i*p], mipo ) * power(x,i); 73 116 return RES; 74 117 } … … 150 193 /////////////////////////////////////////////////////////////// 151 194 static CFFList 152 SqrFreed( const CanonicalForm & r ){195 SqrFreed( const CanonicalForm & r , const CanonicalForm &mipo=0){ 153 196 CanonicalForm h, g, f = r; 154 197 CFFList Outputlist; … … 165 208 // and continue computations with pp(f) 166 209 for (int k=1; k<=n; k++) { 167 g = swapvar(f,k,n); g = content(g); 168 if ( ! (g.isOne() || (-g).isOne() || degree(g)==0 )) { 169 g = swapvar(g,k,n); 170 DEBOUTLN(cout, "We have a content: ", g); 171 Outputlist = myUnion(InternalSqrFree(g),Outputlist); // should we add a 210 if ((mipo.level()==-1000000)||(k!=1)) 211 { 212 g = swapvar(f,k,n); g = content(g); 213 if ( ! (g.isOne() || (-g).isOne() || degree(g)==0 )) { 214 g = swapvar(g,k,n); 215 DEBOUTLN(cout, "We have a content: ", g); 216 Outputlist = myUnion(InternalSqrFree(g,mipo),Outputlist); // should we add a 172 217 // SqrFreeTest(g) first ? 173 DEBOUTLN(cout, "Outputlist is now: ", Outputlist); 174 f /=g; 175 DEBOUTLN(cout, "f is now: ", f); 176 } 218 DEBOUTLN(cout, "Outputlist is now: ", Outputlist); 219 f /=g; 220 DEBOUTLN(cout, "f is now: ", f); 221 } 222 } 177 223 } 178 224 … … 202 248 g= f.deriv(); 203 249 if ( getCharacteristic() > 0 && g.isZero() ){ // Pth roots only apply to char > 0 204 for (int k=1; k<=n; k++) { 205 g=swapvar(f,k,n) ; g = g.deriv(); 206 if ( ! g.isZero() ){ // can`t be Pth root 207 CFFList Outputlist2= SqrFreed(swapvar(f,k,n)); 208 for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++){ 209 Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp())); 250 for (int k=1; k<=n; k++) 251 { 252 if ((mipo.level()==-1000000)||(k!=1)) 253 { 254 g=swapvar(f,k,n) ; 255 g = g.deriv(); 256 257 if ( ! g.isZero() ) 258 { // can`t be Pth root 259 CFFList Outputlist2= SqrFreed(swapvar(f,k,n)); 260 for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++){ 261 Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp())); 262 } 263 return Outputlist; 210 264 } 211 return Outputlist; 265 } 266 if ( k==n ) 267 { // really is Pth power 268 DEBOUTLN(cout, "f is a p'th root: ", f); 269 CFMap m; 270 g = compress(f,m); 271 if (mipo==0) 272 f = m(PthRoot(g)); 273 else 274 f = m(PthRoot(g,mipo)); 275 DEBOUTLN(cout, " that is : ", f); 276 // now : Outputlist union ( SqrFreed(f) )^getCharacteristic() 277 Outputlist=myUnion(Powerup(InternalSqrFree(f),getCharacteristic()),Outputlist); 278 DEBDECLEVEL(cout, "SqrFreed"); 279 return Outputlist ; 212 280 } 213 else214 if ( k==n ) { // really is Pth power215 DEBOUTLN(cout, "f is a p'th root: ", f);216 CFMap m;217 g = compress(f,m);218 f = m(PthRoot(g));219 DEBOUTLN(cout, " that is : ", f);220 // now : Outputlist union ( SqrFreed(f) )^getCharacteristic()221 Outputlist=myUnion(Powerup(InternalSqrFree(f),getCharacteristic()),Outputlist);222 DEBDECLEVEL(cout, "SqrFreed");223 return Outputlist ;224 }225 281 } 226 282 } … … 247 303 // For char > 0 the polys f and h can have Pth roots; so we need a test 248 304 // Test is disabled because timing is the same 305 249 306 // if ( SqrFreeTest(f,0) ) 250 307 // Outputlist= myappend(Outputlist,CFFactor(f,1)) ; … … 276 333 /////////////////////////////////////////////////////////////// 277 334 CFFList 278 InternalSqrFree( const CanonicalForm & r ){335 InternalSqrFree( const CanonicalForm & r , const CanonicalForm & mipo ){ 279 336 CanonicalForm g=icontent(r), f = r; 280 337 CFFList Outputlist, Outputlist2; … … 295 352 f /= g; 296 353 if ( getNumVars(f) != 0 ) // a real polynomial 297 Outputlist=myUnion(SqrFreed(f),Outputlist) ; 354 { 355 if (mipo!=0) 356 Outputlist=myUnion(SqrFreed(f,mipo),Outputlist) ; 357 else 358 Outputlist=myUnion(SqrFreed(f),Outputlist) ; 359 } 298 360 } 299 361 DEBOUTLN(cout,"Outputlist = ", Outputlist); … … 341 403 /* 342 404 $Log: not supported by cvs2svn $ 405 Revision 1.7 2001/08/08 14:27:38 Singular 406 *hannes: Dan's HAVE_SINGULAR_ERROR 407 343 408 Revision 1.6 2001/08/08 14:26:56 Singular 344 409 *hannes: Dan's HAVE_SINGULAR_ERROR -
libfac/factor/SqrFree.h
rb1476d0 r639047e 2 2 //////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: SqrFree.h,v 1. 3 1997-09-12 07:19:51Singular Exp $4 // $Id: SqrFree.h,v 1.4 2002-08-19 11:11:34 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef SQRFREE_H … … 10 10 // CFFList SqrFree( const CanonicalForm & f ) ; 11 11 /*ENDPUBLIC*/ 12 CFFList InternalSqrFree( const CanonicalForm & f ) ;12 CFFList InternalSqrFree( const CanonicalForm & f , const CanonicalForm & mipo=0) ; 13 13 int SqrFreeTest( const CanonicalForm & r, int opt=1) ; 14 14 CFFList SqrFree( const CanonicalForm & f ) ; … … 18 18 /* 19 19 $Log: not supported by cvs2svn $ 20 Revision 1.3 1997/09/12 07:19:51 Singular 21 * hannes/michael: libfac-0.3.0 22 20 23 Revision 1.2 1997/04/25 22:13:03 michael 21 24 Version for libfac-0.2.1 -
libfac/factor/homogfactor.cc
rb1476d0 r639047e 1 1 /* Copyright 1997 Michael Messollen. All rights reserved. */ 2 2 //////////////////////////////////////////////////////////// 3 // static char * rcsid = "$Id: homogfactor.cc,v 1. 3 1997-09-12 07:19:57Singular Exp $ ";3 // static char * rcsid = "$Id: homogfactor.cc,v 1.4 2002-08-19 11:11:34 Singular Exp $ "; 4 4 //////////////////////////////////////////////////////////// 5 5 // FACTORY - Includes … … 111 111 // we assume g is square-free 112 112 CFFList 113 HomogFactor( const CanonicalForm & g, const Variable& minpoly, const int Mainvar ){113 HomogFactor( const CanonicalForm & g, const CanonicalForm & minpoly, const int Mainvar ){ 114 114 DEBINCLEVEL(cout, "HomogFactor"); 115 115 Variable xn = get_max_degree_Variable(g); … … 154 154 /* 155 155 $Log: not supported by cvs2svn $ 156 Revision 1.3 1997/09/12 07:19:57 Singular 157 * hannes/michael: libfac-0.3.0 158 156 159 Revision 1.2 1997/04/25 22:35:20 michael 157 160 changed cerr and cout messages for use with Singular -
libfac/factor/homogfactor.h
rb1476d0 r639047e 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 // $Id: homogfactor.h,v 1. 3 1997-09-12 07:19:58Singular Exp $4 // $Id: homogfactor.h,v 1.4 2002-08-19 11:11:34 Singular Exp $ 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 #ifndef HFACTOR_H … … 8 8 CFList get_Terms( const CanonicalForm & f ); 9 9 bool is_homogeneous( const CanonicalForm & f); 10 CFFList HomogFactor( const CanonicalForm & g, const Variable& minpoly, const int Mainvar );10 CFFList HomogFactor( const CanonicalForm & g, const CanonicalForm & minpoly, const int Mainvar ); 11 11 #endif /* HFACTOR_H */ 12 12 … … 14 14 /* 15 15 $Log: not supported by cvs2svn $ 16 Revision 1.3 1997/09/12 07:19:58 Singular 17 * hannes/michael: libfac-0.3.0 18 16 19 Revision 1.2 1997/04/25 22:14:46 michael 17 20 Version for libfac-0.2.1
Note: See TracChangeset
for help on using the changeset viewer.