org.apache.commons.math3.ode.nonstiff

## Class RungeKuttaStepInterpolator

- java.lang.Object
- - org.apache.commons.math3.ode.sampling.AbstractStepInterpolator
  - - org.apache.commons.math3.ode.nonstiff.RungeKuttaStepInterpolator

- All Implemented Interfaces:
    Externalizable, Serializable, StepInterpolator
  Direct Known Subclasses:
    ClassicalRungeKuttaStepInterpolator, DormandPrince54StepInterpolator, DormandPrince853StepInterpolator, EulerStepInterpolator, GillStepInterpolator, HighamHall54StepInterpolator, MidpointStepInterpolator, ThreeEighthesStepInterpolator

      abstract class RungeKuttaStepInterpolator
      extends AbstractStepInterpolator

  This class represents an interpolator over the last step during an ODE integration for Runge-Kutta and embedded Runge-Kutta integrators.
  Since:
    1.2
  Version:
    $Id: RungeKuttaStepInterpolator.java 1416643 2012-12-03 19:37:14Z tn $
  See Also:
    `RungeKuttaIntegrator`, `EmbeddedRungeKuttaIntegrator`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AbstractIntegrator` | `integrator` Reference to the integrator.
    `protected double[]` | `previousState` Previous state.
    `protected double[][]` | `yDotK` Slopes at the intermediate points

    - ### Fields inherited from class org.apache.commons.math3.ode.sampling.AbstractStepInterpolator

      `currentState, h, interpolatedDerivatives, interpolatedPrimaryDerivatives, interpolatedPrimaryState, interpolatedSecondaryDerivatives, interpolatedSecondaryState, interpolatedState, interpolatedTime`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RungeKuttaStepInterpolator()` Simple constructor.
    `` | `RungeKuttaStepInterpolator(RungeKuttaStepInterpolator interpolator)` Copy constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `readExternal(ObjectInput in)`
    `void` | `reinitialize(AbstractIntegrator rkIntegrator, double[] y, double[][] yDotArray, boolean forward, EquationsMapper primaryMapper, EquationsMapper[] secondaryMappers)` Reinitialize the instance
    `void` | `shift()` Shift one step forward.
    `void` | `writeExternal(ObjectOutput out)`

    - ### Methods inherited from class org.apache.commons.math3.ode.sampling.AbstractStepInterpolator

      `computeInterpolatedStateAndDerivatives, copy, doCopy, doFinalize, finalizeStep, getCurrentTime, getGlobalCurrentTime, getGlobalPreviousTime, getInterpolatedDerivatives, getInterpolatedSecondaryDerivatives, getInterpolatedSecondaryState, getInterpolatedState, getInterpolatedTime, getPreviousTime, isForward, readBaseExternal, reinitialize, setInterpolatedTime, setSoftCurrentTime, setSoftPreviousTime, storeTime, writeBaseExternal`

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

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

- - ### Field Detail

    - #### previousState

          protected double[] previousState

      Previous state.

    - #### yDotK

          protected double[][] yDotK

      Slopes at the intermediate points

    - #### integrator

          protected AbstractIntegrator integrator

      Reference to the integrator.

  - ### Constructor Detail

    - #### RungeKuttaStepInterpolator

          protected RungeKuttaStepInterpolator()

      Simple constructor. This constructor builds an instance that is not usable yet, the `reinitialize(org.apache.commons.math3.ode.AbstractIntegrator, double[], double[][], boolean, org.apache.commons.math3.ode.EquationsMapper, org.apache.commons.math3.ode.EquationsMapper[])` method should be called before using the instance in order to initialize the internal arrays. This constructor is used only in order to delay the initialization in some cases. The `RungeKuttaIntegrator` and `EmbeddedRungeKuttaIntegrator` classes use the prototyping design pattern to create the step interpolators by cloning an uninitialized model and latter initializing the copy.

    - #### RungeKuttaStepInterpolator

          public RungeKuttaStepInterpolator(RungeKuttaStepInterpolator interpolator)

      Copy constructor.

      The copied interpolator should have been finalized before the copy, otherwise the copy will not be able to perform correctly any interpolation and will throw a `NullPointerException` later. Since we don't want this constructor to throw the exceptions finalization may involve and since we don't want this method to modify the state of the copied interpolator, finalization is not done automatically, it remains under user control.

      The copy is a deep copy: its arrays are separated from the original arrays of the instance.

      Parameters:
        `interpolator` - interpolator to copy from.

  - ### Method Detail

    - #### reinitialize

          public void reinitialize(AbstractIntegrator rkIntegrator,
                          double[] y,
                          double[][] yDotArray,
                          boolean forward,
                          EquationsMapper primaryMapper,
                          EquationsMapper[] secondaryMappers)

      Reinitialize the instance

      Some Runge-Kutta integrators need fewer functions evaluations than their counterpart step interpolators. So the interpolator should perform the last evaluations they need by themselves. The `RungeKuttaIntegrator` and `EmbeddedRungeKuttaIntegrator` abstract classes call this method in order to let the step interpolator perform the evaluations it needs. These evaluations will be performed during the call to `doFinalize` if any, i.e. only if the step handler either calls the `finalizeStep` method or the `getInterpolatedState` method (for an interpolator which needs a finalization) or if it clones the step interpolator.

      Parameters:
        `rkIntegrator` - integrator being used
        `y` - reference to the integrator array holding the state at the end of the step
        `yDotArray` - reference to the integrator array holding all the intermediate slopes
        `forward` - integration direction indicator
        `primaryMapper` - equations mapper for the primary equations set
        `secondaryMappers` - equations mappers for the secondary equations sets

    - #### shift

          public void shift()

      Shift one step forward. Copy the current time into the previous time, hence preparing the interpolator for future calls to `storeTime`
      Overrides:
        `shift` in class `AbstractStepInterpolator`

    - #### writeExternal

          public void writeExternal(ObjectOutput out)
                             throws IOException

      Specified by:
        `writeExternal` in interface `Externalizable`
      Specified by:
        `writeExternal` in class `AbstractStepInterpolator`
      Throws:
        `IOException`

    - #### readExternal

          public void readExternal(ObjectInput in)
                            throws IOException,
                                   ClassNotFoundException

      Specified by:
        `readExternal` in interface `Externalizable`
      Specified by:
        `readExternal` in class `AbstractStepInterpolator`
      Throws:
        `IOException`
        `ClassNotFoundException`

Copyright (c) 2003-2013 Apache Software Foundation