Changeset 57f13b in git
- Timestamp:
- Mar 27, 1997, 10:54:41 AM (27 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 83452f672f51e8f1610d8f803fd147fd3c2cd574
- Parents:
- 043814c307adc58ae0e7174dc880bfb222e8e6dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/fac_univar.cc
r043814 r57f13b 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: fac_univar.cc,v 1. 4 1996-07-12 08:37:20 stobbeExp $2 // $Id: fac_univar.cc,v 1.5 1997-03-27 09:54:41 schmidt Exp $ 3 3 4 4 /* 5 5 $Log: not supported by cvs2svn $ 6 Revision 1.4 1996/07/12 08:37:20 stobbe 7 "ZFactorizeUnivariate: now handles constants of the squarefree decomposition 8 " 9 6 10 Revision 1.3 1996/06/26 13:17:03 stobbe 7 11 "ZFactorizeUnivariate: now handles the sign of the argument right. … … 22 26 */ 23 27 24 //#define TIMING25 26 #ifndef NDEBUG27 //#define DEBUGOUTPUT28 #endif29 30 #ifdef TIMING31 #include <sys/times.h>32 #endif33 34 28 #include <math.h> 29 35 30 #include "assert.h" 31 #include "debug.h" 32 #include "timing.h" 33 36 34 #include "cf_defs.h" 35 37 36 #include "fac_util.h" 38 37 #include "fac_univar.h" … … 43 42 #include "fac_sqrfree.h" 44 43 44 TIMING_DEFINE_PRINT(fac_choosePrimes); 45 TIMING_DEFINE_PRINT(fac_facModPrimes); 46 TIMING_DEFINE_PRINT(fac_liftFactors); 47 TIMING_DEFINE_PRINT(fac_combineFactors); 48 45 49 #define MAX_FP_FAC 3 46 50 … … 50 54 iextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b ); 51 55 52 #ifndef NDEBUG 53 56 #ifdef DEBUGOUTPUT 54 57 static void 55 58 hprint ( int * a ) … … 63 66 i++; 64 67 } 65 cerr << ")" << endl; 66 } 67 68 cerr << ")" << endl << endl; 69 } 68 70 #endif 69 71 … … 245 247 int * kvals = new int[no_iter]; 246 248 247 DEBOUT( cerr, "quadratic lift called with p = ", p ); 248 DEBOUTLN( cerr, " and k = ", k ); 249 DEBOUTSL( cerr ); 250 DEBOUT( cerr, "quadratic lift called with p = " << p << " and k = " << k ); 251 DEBOUTENDL( cerr ); 249 252 for ( j = 0, i = k; i > 1; i = ( i+1 ) / 2, j++ ) kvals[j] = i; 250 253 kvals[j] = 1; … … 273 276 j--; 274 277 setCharacteristic( p, kvals[j+1] ); 275 DEBOUT( cerr, "lifting from p^", kvals[j+1] ); 276 DEBOUTLN( cerr, " to p^", kvals[j] ); 278 DEBOUTSL( cerr ); 279 DEBOUT( cerr, "lifting from p^" << kvals[j+1] << " to p^" << kvals[j] ); 280 DEBOUTENDL( cerr ); 277 281 c = mapinto( c ); 278 282 DEBOUTLN( cerr, " !!! g = ", mapinto( g ) ); … … 395 399 Dh = new int [n]; Dh[0] = n; 396 400 exp = J.getItem().exp(); 397 #ifdef TIMING 398 struct tms ts, te; 399 times( &ts ); 400 #endif 401 TIMING_START(fac_choosePrimes); 401 402 ok = choosePrimes( p, f ); 402 #ifdef TIMING 403 times( &te ); 404 cout.setf( ios::fixed, ios::floatfield ); 405 cout.precision(2); 406 cout << "time to choose the primes: " 407 << float(te.tms_utime-ts.tms_utime) / CLK_TCK << " sec" << endl; 408 #endif 403 TIMING_END_AND_PRINT(fac_choosePrimes, "time to choose the primes: "); 409 404 if ( ! ok ) { 410 cerr << "factorize warnig: no good prime found" << endl;411 cerr << f << endl;405 DEBOUTLN( cerr, "error: no good prime found to factorize ", f ); 406 ASSERT( 0, "error: no good prime found" ); 412 407 ZF.append( CFFactor( f, exp ) ); 413 408 } 414 409 else { 415 #ifdef TIMING 416 times( &ts ); 417 #endif 410 TIMING_START(fac_facModPrimes); 418 411 for ( i = 0; i < MAX_FP_FAC; i++ ) { 419 412 setCharacteristic( p[i] ); … … 424 417 // else 425 418 // F[i] = FpFactorizeUnivariateCZ( fp, true ); 426 DEBOUT( cerr, "F[i] = ", F[i] ); 427 DEBOUTLN( cerr, ", p = ", p[i] ); 419 DEBOUTSL( cerr ); 420 DEBOUT( cerr, "F[i] = " << F[i] << ", p = " << p[i] ); 421 DEBOUTENDL( cerr ); 428 422 } 429 #ifdef TIMING 430 times( &te ); 431 cout.setf( ios::fixed, ios::floatfield ); 432 cout.precision(2); 433 cout << "time to factorize mod primes: " 434 << float(te.tms_utime-ts.tms_utime) / CLK_TCK << " sec" << endl; 435 #endif 423 TIMING_END_AND_PRINT(fac_facModPrimes, "time to factorize mod primes: "); 436 424 setCharacteristic( 0 ); 437 425 #ifdef DEBUGOUTPUT 426 DEBOUTLN( cerr, "D = ", ' ' ); 438 427 hprint( D ); 439 428 #endif … … 441 430 hgroup( D ); 442 431 #ifdef DEBUGOUTPUT 432 DEBOUTLN( cerr, "D = ", ' ' ); 443 433 hprint( D ); 444 434 #endif … … 447 437 hgroup( Dh ); 448 438 #ifdef DEBUGOUTPUT 449 cerr << "Dh = ";439 DEBOUTLN( cerr, "Dh = ", ' ' ); 450 440 hprint( Dh ); 451 441 #endif 452 442 hintersect( D, Dh ); 453 443 #ifdef DEBUGOUTPUT 454 cerr << "D = ";444 DEBOUTLN( cerr, "D = ", ' ' ); 455 445 hprint( D ); 456 446 #endif … … 475 465 F[j].sort( cmpFactor ); 476 466 I = F[j]; i = 0; 477 #ifdef TIMING 478 times( &ts ); 479 #endif 467 TIMING_START(fac_liftFactors); 480 468 while ( I.hasItem() ) { 481 469 DEBOUTLN( cerr, "factor to lift = ", I.getItem().factor() ); … … 491 479 fp /= I.getItem().factor(); 492 480 ZF.append( CFFactor( dummy1, exp ) ); 493 I.remove( 0 ); 481 I.remove( 0 ); 494 482 I = F[j]; 495 483 i = 0; … … 507 495 } 508 496 } 509 #ifdef TIMING 510 times( &te ); 511 cout.setf( ios::fixed, ios::floatfield ); 512 cout.precision(2); 513 cout << "time to lift the factors: " 514 << float(te.tms_utime-ts.tms_utime) / CLK_TCK << " sec" << endl; 515 #endif 497 TIMING_END_AND_PRINT(fac_liftFactors, "time to lift the factors: "); 516 498 DEBOUTLN( cerr, "ZF = ", ZF ); 517 499 initHG( Dh, theFactors ); 518 500 hgroup( Dh ); 519 501 #ifdef DEBUGOUTPUT 520 cerr << "Dh = ";502 DEBOUTLN( cerr, "Dh = ", ' ' ); 521 503 hprint( Dh ); 522 504 #endif … … 527 509 DEBOUTLN( cerr, "theFactors = ", theFactors ); 528 510 DEBOUTLN( cerr, "f = ", f ); 529 DEBOUT( cerr, "p = ", pk.getp() ); 530 DEBOUTLN( cerr, ", k = ", pk.getk() ); 531 #ifdef DEBUGOUTPUT 511 DEBOUTSL( cerr ); 512 DEBOUT( cerr, "p = " << pk.getp() << ", k = " << pk.getk() ); 513 DEBOUTENDL( cerr ); 514 #ifdef DEBUGOUTPUT 515 DEBOUTLN( cerr, "D = ", ' ' ); 532 516 hprint( D ); 533 517 #endif … … 535 519 (void)iextgcd( pk.getpk(), lf, dummy1, recip_lf ); 536 520 DEBOUTLN( cerr, "recip_lf = ", recip_lf ); 537 #ifdef TIMING 538 times( &ts ); 539 #endif 521 TIMING_START(fac_combineFactors); 540 522 for ( i = 1; i < D[0]; i++ ) 541 523 if ( D[i] != 0 ) … … 543 525 if ( degree( f ) > 0 ) 544 526 ZF.append( CFFactor( f, exp ) ); 545 #ifdef TIMING 546 times( &te ); 547 cout.setf( ios::fixed, ios::floatfield ); 548 cout.precision(2); 549 cout << "time to combine the factors: " 550 << float(te.tms_utime-ts.tms_utime) / CLK_TCK << " sec" << endl; 551 #endif 527 TIMING_END_AND_PRINT(fac_combineFactors, "time to combine the factors: "); 552 528 } 553 529 }
Note: See TracChangeset
for help on using the changeset viewer.