public class PuComplexFunction extends PsObject
Default names of complex variables are {"z", "w"} or, if more created with more than
three variables, {"z0", "z1", "z2", ...}. A good practice is to specify individual variables
directly after creating a function object using setVariables(String [])
.
Default names of the component functions are {"f", "g"} or, if more created with more than
two component functions, {"F[0]", "F[1]", ...}. A good practice is to specify individual expression names
directly after creating a function object using setExpressionNames(String [])
.
The following real and complex constants are registered by default: {"Pi", "pi", "i", "I"}.
An arbitrary number of additional parameters can be added to a function.
Usage:
// Complex-valued function in one variable PuFunction function = new PuFunction(1, 1); m_function.setName("Square Function"); m_function.setVariables(new String[] {"z"}); m_function.setExpression("z*z"); PuComplex result = m_function.eval(PuComplex arg);or
// Complex surface in C3: PuFunction function = new PuFunction(1, 3); m_function.setName("Complex Surface"); m_function.setVariables(new String[] {"z"}); m_function.setExpression(0, "z*z"); m_function.setExpression(1, "sqrt(z)"); m_function.setExpression(2, "2*z+3*i"); m_function.eval(PuComplex [] result, PuComplex arg);Later, a function can be evaluated by calling
m_function.eval(PuComplex [] result, PuComplex arg);
See jv.thirdParty.expr.Expr
for a list and notation of functions.
Expr
,
Serialized FormHAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
Constructor and Description |
---|
PuComplexFunction() |
PuComplexFunction(int numVariables,
int numFunctions) |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(PuDouble parm)
Add adjustable function parameter to all expressions.
|
void |
addParameter(java.lang.String symbol,
double initialValue)
Add additional variables to all expressions, usually used as constants or parameters.
|
java.lang.Object |
clone()
Duplicate a function object by recursively cloning all instance variables.
|
void |
copy(PsObject object)
Copies data from given function object.
|
PuComplex |
eval(int ind,
PuComplex arg)
Evaluate a component of an m-dim functions of 1 variable'.
|
PuComplex |
eval(int ind,
PuComplex[] args)
Evaluate a component of an m-dim functions of n-variables'.
|
PuComplex |
eval(PuComplex arg)
Evaluate a complex-valued function of one variable.
|
PuComplex |
eval(PuComplex[] args)
Evaluate a complex-valued function in n variables.
|
boolean |
eval(PuComplex[] result,
PuComplex arg)
Evaluate an m-dim functions of n-variables'.
|
java.lang.String |
getExpression()
Get string of function if number of functions is 1.
|
java.lang.String |
getExpression(int ind)
Get string of function with index
ind . |
java.lang.String |
getExpressionName()
Get string of function if number of functions is 1.
|
java.lang.String |
getExpressionName(int ind)
Get string of function with index
ind . |
java.lang.String[] |
getExpressionNames()
Get string of function if number of functions is 1.
|
java.lang.String[] |
getExpressions()
Get strings of all function.
|
int |
getNumFunctions()
Get number of functions.
|
int |
getNumParameters()
Get number of parameters used in current functions.
|
int |
getNumVariables()
Get number of argument variables used in current functions.
|
PuDouble |
getParameter(java.lang.String symbol)
Return stored function parameters as PuDouble objects.
|
java.util.Enumeration |
getParameters()
Return stored function parameters as PuDouble objects.
|
java.lang.String[] |
getVariables()
Get array of variables names.
|
void |
init()
If instance has missing name then assign default name 'Object_NUMBER' where
number is the total number of already created instances.
|
boolean |
setDefExpression(int ind,
java.lang.String expr)
Set string of function with index
ind . |
boolean |
setExpression(int ind,
java.lang.String expr)
Set string of function with index
ind . |
boolean |
setExpression(java.lang.String expr)
Supply expression of function if number of functions is 1.
|
void |
setExpressionName(int ind,
java.lang.String name)
Set name of individual function expression.
|
void |
setExpressionName(java.lang.String name)
Set name of function expression.
|
void |
setExpressionNames(java.lang.String[] name)
Set names of all function expressions.
|
boolean |
setExpressions(java.lang.String[] exprArr)
Supply expressions of all functions.
|
void |
setNumFunctions(int numFunctions)
Set number of functions.
|
void |
setNumVariables(int numVariables)
Set number of argument variables used in current functions.
|
void |
setParameter(java.lang.String symbol,
double value)
Set value of variable in all expressions, usually used as constants or parameters.
|
void |
setVariables(java.lang.String[] symbol)
Add symbols of variables in all expressions.
|
java.lang.String |
toString()
Create a multi-line string representation
with detailed information about all instance variables.
|
boolean |
update(java.lang.Object event)
Update the class whenever a child has changed.
|
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, updatePanels
public PuComplexFunction()
public PuComplexFunction(int numVariables, int numFunctions)
public void init()
PsObject
public java.lang.Object clone()
clone
in class PsObject
PsObject.copy(PsObject)
public void copy(PsObject object)
copy
in class PsObject
PsObject.clone()
public java.lang.String toString()
public boolean update(java.lang.Object event)
update
in interface PsUpdateIf
update
in class PsObject
event
- carries a lot of informationPsObject.setParent(PsUpdateIf)
,
PsObject.getFather()
,
PsObject.addUpdateListener(PsUpdateIf)
public void addParameter(PuDouble parm)
addParameter(String, double)
.
Use getParameter(String)
to return parameter objects.
This function object is registered as update listener of the slider. Whenever the slider changes then this function object updates the corresponding variable value.
getParameter(String)
public PuDouble getParameter(java.lang.String symbol)
addParameter(PuDouble)
to store function parameter.symbol
- symbol of previously added PuDouble, see PuDouble#getSymbol()
.addParameter(PuDouble)
public java.util.Enumeration getParameters()
addParameter(PuDouble)
to store function parameter.addParameter(PuDouble)
public int getNumParameters()
public void addParameter(java.lang.String symbol, double initialValue)
public void setParameter(java.lang.String symbol, double value)
public int getNumVariables()
public void setNumVariables(int numVariables)
public java.lang.String[] getVariables()
public void setVariables(java.lang.String[] symbol)
public int getNumFunctions()
public void setNumFunctions(int numFunctions)
public java.lang.String getExpressionName()
public void setExpressionName(java.lang.String name)
public java.lang.String getExpressionName(int ind)
ind
.public void setExpressionName(int ind, java.lang.String name)
public java.lang.String[] getExpressionNames()
public void setExpressionNames(java.lang.String[] name)
public java.lang.String[] getExpressions()
public java.lang.String getExpression()
public java.lang.String getExpression(int ind)
ind
.public boolean setExpression(java.lang.String expr)
public boolean setExpression(int ind, java.lang.String expr)
ind
.
String is trimmed, i.e. leading and trailing whitespace characters are removed using String.trim().
public boolean setDefExpression(int ind, java.lang.String expr)
ind
.
String is trimmed, i.e. leading and trailing whitespace characters are removed using String.trim().
public boolean setExpressions(java.lang.String[] exprArr)
public PuComplex eval(PuComplex arg)
arg
- Value of function argument.public PuComplex eval(int ind, PuComplex arg)
ind
- Component to evaluatearg
- Value of function argument.public PuComplex eval(PuComplex[] args)
args
- Array of function arguments.public PuComplex eval(int ind, PuComplex[] args)
ind
- Component to evaluateargs
- Value of function argument."