Changeset bc76e8 in git for factory/canonicalform.cc


Ignore:
Timestamp:
Aug 29, 1997, 3:15:16 PM (27 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
45448d01d1185bac4b858ea8a686a5370e7d2161
Parents:
cfff6a26b7988bc4bfccd2c82b877fd314c3fce6
Message:
	* canonicalform.cc (deriv( Variable )): assertion added
	(deriv( Variable )): bug fix


git-svn-id: file:///usr/local/Singular/svn/trunk@644 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/canonicalform.cc

    rcfff6a2 rbc76e8  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: canonicalform.cc,v 1.14 1997-08-04 14:57:41 schmidt Exp $ */
     2/* $Id: canonicalform.cc,v 1.15 1997-08-29 13:15:16 schmidt Exp $ */
    33
    44#include <config.h>
     
    358358}
    359359
     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//}}}
    360369CanonicalForm
    361370CanonicalForm::deriv() const
     
    372381    }
    373382}
    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//}}}
    375396CanonicalForm
    376397CanonicalForm::deriv( const Variable & x ) const
    377398{
    378     if ( inCoeffDomain() )
     399    ASSERT( x.level() > 0, "cannot derive with respect to algebraic variables" );
     400    Variable y = mvar();
     401    if ( inCoeffDomain() || x > y )
    379402        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//}}}
    389409
    390410CanonicalForm
Note: See TracChangeset for help on using the changeset viewer.