Changeset aa7480c in git
- Timestamp:
- Jan 7, 2008, 2:34:56 PM (15 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 46f6af6b0ad4f593376191e4bbe9dda46e6d8fae
- Parents:
- 1e6de686866af59b3d97fffef1d92033d15f47c6
- Location:
- libfac/factor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libfac/factor/Factor.cc
r1e6de6 raa7480c 1 1 /* Copyright 1996 Michael Messollen. All rights reserved. */ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 static char * rcsid = "$Id: Factor.cc,v 1.3 7 2007-10-25 14:45:41Singular Exp $ ";3 static char * rcsid = "$Id: Factor.cc,v 1.38 2008-01-07 13:34:56 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 /////////////////////////////////////////////////////////////////////////////// … … 116 116 if ( totaldegree(remlc)==0 ){ remlc=f.genOne() ; } 117 117 DEBOUTLN(CERR, "remlc= " , remlc); 118 for ( int i=n-1; i>=1; i-- ){ 118 for ( int i=n-1; i>=1; i-- ) 119 { 119 120 newlc= LC(f,i); 120 121 if ( totaldegree(newlc)==0 ){ newlc=f.genOne() ; } … … 222 223 int test1; 223 224 224 if ( lt == lt.genOne() ) return TheList; // the poly was already monic225 if ( lt.isOne() ) return TheList; // the poly was already monic 225 226 if ( TheList.length() <= 1 ) // only one factor to substitute back 226 227 { … … 356 357 /////////////////////////////////////////////////////////////// 357 358 static int 358 various_tests( const CanonicalForm & g, int deg, int vars_left){ 359 various_tests( const CanonicalForm & g, int deg, int vars_left) 360 { 359 361 CFMap m; 360 362 … … 362 364 if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less 363 365 if ( SqrFreeTest(g,1) ) // poly is sqrfree 364 if ( gcd(g,g.deriv()) == 1) // Discriminante != 0366 if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0 365 367 return 1; 366 368 return 0; … … 579 581 unilist = factorize2(g,Extension,mipo); 580 582 } 581 if (unilist.length() <= minfactors ) { 583 if (unilist.length() <= minfactors ) 584 { 582 585 minfactors=unilist.length(); 583 586 minEvaluation=Substitutionlist; … … 586 589 else samefactors +=1; 587 590 588 if (unilist.length() == 1 ){ // wow! we found f is irreducible! 591 if (unilist.length() == 1 ) // wow! we found f is irreducible! 592 { 589 593 BestEvaluationpoint=minEvaluation; 590 594 BestFactorisation=minFactorisation; … … 592 596 } 593 597 594 if ( samefactors >= sametries ){ // now we stop ( maybe polynomial *has* 595 // minfactors factors? ) 598 if ( samefactors >= sametries ) // now we stop ( maybe polynomial *has* 599 // minfactors factors? ) 600 { 596 601 BestEvaluationpoint=minEvaluation; 597 602 BestFactorisation=minFactorisation; … … 600 605 601 606 } 602 else failedfactor += 1; 603 604 if ( failedfactor >= failtries ){ // now we stop ( perhaps Extension isn't 605 // big enough ) 607 else 608 failedfactor += 1; 609 610 if ( failedfactor >= failtries ) // now we stop ( perhaps Extension isn't 611 // big enough ) 612 { 606 613 if ( tried == 0 ) 607 614 return 0; 608 else{ 615 else 616 { 609 617 BestEvaluationpoint=minEvaluation; 610 618 BestFactorisation=minFactorisation; … … 612 620 } 613 621 } 614 615 622 } 616 623 BestEvaluationpoint=minEvaluation; … … 725 732 // Check special cases 726 733 for ( int i=1; i<=level(F); i++) 727 if ( degree(f,Variable(i) ) == 1 ) { //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ? 734 { 735 if ( degree(f,Variable(i) ) == 1 ) 736 //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ? 737 { 728 738 DEBOUTLN(CERR, "Trivial case: ", F); 729 739 Outputlist.append(CFFactor(F,1)); 730 740 return Outputlist; 731 741 } 742 } 732 743 733 744 // Look at the leading term: 734 745 lt = LC(f); 735 746 DEBOUTLN(CERR, "Leading term: ", lt); 736 if ( lt != f.genOne() ) 747 //if ( lt != f.genOne() ) 748 if ( !lt.isOne() ) 737 749 { 738 750 // make the polynomial monic in the main variable … … 836 848 // INTERRUPTHANDLER 837 849 838 if ( lt != f.genOne() ) 850 //if ( lt != f.genOne() ) 851 if ( !lt.isOne() ) 839 852 { 840 853 Outputlist = not_monic(Outputlist,lt,ff,level(ff)); … … 1318 1331 /* 1319 1332 $Log: not supported by cvs2svn $ 1333 Revision 1.37 2007/10/25 14:45:41 Singular 1334 *hannes: homgfactor for alg.ext of Q 1335 1320 1336 Revision 1.36 2007/10/15 18:03:11 Singular 1321 1337 *hannes: // debug stuff -
libfac/factor/SqrFree.cc
r1e6de6 raa7480c 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 static char * rcsid = "$Id: SqrFree.cc,v 1.1 1 2007-05-15 14:46:49Singular Exp $";4 static char * rcsid = "$Id: SqrFree.cc,v 1.12 2008-01-07 13:34:56 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 /////////////////////////////////////////////////////////////////////////////// … … 304 304 return Outputlist ; 305 305 } 306 else { // we can split into two nontrivial pieces 306 else // we can split into two nontrivial pieces 307 { 307 308 f /= h; // Now we have split the poly into f and h 308 309 g = lc(f); 309 if ( g != f.genOne() && getNumVars(g) == 0 ){ 310 //if ( g != f.genOne() && getNumVars(g) == 0 ){ 311 if ( (!g.isOne()) && getNumVars(g) == 0 ) 312 { 310 313 Outputlist= myappend(Outputlist,CFFactor(g,1)) ; 311 314 f /= g; … … 415 418 /* 416 419 $Log: not supported by cvs2svn $ 420 Revision 1.11 2007/05/15 14:46:49 Singular 421 *hannes: factorize in Zp(a)[x...] 422 417 423 Revision 1.10 2006/05/16 14:46:50 Singular 418 424 *hannes: gcc 4.1 fixes -
libfac/factor/Truefactor.cc
r1e6de6 raa7480c 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 // emacs edit mode for this file is -*- C++ -*- 4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.1 0 2006-05-16 14:46:50Singular Exp $";4 //static char * rcsid = "@(#) $Id: Truefactor.cc,v 1.11 2008-01-07 13:34:56 Singular Exp $"; 5 5 /////////////////////////////////////////////////////////////////////////////// 6 6 // Factory - Includes … … 278 278 onemore=1; 279 279 // steps 3 to 6 280 while (1){ 280 while (1) 281 { 281 282 // step 3 iff onemore == 1 282 283 if ( onemore ) M+= 1; else onemore = 1; 283 284 // step 4 284 if ( U == U.genOne() ) break; // Return FAC 285 if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) ) { 285 if ( U.isOne() ) break; // Return FAC 286 if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) ) 287 { 286 288 FAC.append( CFFactor(U,1) ); 287 289 break; // Return FAC union {U} … … 293 295 E_all = Rightdegree( E_all, degU, levelU ); 294 296 DEBOUTLN(CERR,"Truefactors: (step5) E_all(Rightdegree)= ", E_all); 295 if ( E_all.length() == 0 ){ 297 if ( E_all.length() == 0 ) 298 { 296 299 FAC.append( CFFactor(U,1) ); 297 300 break; // Return FAC union {U} 298 301 } 299 for ( i=E_all; i.hasItem(); i++){ 302 for ( i=E_all; i.hasItem(); i++) 303 { 300 304 factor = i.getItem(); 301 305 Y = Multmod_power( factor.factor(), SubstitutionList, h, levelU); … … 303 307 c = mydivremt(U,Y,a,b); 304 308 // if ( c && b == U.genZero()) { // Y divides U 305 if ( c && b.isZero() ){ 309 if ( c && b.isZero() ) 310 { 306 311 DEBOUT(CERR,"Truefactors: (step6): ",Y ); 307 312 DEBOUTLN(CERR, " divides ",U); … … 320 325 } 321 326 } 322 323 327 return FAC; 324 328 } … … 327 331 // Check if poly f is in Fp (returns true) or in Fp(a) // 328 332 /////////////////////////////////////////////////////////////// 329 static bool 330 is_in_Fp( const CanonicalForm & f ){333 static bool is_in_Fp( const CanonicalForm & f ) 334 { 331 335 if ( f.inCoeffDomain() ) 332 336 return f.inBaseDomain() ; 333 else { 337 else 338 { 334 339 CFIterator i=f; 335 340 bool ok=true; 336 while ( ok && i.hasTerms() ){ 341 while ( ok && i.hasTerms() ) 342 { 337 343 ok = is_in_Fp( i.coeff() ); 338 344 i++ ; … … 348 354 // of) multiplying by other elements. // 349 355 /////////////////////////////////////////////////////////////// 350 CFFList 351 TakeNorms(const CFFList & PiList){356 CFFList TakeNorms(const CFFList & PiList) 357 { 352 358 CFFList CopyPossibleFactors, PossibleFactors, TrueFactors; 353 359 CFFListIterator i; … … 359 365 360 366 // First check if the factors in PiList already lie in Fp-Domain 361 for ( i=PiList; i.hasItem(); i++ ){ 367 for ( i=PiList; i.hasItem(); i++ ) 368 { 362 369 Factor = i.getItem(); 363 370 if ( is_in_Fp( Factor.factor() ) ) … … 368 375 // Now we have to check if combinations of the remaining factors 369 376 // (now in PossibleFactors) do lie in Fp-Domain 370 if ( PossibleFactors.length() > 0 ){ // there are (at least two) items 377 if ( PossibleFactors.length() > 0 ) // there are (at least two) items 378 { 371 379 int n=2; 372 if ( PossibleFactors.length() < n ) { // a little check 380 if ( PossibleFactors.length() < n ) // a little check 381 { 373 382 #ifdef HAVE_SINGULAR_ERROR 374 383 WerrorS("libfac: ERROR: TakeNorms less then two items remaining!"); … … 382 391 #endif 383 392 } 384 while ( n < PossibleFactors.length() ){ 393 while ( n < PossibleFactors.length() ) 394 { 385 395 // generate all combinations of n elements 386 396 combinat(n, PossibleFactors.length(), CombinatList); 387 for ( j=CombinatList ; j.hasItem(); j++ ){ 397 for ( j=CombinatList ; j.hasItem(); j++ ) 398 { 388 399 intermediate=1; 389 400 for ( k=j.getItem(); k.hasItem(); k++ ) 390 401 intermediate *= getItemNr( k.getItem(), PossibleFactors ); 391 if ( is_in_Fp( intermediate ) ){ 402 if ( is_in_Fp( intermediate ) ) 403 { 392 404 TrueFactors.append(intermediate); // found a true factor 393 405 CopyPossibleFactors=PossibleFactors; // save list … … 399 411 break; 400 412 } 401 else { 413 else 414 { 402 415 //CERR << "Schade!" << "\n"; 403 416 } … … 409 422 // All remaining factors in PossibleFactors multiplied 410 423 // should lie in Fp domain 411 if ( PossibleFactors.length() >=1 ){ 424 if ( PossibleFactors.length() >=1 ) 425 { 412 426 for ( i=PossibleFactors; i.hasItem(); i++ ) 413 427 intermediate *= i.getItem().factor(); 414 428 // a last check: 415 if ( is_in_Fp(intermediate) ){ 429 if ( is_in_Fp(intermediate) ) 430 { 416 431 TrueFactors.append(CFFactor(intermediate,1)); 417 432 } 418 else{ 433 else 434 { 419 435 #ifdef HAVE_SINGULAR_ERROR 420 436 WerrorS("libfac: TakeNorms: somethings wrong with remaining factors!"); … … 434 450 /* 435 451 $Log: not supported by cvs2svn $ 452 Revision 1.10 2006/05/16 14:46:50 Singular 453 *hannes: gcc 4.1 fixes 454 436 455 Revision 1.9 2001/08/08 14:26:56 Singular 437 456 *hannes: Dan's HAVE_SINGULAR_ERROR
Note: See TracChangeset
for help on using the changeset viewer.