Package com.singularsys.extensions.djep
Class DVariable
- java.lang.Object
-
- java.util.Observable
-
- com.singularsys.jep.Variable
-
- com.singularsys.extensions.xjep.XVariable
-
- com.singularsys.extensions.djep.DVariable
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
PartialDerivative
public class DVariable extends XVariable
Holds all info about a variable. Has a name, an equation, a dimension (or sent of dimensions if matrix or tensor) and also a set ofPartialDerivative
. The derivatives are stored in a hashtable index by the sorted names of derivatives. i.e. d^2f/dxdy, and d^2f/dydx will both be indexed by {"x","y"}. df/dx is indexed by {"x"}, d^2f/dx^2 is index by {"x","x"}. Partial derivatives are calculated as required by the findDerivative method.- Author:
- Rich Morris Created on 26-Oct-2003
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,PartialDerivative>
derivatives
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<PartialDerivative>
allDerivatives()
Enumerate all the derivatives of this variable.protected PartialDerivative
calculateDerivative(java.lang.String[] derivnames, DJep jep)
calculate a derivative.protected PartialDerivative
createDerivative(java.lang.String[] derivnames, Node eqn)
boolean
derivativeIsTrivallyZero()
PartialDerivative
getDerivative(java.lang.String... names)
Gets the partial derivativesdf^k/da db dc
void
invalidateAll()
makes value and values of all derivatives invalid.static java.lang.String
makeDerivString(java.lang.String rootname, java.lang.String[] dnames)
Produces a string to represent the derivative.void
setEquation(Node eqn)
sets the equationjava.lang.String
toString(PrintVisitor bpv)
Returns a string rep of variable with its equation and value.-
Methods inherited from class com.singularsys.extensions.xjep.XVariable
calcValue, getEquation, hasEquation, toString
-
Methods inherited from class com.singularsys.jep.Variable
getHook, getName, getValue, hasValidValue, hookKeys, isConstant, removeHook, setHook, setIsConstant, setValidValue, setValue, setValue, setValueRaw
-
-
-
-
Field Detail
-
derivatives
protected java.util.Map<java.lang.String,PartialDerivative> derivatives
-
-
Method Detail
-
createDerivative
protected PartialDerivative createDerivative(java.lang.String[] derivnames, Node eqn)
-
setEquation
public void setEquation(Node eqn)
sets the equation- Overrides:
setEquation
in classXVariable
-
invalidateAll
public void invalidateAll()
makes value and values of all derivatives invalid.
-
makeDerivString
public static java.lang.String makeDerivString(java.lang.String rootname, java.lang.String[] dnames)
Produces a string to represent the derivative. The string will be of the form "dx^2/dxdy". This string is used to index the derivatives of a variable.- Parameters:
rootname
- name of the variable we are calculating the derivative of.dnames
- An array of the names of each of the partial derivatives.- Returns:
- the string representation
-
getDerivative
public PartialDerivative getDerivative(java.lang.String... names)
Gets the partial derivativesdf^k/da db dc
- Parameters:
names
- the names of the derivatives in any order- Returns:
- the derivative
-
calculateDerivative
protected PartialDerivative calculateDerivative(java.lang.String[] derivnames, DJep jep) throws ParseException
calculate a derivative. Either by differentiation of one of the existing derivatives, or by differentiation of the equation of this variable. The method is protected, sub classes can override the methods where some other means of calculating the derivative is needed.- Throws:
ParseException
-
toString
public java.lang.String toString(PrintVisitor bpv)
Description copied from class:XVariable
Returns a string rep of variable with its equation and value.
-
allDerivatives
public java.lang.Iterable<PartialDerivative> allDerivatives()
Enumerate all the derivatives of this variable.- Returns:
- an Enumeration running through all the derivatives.
-
derivativeIsTrivallyZero
public boolean derivativeIsTrivallyZero()
-
-