public class ExpressionFunction extends FunctionParserExtension
name
Constructor and Description |
---|
ExpressionFunction(String name,
String def)
Constuct a function of one parameter, named "x", by parsing the String, def,
to get the definition of the function.
|
ExpressionFunction(String name,
String[] paramNames,
String def,
Parser parser)
Constuct a function of one or more parameters by parsing the String, def,
to get the definition of the function.
|
ExpressionFunction(String name,
Variable[] params,
Expression definition)
Construct a function from a list of variables that serve as parameters and an expression that,
presumably, can include those variables.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(StackOfDouble stack,
Cases cases)
Find the value of the function applied to arguments popped
from the stack, and push the result back onto 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 the arguments are numbered 1, 2, 3,....
|
Function |
derivative(Variable x)
Return the derivative of the function with respect to the
variable x.
|
int |
getArity()
Return the number of arguments of this function.
|
String |
getDefinitionString()
Return the expression that defines this function, as a string.
|
double |
getVal(double[] arguments)
Find the value of the function at the argument values
given by arguments[0], arguments[1], ...
|
double |
getValueWithCases(double[] arguments,
Cases cases)
Find the value of the function at the argument values
given by arguments[0], arguments[1], ...
|
void |
redefine(String def)
Set the definition of this function by parsing the given string,
using a default parser.
|
void |
redefine(String def,
Parser parser)
Set the definition of this function, using the specified parser (or a default
parser if parser is null).
|
String |
toString()
Return a string that describes this function, such as "function f(x,y) given by x^2 - y^2".
|
appendOutputString, compileDerivative, doParse, extent, getName, setName, setParensCanBeOptional
public ExpressionFunction(String name, String def)
name
- Name of function. This should not be null if the function is to be used in a Parser.def
- contains definition of the function, as a function of "x".public ExpressionFunction(String name, String[] paramNames, String def, Parser parser)
name
- Name of function.paramNames
- Names of the parameters of the function. The lenght of this array determines the arity of the function.def
- The definition of the function, in terms of the parameters from the paramNames array.parser
- Used to parse the definition. If this is null, a standard parser is used. The
paramaters are temporarily added onto the parser while the function definition is being parsed.public ExpressionFunction(String name, Variable[] params, Expression definition)
public void redefine(String def)
public void redefine(String def, Parser parser)
public String getDefinitionString()
public String toString()
public int getArity()
public double getVal(double[] arguments)
public double getValueWithCases(double[] arguments, Cases cases)
public Function derivative(int wrt)
public Function derivative(Variable x)
public boolean dependsOn(Variable x)
public void apply(StackOfDouble stack, Cases cases)
apply
in interface ExpressionCommand
apply
in class FunctionParserExtension
stack
- contains results of previous commands in the program.cases
- if non-null, any case information generated during evaluation should be recorded here.