org.apache.commons.math.ode.jacobians
Class FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper

java.lang.Object
  extended by org.apache.commons.math.ode.jacobians.FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, StepInterpolatorWithJacobians
Enclosing class:
FirstOrderIntegratorWithJacobians

private static class FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper
extends java.lang.Object
implements StepInterpolatorWithJacobians

Wrapper for step interpolators.


Field Summary
private  double[][] dydp
          Jacobian with respect to parameters dy/dp.
private  double[][] dydpDot
          Time derivative of the jacobian with respect to parameters dy/dp.
private  double[][] dydy0
          Jacobian with respect to initial state dy/dy0.
private  double[][] dydy0Dot
          Time derivative of the sacobian with respect to initial state dy/dy0.
private  StepInterpolator interpolator
          Wrapped interpolator.
private  double[] y
          State array.
private  double[] yDot
          Time derivative of the state array.
 
Constructor Summary
FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper()
          Simple constructor.
FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper(StepInterpolator interpolator, int n, int k)
          Simple constructor.
 
Method Summary
 StepInterpolatorWithJacobians copy()
          Copy the instance.
private static void copyArray(double[][] src, double[][] dest)
          Copy an array.
private static void copyArray(double[] src, double[] dest)
          Copy an array.
 double getCurrentTime()
          Get the current grid point time.
 double[][] getInterpolatedDyDp()
          Get the partial derivatives of the state vector with respect to the ODE parameters of the interpolated point.
 double[][] getInterpolatedDyDpDot()
          Get the time derivatives of the jacobian of the state vector with respect to the ODE parameters of the interpolated point.
 double[][] getInterpolatedDyDy0()
          Get the partial derivatives of the state vector with respect to the initial state of the interpolated point.
 double[][] getInterpolatedDyDy0Dot()
          Get the time derivatives of the jacobian of the state vector with respect to the initial state of the interpolated point.
 double getInterpolatedTime()
          Get the time of the interpolated point.
 double[] getInterpolatedY()
          Get the state vector of the interpolated point.
 double[] getInterpolatedYDot()
          Get the time derivatives of the state vector of the interpolated point.
 double getPreviousTime()
          Get the previous grid point time.
 boolean isForward()
          Check if the natural integration direction is forward.
private static void readArray(java.io.ObjectInput in, double[] array)
          Read an array.
private static void readArray(java.io.ObjectInput in, double[][] array)
          Read an array.
 void readExternal(java.io.ObjectInput in)
          
 void setInterpolatedTime(double time)
          Set the time of the interpolated point.
private static void writeArray(java.io.ObjectOutput out, double[] array)
          Write an array.
private static void writeArray(java.io.ObjectOutput out, double[][] array)
          Write an array.
 void writeExternal(java.io.ObjectOutput out)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interpolator

private StepInterpolator interpolator
Wrapped interpolator.


y

private double[] y
State array.


dydy0

private double[][] dydy0
Jacobian with respect to initial state dy/dy0.


dydp

private double[][] dydp
Jacobian with respect to parameters dy/dp.


yDot

private double[] yDot
Time derivative of the state array.


dydy0Dot

private double[][] dydy0Dot
Time derivative of the sacobian with respect to initial state dy/dy0.


dydpDot

private double[][] dydpDot
Time derivative of the jacobian with respect to parameters dy/dp.

Constructor Detail

FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper

public FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper()
Simple constructor.

This constructor is used only for externalization. It does nothing.


FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper

public FirstOrderIntegratorWithJacobians.StepInterpolatorWrapper(StepInterpolator interpolator,
                                                                 int n,
                                                                 int k)
Simple constructor.

Parameters:
interpolator - wrapped interpolator
n - dimension of the original ODE
k - number of parameters
Method Detail

setInterpolatedTime

public void setInterpolatedTime(double time)
Set the time of the interpolated point.

Setting the time outside of the current step is now allowed, but should be used with care since the accuracy of the interpolator will probably be very poor far from this step. This allowance has been added to simplify implementation of search algorithms near the step endpoints.

Setting the time changes the instance internal state. If a specific state must be preserved, a copy of the instance must be created using StepInterpolatorWithJacobians.copy().

Specified by:
setInterpolatedTime in interface StepInterpolatorWithJacobians
Parameters:
time - time of the interpolated point

isForward

public boolean isForward()
Check if the natural integration direction is forward.

This method provides the integration direction as specified by the integrator itself, it avoid some nasty problems in degenerated cases like null steps due to cancellation at step initialization, step control or discrete events triggering.

