Changeset bc76e8 in git for factory/canonicalform.cc
- Timestamp:
- Aug 29, 1997, 3:15:16 PM (27 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 45448d01d1185bac4b858ea8a686a5370e7d2161
- Parents:
- cfff6a26b7988bc4bfccd2c82b877fd314c3fce6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/canonicalform.cc
rcfff6a2 rbc76e8 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: canonicalform.cc,v 1.1 4 1997-08-04 14:57:41schmidt Exp $ */2 /* $Id: canonicalform.cc,v 1.15 1997-08-29 13:15:16 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 358 358 } 359 359 360 //{{{ CanonicalForm CanonicalForm::deriv() const 361 //{{{ docu 362 // 363 // deriv() - return the formal derivation of CO. 364 // 365 // Derives CO with respect to its main variable. Returns zero if 366 // f is in a coefficient domain. 367 // 368 //}}} 360 369 CanonicalForm 361 370 CanonicalForm::deriv() const … … 372 381 } 373 382 } 374 383 //}}} 384 385 //{{{ CanonicalForm CanonicalForm::deriv( const Variable & x ) const 386 //{{{ docu 387 // 388 // deriv() - return the formal derivation of CO with respect to x. 389 // 390 // Note: If x is less than the main variable of CO we have to 391 // swap variables which may be quite expensive. x should be a 392 // polynomial variable. Returns zero if f is in a coefficient 393 // domain. 394 // 395 //}}} 375 396 CanonicalForm 376 397 CanonicalForm::deriv( const Variable & x ) const 377 398 { 378 if ( inCoeffDomain() ) 399 ASSERT( x.level() > 0, "cannot derive with respect to algebraic variables" ); 400 Variable y = mvar(); 401 if ( inCoeffDomain() || x > y ) 379 402 return 0; 380 else { 381 CanonicalForm res = 0; 382 Variable y = mvar(); 383 for ( CFIterator i = (y==x) ? *this : swapvar( *this, x, y ); i.hasTerms(); i++ ) 384 if ( i.exp() > 0 ) 385 res += power( y, i.exp()-1 ) * i.coeff() * i.exp(); 386 return (y==x) ? res : swapvar( res, x, y ); 387 } 388 } 403 else if ( x == y ) 404 return deriv(); 405 else 406 return swapvar( swapvar( *this, x, y ).deriv( y ), x, y ); 407 } 408 //}}} 389 409 390 410 CanonicalForm
Note: See TracChangeset
for help on using the changeset viewer.