Class JxnODE
- java.lang.Object
-
- JxnODE
-
- All Implemented Interfaces:
FirstOrderDifferentialEquations
public class JxnODE extends Object implements FirstOrderDifferentialEquations
Wrapper used to pass a system of first order ordinary differential equations (odes) to Commons Math algorithms. Computes the derivativesdy
i/dt
defined in theString[] odes
.
See CommonsMath_ODE_Lotka_Volterra~Test.jxn for an example.
-
-
Constructor Summary
Constructors Constructor Description JxnODE(KmgFormelInterpreter fi, String[] odes)
Constructs aFirstOrderDifferentialEquations
instance to be used by Commons Math algorithms.JxnODE(KmgFormelInterpreter fi, String init, String[] odes, double[] parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeDerivatives(double t, double[] y, double[] ydot)
Computes derivativesydot
fromy
andt
(internally called by Commons Math algorithms).int
getDimension()
Returns the number of states.String
toString()
-
-
-
Constructor Detail
-
JxnODE
public JxnODE(KmgFormelInterpreter fi, String[] odes)
Constructs aFirstOrderDifferentialEquations
instance to be used by Commons Math algorithms.
Example:ode = @JxODE( $this, { "$y[0]*( a - b $y[1] );", "$y[1]*( d $y[0] - c );" } )
- Parameters:
fi
- instance ofKmgFormelInterpreter
on which the definitions inodes[...]
are executedodes
- array of statement_sequences (one or more statements separated by ';
'). The definitions inodes[...]
must usedouble[] $y
and$t
to calculate the derivativesdy/dt
. If the definition inodes[i]
ends with ';
', log output of intermediate steps is suppressed for the definition.
-
JxnODE
public JxnODE(KmgFormelInterpreter fi, String init, String[] odes, double[] parameters)
- Parameters:
init
- statement_sequence (one or more statements separated by ';
').init
is evaluated before evaluatingodes
and can usedouble[] $y
and$t
. Ifinit
ends with ';
', log output is suppressed.parameters
- the values can be used in theinit
andodes
definitions via the array variable$p[...]
-
-
Method Detail
-
getDimension
public int getDimension()
Returns the number of states.- Specified by:
getDimension
in interfaceFirstOrderDifferentialEquations
-
computeDerivatives
public void computeDerivatives(double t, double[] y, double[] ydot)
Computes derivativesydot
fromy
andt
(internally called by Commons Math algorithms).- Specified by:
computeDerivatives
in interfaceFirstOrderDifferentialEquations
-
-