Specified by:
isForward in interface StepInterpolatorWithJacobians
Returns:
true if the integration variable (time) increases during integration

getPreviousTime

public double getPreviousTime()
Get the previous grid point time.

Specified by:
getPreviousTime in interface StepInterpolatorWithJacobians
Returns:
previous grid point time

getInterpolatedTime

public double getInterpolatedTime()
Get the time of the interpolated point. If StepInterpolatorWithJacobians.setInterpolatedTime(double) has not been called, it returns the current grid point time.

Specified by:
getInterpolatedTime in interface StepInterpolatorWithJacobians
Returns:
interpolation point time

getInterpolatedY

public double[] getInterpolatedY()
                          throws DerivativeException
Get the state vector of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedY in interface StepInterpolatorWithJacobians
Returns:
state vector at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedYDot()

getInterpolatedDyDy0

public double[][] getInterpolatedDyDy0()
                                throws DerivativeException
Get the partial derivatives of the state vector with respect to the initial state of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedDyDy0 in interface StepInterpolatorWithJacobians
Returns:
partial derivatives of the state vector with respect to the initial state at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedY()

getInterpolatedDyDp

public double[][] getInterpolatedDyDp()
                               throws DerivativeException
Get the partial derivatives of the state vector with respect to the ODE parameters of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedDyDp in interface StepInterpolatorWithJacobians
Returns:
partial derivatives of the state vector with respect to the ODE parameters at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedY()

getInterpolatedYDot

public double[] getInterpolatedYDot()
                             throws DerivativeException
Get the time derivatives of the state vector of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedYDot in interface StepInterpolatorWithJacobians
Returns:
derivatives of the state vector at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedY()

getInterpolatedDyDy0Dot

public double[][] getInterpolatedDyDy0Dot()
                                   throws DerivativeException
Get the time derivatives of the jacobian of the state vector with respect to the initial state of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedDyDy0Dot in interface StepInterpolatorWithJacobians
Returns:
time derivatives of the jacobian of the state vector with respect to the initial state at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedY()

getInterpolatedDyDpDot

public double[][] getInterpolatedDyDpDot()
                                  throws DerivativeException
Get the time derivatives of the jacobian of the state vector with respect to the ODE parameters of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls.

Specified by:
getInterpolatedDyDpDot in interface StepInterpolatorWithJacobians
Returns:
time derivatives of the jacobian of the state vector with respect to the ODE parameters at time StepInterpolatorWithJacobians.getInterpolatedTime()
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.getInterpolatedY()

getCurrentTime

public double getCurrentTime()
Get the current grid point time.

Specified by:
getCurrentTime in interface StepInterpolatorWithJacobians
Returns:
current grid point time

copy

public StepInterpolatorWithJacobians copy()
                                   throws DerivativeException
Copy the instance.

The copied instance is guaranteed to be independent from the original one. Both can be used with different settings for interpolated time without any side effect.

Specified by:
copy in interface StepInterpolatorWithJacobians
Returns:
a deep copy of the instance, which can be used independently.
Throws:
DerivativeException - if this call induces an automatic step finalization that throws one
See Also:
StepInterpolatorWithJacobians.setInterpolatedTime(double)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

copyArray

private static void copyArray(double[] src,
                              double[] dest)
Copy an array.

Parameters:
src - source array
dest - destination array

copyArray

private static void copyArray(double[][] src,
                              double[][] dest)
Copy an array.

Parameters:
src - source array
dest - destination array

writeArray

private static void writeArray(java.io.ObjectOutput out,
                               double[] array)
                        throws java.io.IOException
Write an array.

Parameters:
out - output stream
array - array to write
Throws:
java.io.IOException - if array cannot be read

writeArray

private static void writeArray(java.io.ObjectOutput out,
                               double[][] array)
                        throws java.io.IOException
Write an array.

Parameters:
out - output stream
array - array to write
Throws:
java.io.IOException - if array cannot be read

readArray

private static void readArray(java.io.ObjectInput in,
                              double[] array)
                       throws java.io.IOException
Read an array.

Parameters:
in - input stream
array - array to read
Throws:
java.io.IOException - if array cannot be read

readArray

private static void readArray(java.io.ObjectInput in,
                              double[][] array)
                       throws java.io.IOException
Read an array.

Parameters:
in - input stream
array - array to read
Throws:
java.io.IOException - if array cannot be read


Copyright (c) 2003-2013 Apache Software Foundation