Changeset 9d6bf4 in git
 Timestamp:
 Jul 3, 2012, 1:50:59 PM (11 years ago)
 Branches:
 (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
 Children:
 cd81417ddd6d2d3d0d2f8b3b8f109992056f2920
 Parents:
 18500b278c2d1587c78c8502e401e80745031231
 gitauthor:
 Hans Schoenemann <hannes@mathematik.unikl.de>20120703 13:50:59+02:00
 gitcommitter:
 Martin Lee <martinlee84@web.de>20120803 10:03:18+02:00
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libfac/charset/alg_factor.cc
r18500b r9d6bf4 2 2 // emacs edit mode for this file is * C++ * 3 3 //////////////////////////////////////////////////////////// 4 //////////////////////////////////////////////////////////// 4 5 5 // FACTORY  Includes 6 6 #include <factory.h> … … 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); … … 169 173 if (getAlgVar(R,X)) 170 174 { 171 if (R.isUnivariate())172 175 testlist=factorize( R, X ); 173 else174 testlist= Factorize(R, X, 0);175 176 } 176 177 else … … 198 199 sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha, 199 200 AlgExtGenerator & myrandom, CanonicalForm & s, CanonicalForm & g, 200 CanonicalForm & R){ 201 CanonicalForm & R) 202 { 201 203 Variable y=PPalpha.mvar(),vf=f.mvar(); 202 204 CanonicalForm temp, Palpha=PPalpha, t; … … 225 227 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 226 228 } 227 else{ 229 else 230 { 228 231 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 229 232 // Look at SqrFreeTest! … … 234 237 if (getAlgVar(R,X)) 235 238 { 236 if (R.isUnivariate())237 239 testlist=factorize( R, X ); 238 else239 testlist= Factorize(R, X, 0);240 240 } 241 241 else … … 248 248 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 249 249 } 250 if ( ! sqfreetest ){ 250 if ( ! sqfreetest ) 251 { 251 252 myrandom.next(); 252 253 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); … … 264 265 sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha, 265 266 const Variable & Extension, CanonicalForm & s, CanonicalForm & g, 266 CanonicalForm & R) {267 267 CanonicalForm & R) 268 { 268 269 DEBOUTLN(CERR, "sqrf_norm: f= ", f); 269 270 DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha); 270 if ( getCharacteristic() == 0 ) { 271 if ( getCharacteristic() == 0 ) 272 { 271 273 IntGenerator myrandom; 272 274 DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0"); … … 278 280 DEBOUTLN(CERR, "sqrf_norm: R= ", R); 279 281 } 280 else if ( degree(Extension) > 0 ){ // working over Extensions 282 else if ( degree(Extension) > 0 ) // working over Extensions 283 { 281 284 DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension)); 282 285 AlgExtGenerator myrandom(Extension); 283 286 sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R); 284 287 } 285 else{ 288 else 289 { 286 290 FFGenerator myrandom; 287 291 DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0"); … … 296 300 Variable x; 297 301 298 for ( VarlistIterator i=uord; i.hasItem(); i++){ 302 for ( VarlistIterator i=uord; i.hasItem(); i++) 303 { 299 304 x=i.getItem(); 300 for ( CFListIterator j=Astar; j.hasItem(); j++ ){ 305 for ( CFListIterator j=Astar; j.hasItem(); j++ ) 306 { 301 307 elem= j.getItem(); 302 if ( degree(elem,x) > 0 ){ // x actually occures in Astar 308 if ( degree(elem,x) > 0 ) // x actually occures in Astar 309 { 303 310 output.append(x); 304 311 break; … … 312 319 // Must be a power of p: i.e. y^{p^e}x 313 320 static int 314 inseperable(const CFList & Astar){ 321 inseperable(const CFList & Astar) 322 { 315 323 CanonicalForm elem; 316 324 int Counter= 1; 317 325 318 326 if ( Astar.length() == 0 ) return 0; 319 for ( CFListIterator i=Astar; i.hasItem(); i++){ 327 for ( CFListIterator i=Astar; i.hasItem(); i++) 328 { 320 329 elem= i.getItem(); 321 330 if ( elem.deriv() == elem.genZero() ) return Counter; … … 327 336 // calculate gcd of f and g in char=0 328 337 static CanonicalForm 329 gcd0( CanonicalForm f, CanonicalForm g ){ 338 gcd0( CanonicalForm f, CanonicalForm g ) 339 { 330 340 int charac= getCharacteristic(); 331 341 int save=isOn(SW_RATIONAL); … … 333 343 CanonicalForm ff= mapinto(f), gg= mapinto(g); 334 344 CanonicalForm result= gcd(ff,gg); 335 setCharacteristic(charac); 345 setCharacteristic(charac); 336 346 if (save) On(SW_RATIONAL); 337 347 return mapinto(result); … … 344 354 // have enough elements to plug in. 345 355 static int 346 getextension( IntList & degreelist, int n){ 356 getextension( IntList & degreelist, int n) 357 { 347 358 int charac= getCharacteristic(); 348 359 setCharacteristic(0); // need it for k ! … … 543 554 544 555 static CFFList 545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){ 556 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ) 557 { 546 558 CanonicalForm F=f, g, q,r; 547 559 CFFList Output; … … 551 563 Variable vg; 552 564 553 for (i=as; i.hasItem(); i++){ 565 for (i=as; i.hasItem(); i++) 566 { 554 567 g= i.getItem(); 555 if (g.deriv() == 0 ){ 568 if (g.deriv() == 0 ) 569 { 556 570 DEBOUTLN(CERR, "Inseperable extension detected: ", g); 557 for (j=uord; j.hasItem(); j++){ 571 for (j=uord; j.hasItem(); j++) 572 { 558 573 if ( degree(g,j.getItem()) > 0 ) vg= j.getItem(); 559 574 } … … 568 583 // Now transform all remaining polys in as: 569 584 int x=0; 570 for (ii=i; ii.hasItem(); ii++){ 571 if ( x != 0 ){ 585 for (ii=i; ii.hasItem(); ii++) 586 { 587 if ( x != 0 ) 588 { 572 589 divrem(ii.getItem(), gg, q,r); 573 590 // CERR << ii.getItem() << " divided by " << gg << "\n"; … … 595 612 596 613 // Transform back: 597 for ( CFFListIterator k=factorlist; k.hasItem(); k++){ 614 for ( CFFListIterator k=factorlist; k.hasItem(); k++) 615 { 598 616 CanonicalForm factor= k.getItem().factor(); 599 617 ii=One; 600 for (i=Two; i.hasItem(); i++){ 618 for (i=Two; i.hasItem(); i++) 619 { 601 620 DEBOUTLN(CERR, "Mapping ", i.getItem()); 602 621 DEBOUTLN(CERR, " to ", ii.getItem()); … … 618 637 // no transcendentals, seperable and inseperable extensions 619 638 CFFList 620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){ 639 newfactoras( const CanonicalForm & f, const CFList & as, int &success) 640 { 621 641 Variable vf=f.mvar(); 622 642 CFListIterator i; … … 751 771 752 772 CFFList 753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){ 773 newcfactor(const CanonicalForm & f, const CFList & as, int & success ) 774 { 754 775 Off(SW_RATIONAL); 755 CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL); 776 CFFList Output, output, Factors=Factorize(f); 777 On(SW_RATIONAL); 756 778 Factors.removeFirst(); 757 779 … … 760 782 761 783 success=1; 762 for ( CFFListIterator i=Factors; i.hasItem(); i++ ){ 784 for ( CFFListIterator i=Factors; i.hasItem(); i++ ) 785 { 763 786 output=newfactoras(i.getItem().factor(),as, success); 764 787 for ( CFFListIterator j=output; j.hasItem(); j++)
Note: See TracChangeset
for help on using the changeset viewer.