public abstract class ChainRuleDiffRules extends java.lang.Object implements DiffRulesI
name pfmc
rules and descriptions fields.
The rules specify the derivative of the function wrt i-th argument
which is supplied as a Node
Variable names in rules MUST be x,y for 1 to 2 variables.
So for the function f(x,y) with two arguments
if rules representing df/dx and df/dy are specified
and x and y are functions of a further variable z
then the derivative wrt z is found using the chain rule
df(x,y)/dz -> df/dx * dx/dz + df/dy * dy/dz.| Modifier and Type | Field and Description |
|---|---|
protected DeepCopyVisitor |
copier |
protected DifferentiationVisitor |
dv |
protected NodeFactory |
nf |
protected OperatorTableI |
opSet |
protected SubstitutionVisitor |
subv |
| Modifier | Constructor and Description |
|---|---|
protected |
ChainRuleDiffRules(DJep djep)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Node |
differentiate(ASTFunNode node,
java.lang.String var,
Node[] children,
Node[] dchildren)
Use the chain rule to differentiate.
|
java.lang.String[] |
getArgNames() |
java.lang.String[] |
getDescriptions() |
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.
|
java.lang.String |
getName()
returns the name of the function
|
int |
getNumRules()
Returns the number of rules which should be number of arguments of
function
|
PostfixMathCommandI |
getPfmc()
returns the PostfixMathCommandI for the function.
|
Node |
getRule(int i)
returns the i-th rule as an expression tree.
|
void |
init(Jep djep)
Initialize the component.
|
protected void |
setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node[] rules,
java.lang.String[] descriptions,
java.lang.String[] argNames)
Set the internal variables for function with multiple arguments
|
protected void |
setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node rule1,
Node rule2,
java.lang.String description1,
java.lang.String description2)
Set the internal variables for binary function with arguments named 'x' 'y'
|
protected void |
setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node rule,
java.lang.String description)
Set the internal variables for unary function with argument named 'x'
|
java.lang.String |
toString()
Returns a string representation of the rule.
|
protected DifferentiationVisitor dv
protected OperatorTableI opSet
protected NodeFactory nf
protected DeepCopyVisitor copier
protected SubstitutionVisitor subv
protected ChainRuleDiffRules(DJep djep)
protected void setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node rule,
java.lang.String description)
funName - name of functionpfmc - Jep functionrule - expression for derivative wrt 'x'description - string rep of derivativeprotected void setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node rule1,
Node rule2,
java.lang.String description1,
java.lang.String description2)
funName - name of functionpfmc - Jep functionrule1 - expression for derivative wrt 'x'rule2 - expression for derivative wrt 'y'description1 - string rep of derivativedescription2 - string rep of derivativeprotected void setup(java.lang.String funName,
PostfixMathCommandI pfmc,
Node[] rules,
java.lang.String[] descriptions,
java.lang.String[] argNames)
funName - name of functionpfmc - Jep functionrules - expression for derivativesdescriptions - text rep of derivativesargNames - names of the variables of the functionpublic Node differentiate(ASTFunNode node, java.lang.String var, Node[] children, Node[] dchildren) throws JepException
diff(f(g(x),h(x)),x) -> df/dg * dg/dx + df/dh * dh/dxdifferentiate in interface DiffRulesIvar - The name of variable to differentiate wrt to.children - the arguments of the functiondchildren - the derivatives of each argument of the function.JepExceptionParseException - if there is some problem in compiling the derivative.public void init(Jep djep)
JepComponentinit in interface JepComponentdjep - the current Jep instancepublic JepComponent getLightWeightInstance()
JepComponentgetLightWeightInstance in interface JepComponentpublic java.lang.String getName()
getName in interface DiffRulesIpublic PostfixMathCommandI getPfmc()
public int getNumRules()
public Node getRule(int i)
public java.lang.String[] getDescriptions()
public java.lang.String[] getArgNames()
public java.lang.String toString()
DiffRulesItoString in interface DiffRulesItoString in class java.lang.ObjectCopyright © 2018 Singular Systems http://www.singularsys.com/jep