|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.webcompmath.functions.FunctionParserExtension net.sourceforge.webcompmath.functions.WrapperFunction
public class WrapperFunction
A WrapperFunction contains another function and delegates to it all calls to methods from the Function interface, except for calls to setName() and getName(). (It maintains its own name, which can be different from the name of the wrapped Function.) This has at least two uses: A WrapperFunction is a FunctionParserExtension, so it can be added to a parser and then used in expressions parsed in that parser. Second, the function that is wrapped inside the WrapperFunction object can be changed by a call to the setFunction() method. This makes it possible to have a single function that can be used, for example, in ValueMath objects and Graph1D's, whose definition can be changed at will. Note that it is NOT legal to change the arity of the function when calling the setFunction() method.
Field Summary |
---|
Fields inherited from class net.sourceforge.webcompmath.functions.FunctionParserExtension |
---|
name |
Constructor Summary | |
---|---|
WrapperFunction()
added py PKHG 050415 to make visible construction possible default constructor |
|
WrapperFunction(Function f)
Create a WrapperFunction object containing a specified function. |
Method Summary | |
---|---|
void |
apply(StackOfDouble stack,
Cases cases)
Evaluate the function applied to argument values popped from the stack, and leave the result on the stack. |
boolean |
dependsOn(Variable x)
Return true if the definition of this function depends in some way on the variable x. |
Function |
derivative(int wrt)
Return the derivative of the function with repect to argument number wrt, where arguments are numbered starting from 1. |
Function |
derivative(Variable x)
Return the derivative of the function with respect to the variable x (where x is NOT one of the parameters of the function). |
int |
getArity()
Return the number of arguments of this function. |
Function |
getFunction()
Return the function that is currently wrapped in this WrapperFunction. |
double |
getVal(double[] arguments)
Find the value of the function at the argument value argument[0], .... |
double |
getValueWithCases(double[] arguments,
Cases cases)
Find the value of the function at the argument values argument[0],.... |
void |
setFunction(Function f)
Set the function that is contained in this WrapperFunction. |
java.lang.String |
toString()
To display the WrapperFunction as text, just return the wrapped function's text |
Methods inherited from class net.sourceforge.webcompmath.functions.FunctionParserExtension |
---|
appendOutputString, compileDerivative, doParse, extent, getName, setName, setParensCanBeOptional |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WrapperFunction()
public WrapperFunction(Function f)
f
- The non-null function that will be contained in the
WrapperFunction.Method Detail |
---|
public void setFunction(Function f)
f
- The non-null function to be used in this WrapperFunction
object. It must have the same arity as the current function.public Function getFunction()
public int getArity()
public double getVal(double[] arguments)
arguments
- array of args to use
public double getValueWithCases(double[] arguments, Cases cases)
arguments
- array of args to usecases
- cases to use
public Function derivative(int wrt)
wrt
- index of arg. with respect to
public Function derivative(Variable x)
x
- variable with respect to
public boolean dependsOn(Variable x)
x
- variable to check
public void apply(StackOfDouble stack, Cases cases)
apply
in interface ExpressionCommand
apply
in class FunctionParserExtension
stack
- stack to usecases
- cases to usepublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |