org.apache.commons.math3.ode
public class JacobianMatrices extends java.lang.Object
secondary equations
to
compute the Jacobian matrices with respect to the initial state vector and, if
any, to some parameters of the primary ODE set.
It is intended to be packed into an ExpandableStatefulODE
in conjunction with a primary set of ODE, which may be:
ExpandableStatefulODE
,
FirstOrderDifferentialEquations
,
MainStateJacobianProvider
,
ParameterJacobianProvider
,
ParameterizedODE
Modifier and Type | Class and Description |
---|---|
private class |
JacobianMatrices.JacobiansSecondaryEquations
Local implementation of secondary equations.
|
private static class |
JacobianMatrices.MainStateJacobianWrapper
Wrapper class to compute jacobian matrices by finite differences for ODE
which do not compute them by themselves.
|
static class |
JacobianMatrices.MismatchedEquations
Special exception for equations mismatch.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
dirtyParameter
Boolean for selected parameters consistency.
|
private ExpandableStatefulODE |
efode
Expandable first order differential equation.
|
private int |
index
Index of the instance in the expandable set.
|
private java.util.List<ParameterJacobianProvider> |
jacobianProviders
FODE with exact parameter Jacobian computation skill.
|
private MainStateJacobianProvider |
jode
FODE with exact primary Jacobian computation skill.
|
private double[] |
matricesData
State and parameters Jacobian matrices in a row.
|
private int |
paramDim
Parameters dimension.
|
private ParameterizedODE |
pode
FODE without exact parameter Jacobian computation skill.
|
private ParameterConfiguration[] |
selectedParameters
Selected parameters for parameter Jacobian computation.
|
private int |
stateDim
Main state vector dimension.
|
Constructor and Description |
---|
JacobianMatrices(FirstOrderDifferentialEquations fode,
double[] hY,
java.lang.String... parameters)
Simple constructor for a secondary equations set computing Jacobian matrices.
|
JacobianMatrices(MainStateJacobianProvider jode,
java.lang.String... parameters)
Simple constructor for a secondary equations set computing Jacobian matrices.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameterJacobianProvider(ParameterJacobianProvider provider)
Add a parameter Jacobian provider.
|
private void |
checkDimension(int expected,
java.lang.Object array)
Check array dimensions.
|
void |
getCurrentMainSetJacobian(double[][] dYdY0)
Get the current value of the Jacobian matrix with respect to state.
|
void |
getCurrentParameterJacobian(java.lang.String pName,
double[] dYdP)
Get the current value of the Jacobian matrix with respect to one parameter.
|
void |
registerVariationalEquations(ExpandableStatefulODE expandable)
Register the variational equations for the Jacobians matrices to the expandable set.
|
void |
setInitialMainStateJacobian(double[][] dYdY0)
Set the initial value of the Jacobian matrix with respect to state.
|
void |
setInitialParameterJacobian(java.lang.String pName,
double[] dYdP)
Set the initial value of a column of the Jacobian matrix with respect to one parameter.
|
void |
setParameterizedODE(ParameterizedODE parameterizedOde)
Set a parameter Jacobian provider.
|
void |
setParameterStep(java.lang.String parameter,
double hP)
Set the step associated to a parameter in order to compute by finite
difference the Jacobian matrix.
|
private ExpandableStatefulODE efode
private int index
private MainStateJacobianProvider jode
private ParameterizedODE pode
private int stateDim
private ParameterConfiguration[] selectedParameters
private java.util.List<ParameterJacobianProvider> jacobianProviders
private int paramDim
private boolean dirtyParameter
private double[] matricesData
public JacobianMatrices(FirstOrderDifferentialEquations fode, double[] hY, java.lang.String... parameters) throws DimensionMismatchException
Parameters must belong to the supported ones given by Parameterizable.getParametersNames()
, so the primary set of differential
equations must be Parameterizable
.
Note that each selection clears the previous selected parameters.
fode
- the primary first order differential equations set to extendhY
- step used for finite difference computation with respect to state vectorparameters
- parameters to consider for Jacobian matrices processing
(may be null if parameters Jacobians is not desired)DimensionMismatchException
- if there is a dimension mismatch between
the steps array hY
and the equation dimensionpublic JacobianMatrices(MainStateJacobianProvider jode, java.lang.String... parameters)
Parameters must belong to the supported ones given by Parameterizable.getParametersNames()
, so the primary set of differential
equations must be Parameterizable
.
Note that each selection clears the previous selected parameters.
jode
- the primary first order differential equations set to extendparameters
- parameters to consider for Jacobian matrices processing
(may be null if parameters Jacobians is not desired)public void registerVariationalEquations(ExpandableStatefulODE expandable) throws DimensionMismatchException, JacobianMatrices.MismatchedEquations
expandable
- expandable set into which variational equations should be registeredDimensionMismatchException
- if the dimension of the partial state does not
match the selected equations set dimensionJacobianMatrices.MismatchedEquations
- if the primary set of the expandable set does
not match the one used to build the instanceExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)
public void addParameterJacobianProvider(ParameterJacobianProvider provider)
provider
- the parameter Jacobian provider to compute exactly the parameter Jacobian matrixpublic void setParameterizedODE(ParameterizedODE parameterizedOde)
parameterizedOde
- the parameterized ODE to compute the parameter Jacobian matrix using finite differencespublic void setParameterStep(java.lang.String parameter, double hP) throws UnknownParameterException
Needed if and only if the primary ODE set is a ParameterizedODE
.
Given a non zero parameter value pval for the parameter, a reasonable value
for such a step is pval * FastMath.sqrt(Precision.EPSILON)
.
A zero value for such a step doesn't enable to compute the parameter Jacobian matrix.
parameter
- parameter to consider for Jacobian processinghP
- step for Jacobian finite difference computation w.r.t. the specified parameterUnknownParameterException
- if the parameter is not supportedParameterizedODE
public void setInitialMainStateJacobian(double[][] dYdY0) throws DimensionMismatchException
If this method is not called, the initial value of the Jacobian matrix with respect to state is set to identity.
dYdY0
- initial Jacobian matrix w.r.t. stateDimensionMismatchException
- if matrix dimensions are incorrectpublic void setInitialParameterJacobian(java.lang.String pName, double[] dYdP) throws UnknownParameterException, DimensionMismatchException
If this method is not called for some parameter, the initial value of the column of the Jacobian matrix with respect to this parameter is set to zero.
pName
- parameter namedYdP
- initial Jacobian column vector with respect to the parameterUnknownParameterException
- if a parameter is not supportedDimensionMismatchException
- if the column vector does not match state dimensionpublic void getCurrentMainSetJacobian(double[][] dYdY0)
dYdY0
- current Jacobian matrix with respect to state.public void getCurrentParameterJacobian(java.lang.String pName, double[] dYdP)
pName
- name of the parameter for the computed Jacobian matrixdYdP
- current Jacobian matrix with respect to the named parameterprivate void checkDimension(int expected, java.lang.Object array) throws DimensionMismatchException
expected
- expected dimensionarray
- (may be null if expected is 0)DimensionMismatchException
- if the array dimension does not match the expected oneCopyright (c) 2003-2013 Apache Software Foundation