|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface NumericalDifferentiable
The interface specifies the methods that must be supplied for
a class to be able to perform automatic differentiation in
the reverse mode.
Example of use:
The example uses the classes from the symbolic computation
package org.jscience.mathematics.analysis.expressions.symbolic that supports automatic differentiation.
Note that since all classes do not implement the NumericalDifferentiable
interface some class castings are necessary.
In the example x, y, and z are independent variables/parameters, and
e and f are dependent variables.
All other expressions are auxiliaries.
Variable x = new Variable( "x" ); Variable y = new Variable( "y" ); Parameter z = new Parameter( "z" ); Expression a = new Sin( x ); Expression b = new Multiplication( new Constant( 1.0 ), x ); Expression c = new Division( y, a ); Expression d = new Multiplication( a, z ); Expression e = new Subtraction( b, c ); Expression f = new Addition( c, d ); for(int k = 0; k < 10; k++) f = new Sin( f ); x.setIndex( 1 ); y.setIndex( 2 ); z.setIndex( 3 ); ((NumericalDifferentiable)e).setNumberOfIndependents( 3 ); ((NumericalDifferentiable)f).setNumberOfIndependents( 3 ); x.setValue( 0.13 ); y.setValue( 0.46 ); z.setValue( 0.73 ); ((NumericalDifferentiable)e).resetNumEval(); ((NumericalDifferentiable)f).resetNumEval(); ((NumericalDifferentiable)e).resetNumDiff( 1 ); ((NumericalDifferentiable)f).resetNumDiff( 1 ); double dedx = ((NumericalDifferentiable)e).numDiff( 1 ); double dfdx = ((NumericalDifferentiable)f).numDiff( 1 ); ((NumericalDifferentiable)e).resetNumDiff( 2 ); ((NumericalDifferentiable)f).resetNumDiff( 2 ); double dedy = ((NumericalDifferentiable)e).numDiff( 2 ); double dfdy = ((NumericalDifferentiable)f).numDiff( 2 ); ((NumericalDifferentiable)e).resetNumDiff( 3 ); ((NumericalDifferentiable)f).resetNumDiff( 3 ); double dedz = ((NumericalDifferentiable)e).numDiff( 3 ); double dfdz = ((NumericalDifferentiable)f).numDiff( 3 );
| Method Summary | |
|---|---|
double |
numDiff(int i)
Returns the derivative of an Expression with respect to a NamedDataExpression whose index is the parameter. |
double |
numEval()
Compute the numerical value of the function expression. |
void |
resetNumDiff(int i)
Reset the computational tree for derivative calculation for the indexed independent variable. |
void |
resetNumEval()
Reset the function evaluation such that the next invocation of numEval() carries out the full computation. |
void |
setIndex(int i)
Sets the index of an independent variable. |
void |
setNumberOfIndependents(int n)
Sets the number of independent variables in the computational tree. |
| Method Detail |
|---|
double numDiff(int i)
i - DOCUMENT ME!
void resetNumDiff(int i)
i - DOCUMENT ME!void setNumberOfIndependents(int n)
n - DOCUMENT ME!void setIndex(int i)
i - DOCUMENT ME!double numEval()
void resetNumEval()
numEval() carries out the full computation.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||