java.lang.Cloneable, Function, MultiVarFunction, KnownFunctionpublic class UserFunction extends java.lang.Object implements KnownFunction, MultiVarFunction, java.lang.Cloneable
| Modifier and Type | Class | Description |
|---|---|---|
protected static class |
UserFunction.Loader |
A class to save and load UserFunction data in an XMLControl.
|
| Modifier and Type | Field | Description |
|---|---|---|
protected java.lang.String |
description |
|
protected static java.lang.String[] |
dummyVars |
|
protected java.lang.String |
expression |
|
protected ParsedMultiVarFunction |
function |
|
protected java.lang.String[] |
functionNames |
|
protected java.lang.String |
inputString |
|
protected java.lang.String |
name |
|
protected boolean |
nameEditable |
|
protected java.lang.String[] |
paramDescriptions |
|
protected java.lang.String[] |
paramNames |
|
protected double[] |
paramValues |
|
protected KnownPolynomial |
polynomial |
|
protected UserFunction[] |
references |
|
protected java.lang.String[] |
vars |
| Constructor | Description |
|---|---|
UserFunction(java.lang.String name) |
Constructor.
|
UserFunction(KnownPolynomial poly) |
Constructor that copies a KnownPolynomial.
|
| Modifier and Type | Method | Description |
|---|---|---|
UserFunction |
clone() |
Returns a clone of this UserFunction.
|
boolean |
equals(java.lang.Object f) |
Determines if another KnownFunction is the same as this one.
|
double |
evaluate(double x) |
Evaluates the function for a single variable x.
|
double |
evaluate(double[] x) |
Evaluates the function for a variables array x.
|
boolean |
evaluatedToNaN() |
Determines if last evaluation resulted in NaN.
|
protected double[] |
evaluateSupportFunctions(double x) |
Evaluates the support functions for a single variable x.
|
protected double[] |
evaluateSupportFunctions(double[] x) |
Evaluates the support functions for a variables array x.
|
java.lang.String |
getDescription() |
Gets the description of this function.
|
java.lang.String |
getExpression() |
Gets the expression using the current variables.
|
java.lang.String |
getExpression(java.lang.String indepVarName) |
Gets the expression and sets the independent variable.
|
java.lang.String |
getExpression(java.lang.String[] varNames) |
Gets the expression and sets the independent variables.
|
java.lang.String |
getFullExpression(java.lang.String[] varNames) |
Gets the full expression using the current variables.
|
java.lang.String[] |
getFunctionNames() |
Returns function names.
|
java.lang.String |
getIndependentVariable() |
Gets the current independent variable.
|
java.lang.String[] |
getIndependentVariables() |
Gets the current independent variables.
|
java.lang.String |
getInputString() |
Gets the expression.
|
static XML.ObjectLoader |
getLoader() |
Returns the XML.ObjectLoader for this class.
|
java.lang.String |
getName() |
Gets the name.
|
int |
getParameterCount() |
Gets the parameter count.
|
java.lang.String |
getParameterDescription(int i) |
Gets a parameter description.
|
java.lang.String |
getParameterName(int i) |
Gets a parameter name.
|
double |
getParameterValue(int i) |
Gets a parameter value.
|
boolean |
isNameEditable() |
Returns true if the name is user-editable.
|
protected java.lang.String |
replaceParameterNameInExpression(java.lang.String oldName,
java.lang.String newName) |
Replaces a parameter name with a new one in the function expression.
|
void |
setDescription(java.lang.String desc) |
Sets the description of this function.
|
boolean |
setExpression(java.lang.String exp,
java.lang.String[] varNames) |
Sets the expression.
|
void |
setName(java.lang.String name) |
Sets the name.
|
void |
setNameEditable(boolean editable) |
Sets the name editable property.
|
void |
setParameters(java.lang.String[] names,
double[] values) |
Sets the parameters.
|
void |
setParameters(java.lang.String[] names,
double[] values,
java.lang.String[] descriptions) |
Sets the parameters.
|
void |
setParameterValue(int i,
double value) |
Sets a parameter value.
|
void |
setReferences(UserFunction[] functions) |
Sets the reference functions.
|
boolean |
updatePolynomial() |
Updates the associated polynomial, if any, with this functions current properties.
|
void |
updateReferenceParameters() |
Sets the parameters of reference functions to those of this function.
|
protected static java.lang.String[] dummyVars
protected java.lang.String name
protected java.lang.String[] paramNames
protected double[] paramValues
protected java.lang.String[] paramDescriptions
protected java.lang.String[] functionNames
protected java.lang.String expression
protected java.lang.String inputString
protected ParsedMultiVarFunction function
protected java.lang.String[] vars
protected UserFunction[] references
protected boolean nameEditable
protected java.lang.String description
protected KnownPolynomial polynomial
public UserFunction(java.lang.String name)
name - the function namepublic UserFunction(KnownPolynomial poly)
poly - the KnownPolynomialpublic java.lang.String getName()
getName in interface KnownFunctionpublic void setName(java.lang.String name)
setName in interface KnownFunctionname - the namepublic boolean isNameEditable()
public void setNameEditable(boolean editable)
editable - true if editablepublic java.lang.String getIndependentVariable()
public java.lang.String[] getIndependentVariables()
public java.lang.String getInputString()
public java.lang.String getExpression()
public java.lang.String getExpression(java.lang.String indepVarName)
getExpression in interface KnownFunctionindepVarName - the name of the independent variablepublic java.lang.String getExpression(java.lang.String[] varNames)
varNames - the name of the independent variablespublic java.lang.String getFullExpression(java.lang.String[] varNames)
varNames - the name of the independent variablespublic boolean setExpression(java.lang.String exp,
java.lang.String[] varNames)
exp - a parsable expression of the parameters and variablesvarNames - the names of the independent variablespublic int getParameterCount()
getParameterCount in interface KnownFunctionpublic java.lang.String getParameterName(int i)
getParameterName in interface KnownFunctioni - the parameter indexpublic double getParameterValue(int i)
getParameterValue in interface KnownFunctioni - the parameter indexpublic void setParameterValue(int i,
double value)
setParameterValue in interface KnownFunctioni - the parameter indexvalue - the valuepublic void setParameters(java.lang.String[] names,
double[] values)
names - the parameter namesvalues - the parameter valuespublic void setParameters(java.lang.String[] names,
double[] values,
java.lang.String[] descriptions)
setParameters in interface KnownFunctionnames - the parameter namesvalues - the parameter valuesdescriptions - the parameter descriptionspublic void updateReferenceParameters()
public void setReferences(UserFunction[] functions)
functions - the functions referenced by this onepublic java.lang.String getDescription()
getDescription in interface KnownFunctionpublic void setDescription(java.lang.String desc)
setDescription in interface KnownFunctiondesc - the descriptionpublic java.lang.String getParameterDescription(int i)
getParameterDescription in interface KnownFunctioni - the parameter indexpublic java.lang.String[] getFunctionNames()
public double evaluate(double x)
public double evaluate(double[] x)
evaluate in interface MultiVarFunctionx - public boolean evaluatedToNaN()
public UserFunction clone()
clone in interface KnownFunctionclone in class java.lang.Objectpublic boolean equals(java.lang.Object f)
equals in interface KnownFunctionequals in class java.lang.Objectf - the KnownFunction to testpublic boolean updatePolynomial()
protected java.lang.String replaceParameterNameInExpression(java.lang.String oldName,
java.lang.String newName)
oldName - the existing parameter namenewName - the new parameter nameprotected double[] evaluateSupportFunctions(double x)
x - protected double[] evaluateSupportFunctions(double[] x)
x - public static XML.ObjectLoader getLoader()