Changeset c10f46 in git for factory/libfac/charset/alg_factor.cc
 Timestamp:
 Aug 3, 2012, 1:06:22 PM (11 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
 Children:
 b0732eb4254fbe76540d72c337f3d7f985adf948
 Parents:
 b8610796eaca5ba7db8dc75f8bc88d698e077b365abb0e7fdca82a2bad9778e410148c74d7b49a0b
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

factory/libfac/charset/alg_factor.cc
r5abb0e7 rc10f46 2 2 // emacs edit mode for this file is * C++ * 3 3 //////////////////////////////////////////////////////////// 4 //////////////////////////////////////////////////////////// 4 5 5 // FACTORY  Includes 6 6 #include <factory.h> … … 18 18 #include "alg_factor.h" 19 19 20 void out_cf(c har *s1,const CanonicalForm &f,char *s2);20 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 21 21 22 22 #ifdef ALGFACTORDEBUG … … 80 80 // replacement for factory's broken psr 81 81 static CanonicalForm 82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){ 82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ) 83 { 83 84 CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue; 84 85 int dr, dv, d,n=0; … … 104 105 // replacement for factory's broken resultant 105 106 static CanonicalForm 106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){ 107 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ) 108 { 107 109 bool on_rational = isOn(SW_RATIONAL); 108 110 On(SW_RATIONAL); … … 113 115 if (!on_rational) Off(SW_RATIONAL); 114 116 115 return resultant(fz,gz,v);117 return resultant(fz,gz,v); 116 118 } 117 119 … … 133 135 sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha, 134 136 CFGenerator & myrandom, CanonicalForm & s, CanonicalForm & g, 135 CanonicalForm & R){ 137 CanonicalForm & R) 138 { 136 139 Variable y=PPalpha.mvar(),vf=f.mvar(); 137 140 CanonicalForm temp, Palpha=PPalpha, t; … … 147 150 148 151 // Norm, resultante taken with respect to y 149 while ( !sqfreetest ){ 152 while ( !sqfreetest ) 153 { 150 154 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 151 155 R = resultante(Palpha, g, y); R= R* bCommonDen(R); … … 160 164 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 161 165 } 162 else{ 166 else 167 { 163 168 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 164 169 // Look at SqrFreeTest! … … 169 174 if (getAlgVar(R,X)) 170 175 { 171 if (R.isUnivariate())172 176 testlist=factorize( R, X ); 173 else174 testlist= Factorize(R, X, 0);175 177 } 176 178 else … … 183 185 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 184 186 } 185 if ( ! sqfreetest ){ 187 if ( ! sqfreetest ) 188 { 186 189 myrandom.next(); 187 190 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); … … 198 201 sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha, 199 202 AlgExtGenerator & myrandom, CanonicalForm & s, CanonicalForm & g, 200 CanonicalForm & R){ 203 CanonicalForm & R) 204 { 201 205 Variable y=PPalpha.mvar(),vf=f.mvar(); 202 206 CanonicalForm temp, Palpha=PPalpha, t; … … 212 216 213 217 // Norm, resultante taken with respect to y 214 while ( !sqfreetest ){ 218 while ( !sqfreetest ) 219 { 215 220 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 216 221 R = resultante(Palpha, g, y); R= R* bCommonDen(R); … … 225 230 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 226 231 } 227 else{ 232 else 233 { 228 234 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 229 235 // Look at SqrFreeTest! … … 234 240 if (getAlgVar(R,X)) 235 241 { 236 if (R.isUnivariate())237 242 testlist=factorize( R, X ); 238 else239 testlist= Factorize(R, X, 0);240 243 } 241 244 else … … 248 251 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 249 252 } 250 if ( ! sqfreetest ){ 253 if ( ! sqfreetest ) 254 { 251 255 myrandom.next(); 252 256 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); … … 264 268 sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha, 265 269 const Variable & Extension, CanonicalForm & s, CanonicalForm & g, 266 CanonicalForm & R) {267 270 CanonicalForm & R) 271 { 268 272 DEBOUTLN(CERR, "sqrf_norm: f= ", f); 269 273 DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha); 270 if ( getCharacteristic() == 0 ) { 274 if ( getCharacteristic() == 0 ) 275 { 271 276 IntGenerator myrandom; 272 277 DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0"); … … 278 283 DEBOUTLN(CERR, "sqrf_norm: R= ", R); 279 284 } 280 else if ( degree(Extension) > 0 ){ // working over Extensions 285 else if ( degree(Extension) > 0 ) // working over Extensions 286 { 281 287 DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension)); 282 288 AlgExtGenerator myrandom(Extension); 283 289 sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R); 284 290 } 285 else{ 291 else 292 { 286 293 FFGenerator myrandom; 287 294 DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0"); … … 296 303 Variable x; 297 304 298 for ( VarlistIterator i=uord; i.hasItem(); i++){ 305 for ( VarlistIterator i=uord; i.hasItem(); i++) 306 { 299 307 x=i.getItem(); 300 for ( CFListIterator j=Astar; j.hasItem(); j++ ){ 308 for ( CFListIterator j=Astar; j.hasItem(); j++ ) 309 { 301 310 elem= j.getItem(); 302 if ( degree(elem,x) > 0 ){ // x actually occures in Astar 311 if ( degree(elem,x) > 0 ) // x actually occures in Astar 312 { 303 313 output.append(x); 304 314 break; … … 312 322 // Must be a power of p: i.e. y^{p^e}x 313 323 static int 314 inseperable(const CFList & Astar){ 324 inseperable(const CFList & Astar) 325 { 315 326 CanonicalForm elem; 316 327 int Counter= 1; 317 328 318 329 if ( Astar.length() == 0 ) return 0; 319 for ( CFListIterator i=Astar; i.hasItem(); i++){ 330 for ( CFListIterator i=Astar; i.hasItem(); i++) 331 { 320 332 elem= i.getItem(); 321 333 if ( elem.deriv() == elem.genZero() ) return Counter; … … 327 339 // calculate gcd of f and g in char=0 328 340 static CanonicalForm 329 gcd0( CanonicalForm f, CanonicalForm g ){ 341 gcd0( CanonicalForm f, CanonicalForm g ) 342 { 330 343 int charac= getCharacteristic(); 331 344 int save=isOn(SW_RATIONAL); … … 333 346 CanonicalForm ff= mapinto(f), gg= mapinto(g); 334 347 CanonicalForm result= gcd(ff,gg); 335 setCharacteristic(charac); 348 setCharacteristic(charac); 336 349 if (save) On(SW_RATIONAL); 337 350 return mapinto(result); … … 344 357 // have enough elements to plug in. 345 358 static int 346 getextension( IntList & degreelist, int n){ 359 getextension( IntList & degreelist, int n) 360 { 347 361 int charac= getCharacteristic(); 348 362 setCharacteristic(0); // need it for k ! … … 543 557 544 558 static CFFList 545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){ 559 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ) 560 { 546 561 CanonicalForm F=f, g, q,r; 547 562 CFFList Output; … … 551 566 Variable vg; 552 567 553 for (i=as; i.hasItem(); i++){ 568 for (i=as; i.hasItem(); i++) 569 { 554 570 g= i.getItem(); 555 if (g.deriv() == 0 ){ 571 if (g.deriv() == 0 ) 572 { 556 573 DEBOUTLN(CERR, "Inseperable extension detected: ", g); 557 for (j=uord; j.hasItem(); j++){ 574 for (j=uord; j.hasItem(); j++) 575 { 558 576 if ( degree(g,j.getItem()) > 0 ) vg= j.getItem(); 559 577 } … … 568 586 // Now transform all remaining polys in as: 569 587 int x=0; 570 for (ii=i; ii.hasItem(); ii++){ 571 if ( x != 0 ){ 588 for (ii=i; ii.hasItem(); ii++) 589 { 590 if ( x != 0 ) 591 { 572 592 divrem(ii.getItem(), gg, q,r); 573 593 // CERR << ii.getItem() << " divided by " << gg << "\n"; … … 595 615 596 616 // Transform back: 597 for ( CFFListIterator k=factorlist; k.hasItem(); k++){ 617 for ( CFFListIterator k=factorlist; k.hasItem(); k++) 618 { 598 619 CanonicalForm factor= k.getItem().factor(); 599 620 ii=One; 600 for (i=Two; i.hasItem(); i++){ 621 for (i=Two; i.hasItem(); i++) 622 { 601 623 DEBOUTLN(CERR, "Mapping ", i.getItem()); 602 624 DEBOUTLN(CERR, " to ", ii.getItem()); … … 618 640 // no transcendentals, seperable and inseperable extensions 619 641 CFFList 620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){ 642 newfactoras( const CanonicalForm & f, const CFList & as, int &success) 643 { 621 644 Variable vf=f.mvar(); 622 645 CFListIterator i; … … 751 774 752 775 CFFList 753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){ 776 newcfactor(const CanonicalForm & f, const CFList & as, int & success ) 777 { 754 778 Off(SW_RATIONAL); 755 CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL); 779 CFFList Output, output, Factors=Factorize(f); 780 On(SW_RATIONAL); 756 781 Factors.removeFirst(); 757 782 … … 760 785 761 786 success=1; 762 for ( CFFListIterator i=Factors; i.hasItem(); i++ ){ 787 for ( CFFListIterator i=Factors; i.hasItem(); i++ ) 788 { 763 789 output=newfactoras(i.getItem().factor(),as, success); 764 790 for ( CFFListIterator j=output; j.hasItem(); j++)
Note: See TracChangeset
for help on using the changeset viewer.