org.apache.commons.math.ode.jacobians

## Class FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper

- java.lang.Object
- - org.apache.commons.math.ode.jacobians.FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper

All Implemented Interfaces:
  FirstOrderDifferentialEquations, ODEWithJacobians

Enclosing class:
  FirstOrderIntegratorWithJacobians

    private class FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper
    extends Object
    implements ODEWithJacobians

Wrapper class to compute jacobians by finite differences for ODE which do not compute them themselves.

### Field Summary

Fields
`private double[]` `hP` Step sizes to use for computing the jacobian df/dp.
`private double[]` `hY` Step sizes to use for computing the jacobian df/dy.
`private ParameterizedODE` `ode` Raw ODE without jacobians computation.
`private double[]` `p` Parameters array (may be null if parameters dimension from original problem is zero)
`private double[]` `tmpDot` Temporary array for state derivatives used to compute jacobians.

### Constructor Summary

Constructors
Constructor and Description
`FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper(ParameterizedODE ode, double[] p, double[] hY, double[] hP)` Simple constructor.

### Method Summary

Methods
`void` `computeDerivatives(double t, double[] y, double[] yDot)` Get the current time derivative of the state vector.
`void` `computeJacobians(double t, double[] y, double[] yDot, double[][] dFdY, double[][] dFdP)` Compute the partial derivatives of ODE with respect to state.
`int` `getDimension()` Get the dimension of the problem.
`int` `getParametersDimension()` Get the number of parameters.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### ode

    private final ParameterizedODE ode

Raw ODE without jacobians computation.

#### p

    private final double[] p

Parameters array (may be null if parameters dimension from original problem is zero)

#### hY

    private final double[] hY

Step sizes to use for computing the jacobian df/dy.

#### hP

    private final double[] hP

Step sizes to use for computing the jacobian df/dp.

#### tmpDot

    private final double[] tmpDot

Temporary array for state derivatives used to compute jacobians.

### Constructor Detail

#### FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper

    public FirstOrderIntegratorWithJacobians.FiniteDifferencesWrapper(ParameterizedODE ode,
                                                              double[] p,
                                                              double[] hY,
                                                              double[] hP)

Simple constructor.

Parameters:
  `ode` - original ODE problem, without jacobians computations
  `p` - parameters array (may be null if parameters dimension from original problem is zero)
  `hY` - step sizes to use for computing the jacobian df/dy
  `hP` - step sizes to use for computing the jacobian df/dp

### Method Detail

#### getDimension

    public int getDimension()

Get the dimension of the problem.

Specified by:
  `getDimension` in interface `FirstOrderDifferentialEquations`
Returns:
  dimension of the problem

#### computeDerivatives

    public void computeDerivatives(double t,
                          double[] y,
                          double[] yDot)
                            throws DerivativeException

Get the current time derivative of the state vector.

Specified by:
  `computeDerivatives` in interface `FirstOrderDifferentialEquations`
Parameters:
  `t` - current value of the independent time variable
  `y` - array containing the current value of the state vector
  `yDot` - placeholder array where to put the time derivative of the state vector
Throws:
  `DerivativeException` - this user-defined exception should be used if an error is is triggered by user code

#### getParametersDimension

    public int getParametersDimension()

Get the number of parameters.

Specified by:
  `getParametersDimension` in interface `ODEWithJacobians`
Returns:
  number of parameters

#### computeJacobians

    public void computeJacobians(double t,
                        double[] y,
                        double[] yDot,
                        double[][] dFdY,
                        double[][] dFdP)
                          throws DerivativeException

Compute the partial derivatives of ODE with respect to state.

Specified by:
  `computeJacobians` in interface `ODEWithJacobians`
Parameters:
  `t` - current value of the independent time variable
  `y` - array containing the current value of the state vector
  `yDot` - array containing the current value of the time derivative of the state vector
  `dFdY` - placeholder array where to put the jacobian of the ODE with respect to the state vector
  `dFdP` - placeholder array where to put the jacobian of the ODE with respect to the parameters
Throws:
  `DerivativeException` - this exception is propagated to the caller if the underlying user function triggers one