net.sourceforge.webcompmath.functions
Class NumDerivParser

java.lang.Object
  extended by net.sourceforge.webcompmath.functions.NumDerivParser
All Implemented Interfaces:
java.io.Serializable, MathObject, ParserExtension

public class NumDerivParser
extends java.lang.Object
implements ParserExtension

The NumDerivParser class makes it possible to use numerical derivatives such as numDeriv(x,0,x^2) in a Parser. The numerical derivative psedu-function has three parameters: (1) The with-respect-to variable, which must be an identifier; (2) The value of the variable at which to evaluate the derivative, given as an expression; and (3) the expression that is to have its derivative taken. The expression in the third parameter can (and presumably will) use the variable (as well as other identifiers known to the parser). This uses a symmetric difference quotient with h = 0.001 to evaluate the derivative.

To use numerical derivatives with a Parser p, just say p.add(new NumDerivParser()). It's unlikely that you will ever need to do anything else with NumDerivParsers. If you want to use a name other than "numDeriv", you can change the name after creating the NumDerivParser object but before adding it to a parser.

See Also:
Serialized Form

Constructor Summary
NumDerivParser()
           
 
Method Summary
 void doParse(Parser parser, ParserContext context)
          When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the subexpression.
 java.lang.String getName()
          Get the name, which will be used in place of "numDeriv" in expressions.
 void setName(java.lang.String name)
          Set the name, which will be used in place of "numDeriv" in expressions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumDerivParser

public NumDerivParser()
Method Detail

setName

public void setName(java.lang.String name)
Set the name, which will be used in place of "numDeriv" in expressions. This should not be done after the NumDerivParser has been added to a Parser. The default name is "numDeriv".

Specified by:
setName in interface MathObject
Parameters:
name - name of numerical derivative

getName

public java.lang.String getName()
Get the name, which will be used in place of "numDeriv" in expressions.

Specified by:
getName in interface MathObject
Returns:
name of numerical derivative

doParse

public void doParse(Parser parser,
                    ParserContext context)
When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the subexpression. The subexpression has the form ( , , ). This method is not meant to be called directly

Specified by:
doParse in interface ParserExtension
Parameters:
parser - parser to use
context - context to use