org.lsmp.djep.djep.diffRules
Class ChainRuleDiffRules

java.lang.Object
  extended byorg.lsmp.djep.djep.diffRules.ChainRuleDiffRules
All Implemented Interfaces:
DiffRulesI
Direct Known Subclasses:
MacroDiffRules, MacroFunctionDiffRules

public abstract class ChainRuleDiffRules
extends java.lang.Object
implements DiffRulesI

Common methods used when the rules are specified by node trees or strings. All subclasses use the chain rule to differentiate. df(g(x),h(x))/dx -> df/dg * dg/dx + df/dh * dh/dx Variable names MUST be x,y for 1 to 2 variables or x1,x2,x3 for 3 for more variables.


Field Summary
protected  java.lang.String name
           
protected  PostfixMathCommandI pfmc
           
protected  Node[] rules
           
 
Constructor Summary
ChainRuleDiffRules()
          Cannot construct outside the context of a differentation visitor.
 
Method Summary
 Node differentiate(ASTFunNode node, java.lang.String var, Node[] children, Node[] dchildren, DJep djep)
          Use the chain rule to differentiate.
 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.
 java.lang.String toString()
          Returns a string representation of the rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

pfmc

protected PostfixMathCommandI pfmc

rules

protected Node[] rules
Constructor Detail

ChainRuleDiffRules

public ChainRuleDiffRules()
Cannot construct outside the context of a differentation visitor.

Method Detail

getName

public java.lang.String getName()
returns the name of the function

Specified by:
getName in interface DiffRulesI

getPfmc

public PostfixMathCommandI getPfmc()
returns the PostfixMathCommandI for the function.


getNumRules

public int getNumRules()
Returns the number of rules which should be number of arguments of function


getRule

public Node getRule(int i)
returns the i-th rule as an expression tree.


differentiate

public Node differentiate(ASTFunNode node,
                          java.lang.String var,
                          Node[] children,
                          Node[] dchildren,
                          DJep djep)
                   throws ParseException
Use the chain rule to differentiate. df(g(x),h(x))/dx -> df/dg * dg/dx + df/dh * dh/dx

Specified by:
differentiate in interface DiffRulesI
Parameters:
var - The name of variable to differentiate wrt to.
Returns:
top node of and expression tree for the derivative.
Throws:
ParseException - if there is some problem in compiling the derivative.

toString

public java.lang.String toString()
Description copied from interface: DiffRulesI
Returns a string representation of the rule.

Specified by:
toString in interface DiffRulesI


http://www.singularsys.com/jep Copyright © 2004 Singular Systems