Class JxnODE

java.lang.Object
  extended by JxnODE
All Implemented Interfaces:
FirstOrderDifferentialEquations

public class JxnODE
extends java.lang.Object
implements FirstOrderDifferentialEquations

Wrapper used to pass a system of first order differential equations (odes) to Commons Math algorithms. Computes the derivatives dyi/dt defined as String[] odes.

See CommonsMath_ODE_Lotka_Volterra~Test.jxn for an example.


Constructor Summary
JxnODE(KmgFormelInterpreter fi, java.lang.String[] odes)
          Constructs a FirstOrderDifferentialEquations instance to be used by Commons Math algorithms.
JxnODE(KmgFormelInterpreter fi, java.lang.String init, java.lang.String[] odes, double[] parameters)
          See JxnODE(KmgFormelInterpreter, java.lang.String, java.lang.String[], double[]).
 
Method Summary
 void computeDerivatives(double t, double[] y, double[] ydot)
          Computes derivatives ydot from y and t (internally called by Commons Math algorithms).
 int getDimension()
          Returns the number of states.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JxnODE

public JxnODE(KmgFormelInterpreter fi,
              java.lang.String[] odes)
Constructs a FirstOrderDifferentialEquations 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 of KmgFormelInterpreter on which the definitions in odes[...] are executed
odes - array of statement_sequences (one or more statements separated by ';'). The definitions in odes[...] must use double[] $y and $t to calculate the derivatives dy/dt. If the definition in odes[i] ends with ';', log output of intermediate steps is suppressed for the definition.

JxnODE

public JxnODE(KmgFormelInterpreter fi,
              java.lang.String init,
              java.lang.String[] odes,
              double[] parameters)
See JxnODE(KmgFormelInterpreter, java.lang.String, java.lang.String[], double[]).

Parameters:
init - statement_sequence (one or more statements separated by ';'). init is evaluated before evaluating odes and can use double[] $y and $t. If init ends with ';', log output is suppressed.
parameters - the values can be used in the init and odes definitions via the array variable $p[...]
Method Detail

getDimension

public int getDimension()
Returns the number of states.

Specified by:
getDimension in interface FirstOrderDifferentialEquations

computeDerivatives

public void computeDerivatives(double t,
                               double[] y,
                               double[] ydot)
Computes derivatives ydot from y and t (internally called by Commons Math algorithms).

Specified by:
computeDerivatives in interface FirstOrderDifferentialEquations

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object