Changeset 2955ba in git
- Timestamp:
- Oct 7, 2009, 12:26:11 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- bedecea1bbe3e8a1d0e5a820d4d446733ede75b9
- Parents:
- cfca59b87c9afcfaf6c14e04e85063f3e85d9934
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_map.cc
rcfca59 r2955ba 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_map.cc,v 1.1 4 2006-05-15 09:03:04Singular Exp $ */2 /* $Id: cf_map.cc,v 1.15 2009-10-07 10:26:11 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 27 27 { 28 28 if ( this != &p ) { 29 30 29 V = p.V; 30 S = p.S; 31 31 } 32 32 return *this; … … 68 68 int j; 69 69 for ( i = L, j = 1; i.hasItem(); i++, j++ ) 70 70 P.insert( MapPair( Variable(j), i.getItem() ) ); 71 71 } 72 72 //}}} … … 82 82 { 83 83 if ( this != &m ) 84 84 P = m.P; 85 85 return *this; 86 86 } … … 155 155 156 156 if ( j.hasItem() ) 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 157 if ( j.getItem().var() != f.mvar() ) { 158 // simply descend if the current MapPair variable is 159 // not the main variable of f 160 CanonicalForm result = 0; 161 CFIterator I; 162 for ( I = f; I.hasTerms(); I++ ) 163 result += power( f.mvar(), I.exp() ) * subsrec( I.coeff(), j ); 164 return result; 165 } 166 else { 167 // replace the main variable of f with the image of 168 // the current variable under MapPair 169 CanonicalForm result = 0; 170 CanonicalForm s = j.getItem().subst(); 171 CFIterator I; 172 // move on to the next MapPair 173 j++; 174 for ( I = f; I.hasTerms(); I++ ) 175 result += subsrec( I.coeff(), j ) * power( s, I.exp() ); 176 return result; 177 } 178 178 else 179 179 return f; 180 180 } 181 181 //}}} … … 235 235 n = i = 1; 236 236 while ( i <= level( f ) ) { 237 238 239 240 241 242 243 237 while( degs[i] == 0 ) i++; 238 if ( i != n ) { 239 // swap variables and remember the swap in the map 240 m.newpair( Variable( n ), Variable( i ) ); 241 result = swapvar( result, Variable( i ), Variable( n ) ); 242 } 243 n++; i++; 244 244 } 245 245 delete [] degs; … … 267 267 M = N = CFMap(); 268 268 if ( a.size() == 0 ) 269 269 return; 270 270 int maxlevel = level( a[a.min()] ); 271 271 int i, j; … … 273 273 // get the maximum of levels in a 274 274 for ( i = a.min() + 1; i <= a.max(); i++ ) 275 276 275 if ( level( a[i] ) > maxlevel ) 276 maxlevel = level( a[i] ); 277 277 if ( maxlevel <= 0 ) 278 278 return; 279 279 280 280 int * degs = new int[maxlevel+1]; 281 281 int * tmp = new int[maxlevel+1]; 282 282 for ( i = 1; i <= maxlevel; i++ ) 283 283 degs[i] = 0; 284 284 285 285 // calculate the union of all levels occuring in a 286 286 for ( i = a.min(); i <= a.max(); i++ ) { 287 288 289 290 287 tmp = degrees( a[i], tmp ); 288 for ( j = 1; j <= level( a[i] ); j++ ) 289 if ( tmp[j] != 0 ) 290 degs[j] = 1; 291 291 } 292 292 … … 294 294 i = 1; j = 1; 295 295 while ( i <= maxlevel ) { 296 297 298 299 300 301 296 if ( degs[i] != 0 ) { 297 M.newpair( Variable(i), Variable(j) ); 298 N.newpair( Variable(j), Variable(i) ); 299 j++; 300 } 301 i++; 302 302 } 303 303 delete [] tmp; … … 373 373 int * degsg = new int[n+1]; 374 374 375 for ( i = 0; i <= n; i++ ) { 376 degsf[i] = degsg[i] = 0; 375 for ( i = 0; i <= n; i++ ) 376 { 377 degsf[i] = degsg[i] = 0; 377 378 } 378 379 … … 382 383 383 384 i = 1; k = 1; 384 if ( pe > 1 ){ 385 M.newpair( Variable(pe), Variable(k) ); 386 N.newpair( Variable(k), Variable(pe) ); 385 if ( pe > 1 ) 386 { 387 M.newpair( Variable(pe), Variable(k) ); 388 N.newpair( Variable(k), Variable(pe) ); 387 389 k++; 388 390 } 389 while ( i <= n ) { 390 if ( degsf[i] > 0 && degsg[i] > 0 ) { 391 if ( ( i != k ) && ( i != pe ) && ( i != p1 ) ) { 392 M.newpair( Variable(i), Variable(k) ); 393 N.newpair( Variable(k), Variable(i) ); 394 } 395 k++; 396 } 397 i++; 398 } 399 if ( p1 != pe ){ 400 M.newpair( Variable(p1), Variable(k) ); 401 N.newpair( Variable(k), Variable(p1) ); 391 while ( i <= n ) 392 { 393 if ( degsf[i] > 0 && degsg[i] > 0 ) 394 { 395 if ( ( i != k ) && ( i != pe ) && ( i != p1 ) ) 396 { 397 M.newpair( Variable(i), Variable(k) ); 398 N.newpair( Variable(k), Variable(i) ); 399 } 400 k++; 401 } 402 i++; 403 } 404 if ( p1 != pe ) 405 { 406 M.newpair( Variable(p1), Variable(k) ); 407 N.newpair( Variable(k), Variable(p1) ); 402 408 k++; 403 409 } 404 410 i = 1; 405 while ( i <= n ) { 406 if ( degsf[i] > 0 && degsg[i] == 0 ) { 407 if ( i != k ) { 408 M.newpair( Variable(i), Variable(k) ); 409 k++; 411 while ( i <= n ) 412 { 413 if ( degsf[i] > 0 && degsg[i] == 0 ) { 414 if ( i != k ) 415 { 416 M.newpair( Variable(i), Variable(k) ); 417 k++; 410 418 } 411 } 412 else if ( degsf[i] == 0 && degsg[i] > 0 ) { 413 if ( i != k ) { 414 M.newpair( Variable(i), Variable(k) ); 415 k++; 419 } 420 else if ( degsf[i] == 0 && degsg[i] > 0 ) 421 { 422 if ( i != k ) 423 { 424 M.newpair( Variable(i), Variable(k) ); 425 k++; 416 426 } 417 418 427 } 428 i++; 419 429 } 420 430 -
factory/cf_ops.cc
rcfca59 r2955ba 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_ops.cc,v 1.1 1 2007-12-19 14:26:20Singular Exp $ */2 /* $Id: cf_ops.cc,v 1.12 2009-10-07 10:26:11 Singular Exp $ */ 3 3 4 4 //{{{ docu … … 507 507 // 508 508 //}}} 509 int * 510 degrees ( const CanonicalForm & f, int * degs ) 509 int * degrees ( const CanonicalForm & f, int * degs ) 511 510 { 512 511 if ( f.inCoeffDomain() ) … … 535 534 // 536 535 //}}} 537 int 538 totaldegree ( const CanonicalForm & f ) 536 int totaldegree ( const CanonicalForm & f ) 539 537 { 540 538 if ( f.isZero() )
Note: See TracChangeset
for help on using the changeset viewer.