public class ParsedFunction
extends java.lang.Object
implements org.apache.commons.math3.analysis.MultivariateFunction, java.io.Serializable
Variables in the function must be surrounded by "#{" and "}" (think Bash, but using # instead of $ to denote variables), and should not contain any characters that would be confused with a math operation (e.g., +) or be named after a math function (e.g., cos). Also, don't put any whitespace inside the {}'s.
Dev note: This class *is not* thread safe.
Parser,
Serialized Form| Constructor and Description |
|---|
ParsedFunction(java.lang.String function)
Parse a function from a text string.
|
| Modifier and Type | Method and Description |
|---|---|
double |
evaluate()
Evaluate function with current variable values
|
java.lang.String |
getInput()
Get the string that was provided as input
|
java.util.List<java.lang.String> |
getVariableNames()
Get the list of variables.
|
int |
numVariables()
Print the number of variables this function expects
|
void |
setVariable(int index,
double val)
Define the value of a certain variable in this expression
|
void |
setVariable(java.lang.String name,
double val)
Define the value of a certain variable in this expression
|
double |
value(double[] point) |
public ParsedFunction(java.lang.String function)
throws java.lang.Exception
function - Function to be parsed. See Javadoc for formatjava.lang.Exceptionpublic java.util.List<java.lang.String> getVariableNames()
public java.lang.String getInput()
public void setVariable(java.lang.String name,
double val)
throws java.lang.Exception
name - Name of variableval - Desired valuejava.lang.Exceptionpublic void setVariable(int index,
double val)
index - Index of variableval - Desired valuepublic int numVariables()
public double value(double[] point)
value in interface org.apache.commons.math3.analysis.MultivariateFunctionpublic double evaluate()