Changeset afd067 in git
- Timestamp:
- Aug 22, 2005, 7:24:02 PM (19 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- dbb5b323a019a8f9237ef8f8617f358c43046074
- Parents:
- 42de8e63b3e9b4283abf78c542e5012da1723bdf
- Location:
- factory
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_factor.cc,v 1.2 5 2005-07-08 14:36:31 Singular Exp $ */2 /* $Id: cf_factor.cc,v 1.26 2005-08-22 17:24:01 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 27 27 #include "fac_sqrfree.h" 28 28 #include "cf_algorithm.h" 29 #include "cf_map.h" 29 30 30 31 #include "int_int.h" … … 333 334 } 334 335 else 336 { 335 337 F = ZFactorizeMultivariate( fz, issqrfree ); 338 } 336 339 337 340 if ( on_rational ) -
factory/cf_random.cc
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_random.cc,v 1. 6 1997-12-08 18:24:25 schmidtExp $ */2 /* $Id: cf_random.cc,v 1.7 2005-08-22 17:24:01 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 76 76 IntRandom::IntRandom() 77 77 { 78 max = 100;78 max = 50; 79 79 } 80 80 … … 88 88 CanonicalForm IntRandom::generate() const 89 89 { 90 return factoryrandom( max );90 return factoryrandom( 2*max )-max; 91 91 } 92 92 -
factory/cf_reval.cc
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_reval.cc,v 1.3 2001-01-19 18:11:50 Singular Exp $ */ 2 /* $Id: cf_reval.cc,v 1.4 2005-08-22 17:24:01 Singular Exp $ */ 3 4 #define MORE_ZEROES 3 5 4 6 #include <config.h> … … 17 19 gen = e.gen->clone(); 18 20 values = e.values; 21 cnt = e.cnt; 19 22 } 20 23 … … 32 35 delete gen; 33 36 values = e.values; 37 cnt = e.cnt; 34 38 if ( e.gen == 0 ) 35 39 gen = 0; … … 47 51 values[i] = gen->generate(); 48 52 } 53 54 void 55 REvaluation::nextpoint_0() 56 { 57 int n = values.max(); 58 #ifdef MORE_ZEROES 59 // for ( int i = values.min(); i <= n; i++ ) 60 // values[i] = gen->generate(); 61 if (cnt<=n /* values.max() */ ) 62 { 63 cnt++; 64 int t; 65 if (values.min()<n) 66 { 67 do 68 { 69 t=factoryrandom(n); 70 } 71 while (t<values.min()); 72 } 73 else t=n; 74 values[t]=gen->generate(); 75 } 76 else 77 #endif 78 { 79 for ( int i = values.min(); i <= n; i++ ) 80 values[i] = gen->generate(); 81 } 82 } -
factory/cf_reval.h
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_reval.h,v 1. 3 1997-06-19 12:23:56 schmidtExp $ */2 /* $Id: cf_reval.h,v 1.4 2005-08-22 17:24:01 Singular Exp $ */ 3 3 4 4 #ifndef INCL_CF_REVAL_H … … 17 17 private: 18 18 CFRandom * gen; 19 int cnt; 19 20 public: 20 21 REvaluation() : Evaluation(), gen(0) {} 21 REvaluation( int min, int max, const CFRandom & sample ) : Evaluation( min, max ), gen( sample.clone() ) { }22 REvaluation( int min, int max, const CFRandom & sample ) : Evaluation( min, max ), gen( sample.clone() ) { cnt=1;} 22 23 REvaluation( const REvaluation & e ); 23 24 ~REvaluation(); 24 25 REvaluation& operator= ( const REvaluation & e ); 25 26 void nextpoint(); 27 void nextpoint_0(); 26 28 }; 27 29 -
factory/fac_ezgcd.cc
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_ezgcd.cc,v 1.2 0 2005-08-19 10:59:19 pohlExp $ */2 /* $Id: fac_ezgcd.cc,v 1.21 2005-08-22 17:24:01 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 19 19 #define OPTIMALVAR 1 20 20 21 static void findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG ); 22 23 static CanonicalForm ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG, REvaluation & b, bool internal ); 24 25 static CanonicalForm ezgcd_specialcase ( const CanonicalForm & F, const CanonicalForm & G, REvaluation & b, const modpk & bound ); 26 27 static modpk findBound ( const CanonicalForm & F, const CanonicalForm & G, const CanonicalForm & lcF, const CanonicalForm & lcG, int degF, int degG ); 28 29 static modpk enlargeBound ( const CanonicalForm & F, const CanonicalForm & Lb, const CanonicalForm & Db, const modpk & pk ); 30 21 31 #ifdef OPTIMALVAR 22 static Variable getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG ); 23 #endif 24 25 static void findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG ); 26 27 static CanonicalForm ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG, REvaluation & b, bool internal ); 28 29 static CanonicalForm ezgcd_specialcase ( const CanonicalForm & F, const CanonicalForm & G, REvaluation & b, const modpk & bound ); 30 31 static modpk findBound ( const CanonicalForm & F, const CanonicalForm & G, const CanonicalForm & lcF, const CanonicalForm & lcG, int degF, int degG ); 32 33 static modpk enlargeBound ( const CanonicalForm & F, const CanonicalForm & Lb, const CanonicalForm & Db, const modpk & pk ); 34 35 #ifdef OPTIMALVAR 32 static Variable ezgcd_getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG ); 33 34 36 35 CanonicalForm ezgcd( const CanonicalForm & FF, const CanonicalForm & GG ) 37 36 { 38 37 CanonicalForm F,G; 39 38 REvaluation b; 40 Variable Z= getOptimalVar(FF,GG);39 Variable Z=ezgcd_getOptimalVar(FF,GG); 41 40 //Test: return Z; 42 if(Z==Variable(1)){return ezgcd( FF, GG, b, false );} 41 if(Z==Variable(1)) 42 return ezgcd( FF, GG, b, false ); 43 43 F=swapvar(FF,Z,Variable(1)); 44 44 G=swapvar(GG,Z,Variable(1)); … … 89 89 bound = findBound( F, G, lcF, lcG, degF, degG ); 90 90 if ( ! internal ) 91 b = REvaluation( 2, t, IntRandom( 50) );91 b = REvaluation( 2, t, IntRandom( 25 ) ); 92 92 while ( ! gcdfound ) { 93 93 /// ---> A2 … … 103 103 /// ---> A3 104 104 if ( delta == 0 ) 105 105 { 106 106 DEBDECLEVEL( cerr, "ezgcd" ); 107 107 return d; 108 108 } 109 109 /// ---> A4 110 110 //deltaold = delta; … … 112 112 bt = b; 113 113 findeval( F, G, Fbt, Gbt, Dbt, bt, delta + 1, degF, degG ); 114 114 int dd=degree( Dbt ); 115 115 if ( dd /*degree( Dbt )*/ == 0 ) 116 116 { 117 117 DEBDECLEVEL( cerr, "ezgcd" ); 118 118 return d; 119 119 } 120 120 if ( dd /*degree( Dbt )*/ == delta ) 121 121 break; … … 132 132 DEBDECLEVEL( cerr, "ezgcd" ); 133 133 return d*F; 134 134 } 135 135 if ( degG < degF && delta == degG && divides( G, F ) ) 136 136 { 137 137 DEBDECLEVEL( cerr, "ezgcd" ); 138 138 return d*G; 139 139 } 140 140 if ( delta != degF && delta != degG ) { 141 141 /// ---> A6 … … 143 143 //if ( gcd( (DD[1] = Fb / Db), Db ) == 1 ) { 144 144 DD[1] = Fb / Db; 145 145 xxx= gcd( DD[1], Db ); 146 146 DEBOUTLN( cerr, "gcd((Fb/Db),Db) = " << xxx ); 147 147 DEBOUTLN( cerr, "Fb/Db = " << DD[1] ); 148 148 DEBOUTLN( cerr, "Db = " << Db ); 149 149 if (xxx.inCoeffDomain()) { 150 150 B = F; 151 151 DD[2] = Db; … … 155 155 } 156 156 //else if ( gcd( (DD[1] = Gb / Db), Db ) == 1 ) { 157 158 { 157 else 158 { 159 159 DD[1] = Gb / Db; 160 160 xxx=gcd( DD[1], Db ); 161 161 DEBOUTLN( cerr, "gcd((Gb/Db),Db) = " << xxx ); 162 162 DEBOUTLN( cerr, "Gb/Db = " << DD[1] ); 163 163 DEBOUTLN( cerr, "Db = " << Db ); 164 164 if (xxx.inCoeffDomain()) 165 165 { 166 166 B = G; … … 180 180 #endif 181 181 } 182 182 } 183 183 /// ---> A7 184 184 DD[2] = DD[2] * ( b( lcDD[2] ) / lc( DD[2] ) ); … … 192 192 gcdfound = Hensel( B, DD, lcDD, b, bound, x ); 193 193 DEBOUTLN( cerr, "(hensel finished) DD = " << DD ); 194 195 196 194 195 if (gcdfound) 196 { 197 197 CanonicalForm cand=DD[2] / content(DD[2],Variable(1)); 198 199 198 if (B==F) 199 { 200 200 DEBOUTLN( cerr, "(test) G: "<<G<<" % gcd:"<<cand<<" -> " << G%cand ); 201 201 gcdfound= divides(cand,G); 202 202 } 203 204 { 203 else 204 { 205 205 DEBOUTLN( cerr, "(test) F: "<<F<<" % gcd:"<<cand<<" -> " << F%cand); 206 206 gcdfound= divides(cand,F); 207 208 207 } 208 } 209 209 /// ---> A8 (gcdfound) 210 210 } … … 236 236 // '(16*B^8-208*B^6*C+927*B^4*C^2-1512*B^2*C^3+432*C^4)' \ 237 237 // '(4*B^7*C^2-50*B^5*C^3+208*B^3*C^4-288*B*C^5)' 238 b.nextpoint ();239 238 b.nextpoint_0(); 239 return ezgcd( F, G, b, true ); 240 240 } 241 241 #if 1 … … 314 314 bool ok; 315 315 if ( delta != 0 ) 316 b.nextpoint ();316 b.nextpoint_0(); 317 317 DEBOUTLN( cerr, "ezgcd: (findeval) F = " << F <<", G="<< G); 318 318 DEBOUTLN( cerr, "ezgcd: (findeval) degF = " << degF << ", degG="<<degG ); … … 325 325 ok = degree( Gb ) == degG; 326 326 } 327 327 328 328 if ( ok ) 329 { 329 { 330 330 Db = gcd( Fb, Gb ); 331 331 if ( delta > 0 ) … … 333 333 } 334 334 if ( ! ok ) 335 b.nextpoint(); 335 { 336 b.nextpoint_0(); 337 } 336 338 } while ( ! ok ); 337 339 } … … 380 382 381 383 #ifdef OPTIMALVAR 382 static Variable getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG )383 { 384 int ii,tt,d, dd,s,so;385 CanonicalForm F,G ,Fbz,Gbz,Dbz;384 static Variable ezgcd_getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG ) 385 { 386 int ii,tt,d,s,dd,so; 387 CanonicalForm F,G; 386 388 Variable opt=Variable(1); 387 if((FF.level()<3)||(GG.level()<3)){return opt;}388 REvaluation bz=REvaluation(2,tmax(FF.level(),GG.level()),IntRandom(50));389 Fbz=bz(FF);390 Gbz=bz(GG);391 Dbz=gcd(Fbz,Gbz);392 dd=degree(Dbz);393 so=size(Dbz);394 389 tt=FF.level(); 395 if(GG.level()<tt){tt=GG.level();} 390 if(GG.level()<tt) 391 tt=GG.level(); 392 if(tt<3 /*(FF.level()<3)||(GG.level()<3)*/) 393 return opt; 394 REvaluation bz=REvaluation(2,tmax(FF.level(),GG.level()),IntRandom(1)); 395 CanonicalForm Fbz=bz(FF); 396 CanonicalForm Gbz=bz(GG); 397 CanonicalForm Dbz0=gcd(Fbz,Gbz); 398 dd=degree(Dbz0); 399 so=-1; 396 400 for(ii=2;ii<=tt;ii++) 397 401 { 402 //bz.nextpoint(); 398 403 F=swapvar(FF,Variable(ii),Variable(1)); 399 404 G=swapvar(GG,Variable(ii),Variable(1)); 400 405 Fbz=bz(F); 401 406 Gbz=bz(G); 402 Dbz=gcd(Fbz,Gbz);407 CanonicalForm Dbz=gcd(Fbz,Gbz); 403 408 d=degree(Dbz); 404 409 if(d==dd) 405 410 { 406 411 s=size(Dbz); 407 if(s>so){so=s;opt=Variable(ii);} 408 } 409 if(d>dd){dd=d;so=size(Dbz);opt=Variable(ii);} 412 if (so==-1) 413 { 414 so=size(Dbz0); 415 } 416 if(s>so) 417 { 418 so=s; 419 opt=Variable(ii); 420 Dbz0=Dbz; 421 } 422 } 423 else if(d>dd) 424 { 425 dd=d; 426 so=-1; 427 opt=Variable(ii); 428 Dbz0=Dbz; 429 } 410 430 } 411 431 return opt; -
factory/fac_multivar.cc
r42de8e6 rafd067 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_multivar.cc,v 1.1 1 2005-06-28 14:39:52 Singular Exp $ */2 /* $Id: fac_multivar.cc,v 1.12 2005-08-22 17:24:02 Singular Exp $ */ 3 3 4 4 #include <config.h> … … 203 203 CFArray G, lcG, D; 204 204 int i, j, k, m, r, maxdeg, h; 205 REvaluation A( 2, t, IntRandom( 100 ) );205 REvaluation A( 2, t, IntRandom( 50 ) ); 206 206 CanonicalForm U0; 207 207 CanonicalForm ft, ut, gt, d;
Note: See TracChangeset
for help on using the changeset viewer.