ptolemy.domains.ct.kernel
Class CTBaseIntegrator.History

java.lang.Object
  extended by ptolemy.domains.ct.kernel.CTBaseIntegrator.History
Enclosing class:
CTBaseIntegrator

protected class CTBaseIntegrator.History
extends java.lang.Object

The history information, state and derivatives, at equidistance past time points. This inner class is protected so that it can be tested.


Field Summary
private  int _capacity
           
private  CTBaseIntegrator _container
           
private  java.util.LinkedList<CTBaseIntegrator.DoubleDouble> _entries
           
private  double _stepsize
           
 
Constructor Summary
CTBaseIntegrator.History(CTBaseIntegrator container)
          Construct a history object and associate it with the given integrator.
 
Method Summary
private  double[] _extrapolation(double[] p1, double[] p2, double s)
           
private  double[] _Hermite(double[] p1, double[] p2, double s)
           
 void clear()
          Remove all history information.
 int getCapacity()
          Return the maximum capacity.
 double[] getEntry(int index)
          Return the index-th entry in the history.
 int getValidEntryCount()
          Return the number of valid entries.
 void pushEntry(double state, double derivative)
          Push the new state-derivative pair into the history.
 void rebalance(double currentStepSize)
          Rebalance the history information with respect to the current step size, such that the information in the history list are equally distanced, and the distance is the current step size.
 void setCapacity(int capacity)
          Set the history capacity.
 double[][] toDoubleArray()
          Return the history information in an array format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_container

private CTBaseIntegrator _container

_entries

private java.util.LinkedList<CTBaseIntegrator.DoubleDouble> _entries

_capacity

private int _capacity

_stepsize

private double _stepsize
Constructor Detail

CTBaseIntegrator.History

public CTBaseIntegrator.History(CTBaseIntegrator container)
Construct a history object and associate it with the given integrator.

Parameters:
container - The container that contains this history object.
Method Detail

clear

public void clear()
Remove all history information.


getCapacity

public int getCapacity()
Return the maximum capacity.

Returns:
The capacity.
See Also:
setCapacity(int)

getValidEntryCount

public int getValidEntryCount()
Return the number of valid entries.

Returns:
The number of valid history entries.

getEntry

public double[] getEntry(int index)
Return the index-th entry in the history. The index starts from 0. If the current time index is n, then calling this method with argument 0 will return the history of time index n-1.

Parameters:
index - The index of the entry.
Returns:
The double matrix storing the index-th state and its derivative in history.

pushEntry

public void pushEntry(double state,
                      double derivative)
               throws IllegalActionException
Push the new state-derivative pair into the history. If the number of entries exceeds the capacity after the pushing , then the oldest entry will be lost.

Parameters:
state - The state.
derivative - THe derivative of the state.
Throws:
IllegalActionException - If the capacity of history is less than or equal to zero.

rebalance

public void rebalance(double currentStepSize)
               throws IllegalActionException
Rebalance the history information with respect to the current step size, such that the information in the history list are equally distanced, and the distance is the current step size. If the current step size is less than the history step size used in the history list, then a 4-th order Hermite interpolation is used for every two consecutive points. If the current step size is larger than the history step size, then a linear extrapolation is used.

Parameters:
currentStepSize - The current step size.
Throws:
IllegalActionException - If the director has an invalid time resolution parameter.

setCapacity

public void setCapacity(int capacity)
Set the history capacity. The entries exceed the capacity will be lost. If the argument is less than 0, it is set to 0.

Parameters:
capacity - The new capacity.
See Also:
getCapacity()

toDoubleArray

public double[][] toDoubleArray()
Return the history information in an array format. The entries are ordered in their backward chronological order.

Returns:
The content of the history information in a double array format.

_Hermite

private double[] _Hermite(double[] p1,
                          double[] p2,
                          double s)

_extrapolation

private double[] _extrapolation(double[] p1,
                                double[] p2,
                                double s)