Changeset 1048e0c in git for libfac/factor
- Timestamp:
- Feb 14, 2003, 4:51:15 PM (21 years ago)
- Branches:
- (u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
- Children:
- cd86ac0de216196cc9d05f7ad208a00a8046aff9
- Parents:
- 0191db90f1b4ad6d544bae570504054ff0db0eaf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/factor/Factor.cc
r0191db r1048e0c 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.1 4 2002-08-19 11:11:32Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.15 2003-02-14 15:51:15 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 /////////////////////////////////////////////////////////////////////////////// … … 46 46 TIMING_DEFINE_PRINT(truefactor_time); 47 47 48 48 void out_cf(char *s1,const CanonicalForm &f,char *s2); 49 50 /* 51 * a wrapper for factorize over algebraic extensions: 52 * does a sanity check and, if nec., a conversion 53 * before calling factorize(f,alpha) 54 * ( in factorize, alpha.level() must be < 0 ) 55 */ 56 CFFList factorize2 ( const CanonicalForm & f, 57 const Variable & alpha, const CanonicalForm & mipo ) 58 { 59 if (alpha.level() <0) 60 return factorize(f,alpha); 61 else 62 { 63 bool repl=(f.mvar() != alpha); 64 //out_cf("f2 - factor:",f,"\n"); 65 //out_cf("f2 - ext:",alpha,"\n"); 66 //out_cf("f2 - mipo:",mipo,"\n"); 67 Variable X=rootOf(mipo); 68 CanonicalForm F=f; 69 if (repl) F=replacevar(f,alpha,X); 70 //out_cf("call - factor:",F,"\n"); 71 //out_cf("call - ext:",X,"\n"); 72 //out_cf("call - mipo:",getMipo(X,'A'),"\n"); 73 CFFList L=factorize(F,X); 74 CFFListIterator i=L; 75 if (repl) 76 { 77 CFFList Outputlist; 78 for(;i.hasItem(); i++ ) 79 { 80 Outputlist.append(CFFactor( 81 replacevar(i.getItem().factor(),X,alpha), 82 i.getItem().exp())); 83 } 84 return Outputlist; 85 } 86 else return L; 87 } 88 } 49 89 /////////////////////////////////////////////////////////////// 50 90 // Choose a main variable if the user didn`t wish a // … … 429 469 // Extension isn't big enough! 430 470 static int 431 evaluate( int maxtries, int sametries, int failtries, const CanonicalForm &f , const Variable & Extension, SFormList & BestEvaluationpoint, CFFList & BestFactorisation ){471 evaluate( int maxtries, int sametries, int failtries, const CanonicalForm &f , const Variable & Extension, const CanonicalForm &mipo, SFormList & BestEvaluationpoint, CFFList & BestFactorisation ){ 432 472 int minfactors=degree(f),degf=degree(f),n=level(f.mvar())-1; 433 473 SFormList minEvaluation; … … 464 504 else 465 505 { 466 unilist = factorize (g,Extension);467 } 506 unilist = factorize2(g,Extension,mipo); 507 } 468 508 if (unilist.length() <= minfactors ) { 469 509 minfactors=unilist.length(); … … 542 582 } 543 583 else{ 584 if (Extension.level()<0) 544 585 DEBOUTLN(cout, "Univ. Factorization over extension of degree ", 545 586 degree(getMipo(Extension,'x')) ); 587 else 588 DEBOUTLN(cout, "Univ. Factorization over extension of level ??", 589 Extension.level()); 546 590 TIMING_START(evaluate_time); 547 591 #if 1 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 } 592 Outputlist = factorize2(F,Extension,alpha); 562 593 #else 563 594 Variable X; … … 634 665 635 666 TIMING_START(evaluate_time); 636 success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, Substitutionlist,UnivariateFactorlist);667 success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, alpha, Substitutionlist,UnivariateFactorlist); 637 668 DEBOUTLN(cout, "Returned from evaluate: success: ", success); 638 669 for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ ){ … … 673 704 degree(getMipo(Extension,'x')) ); 674 705 #if 1 675 UnivariateFactorlist = factorize (ffuni,Extension);706 UnivariateFactorlist = factorize2(ffuni,Extension,alpha); 676 707 #else 677 708 Variable X; … … 866 897 swapvar(F,Variable(mv),F.mvar()); 867 898 } 868 899 869 900 DEBDECLEVEL(cout, "Factorize"); 870 901 TIMING_END(factorize_time); … … 970 1001 if ( g.isUnivariate() ){ 971 1002 Variable alpha=rootOf(minpoly); 972 Intermediatelist=factorize (g,alpha); // poly is sqr-free!1003 Intermediatelist=factorize2(g,alpha,minpoly); // poly is sqr-free! 973 1004 for ( j=Intermediatelist; j.hasItem(); j++ ) 974 1005 //Normally j.getItem().exp() should be 1 … … 1024 1055 swapvar(F,Variable(mv),F.mvar()); 1025 1056 } 1026 1057 1027 1058 DEBDECLEVEL(cout, "Factorize"); 1028 1059 TIMING_END(factorize_time); … … 1039 1070 /* 1040 1071 $Log: not supported by cvs2svn $ 1072 Revision 1.14 2002/08/19 11:11:32 Singular 1073 * hannes/pfister: alg_gcd etc. 1074 1041 1075 Revision 1.13 2002/07/30 17:06:47 Singular 1042 1076 *hannes: uuh - factorize in Q(a)[x] is missing, use Q[a][x].
Note: See TracChangeset
for help on using the changeset viewer.