Top Description Fields Constructors Methods
org.apache.commons.math3.ode.nonstiff

public Class AdamsNordsieckFieldTransformer<T extends RealFieldElement<T>>

extends Object
Class Inheritance
Type Parameters
<T>
the type of the field elements
Imports
java.util.Arrays, .HashMap, .Map, org.apache.commons.math3.Field, .RealFieldElement, org.apache.commons.math3.linear.Array2DRowFieldMatrix, .ArrayFieldVector, .FieldDecompositionSolver, .FieldLUDecomposition, .FieldMatrix, org.apache.commons.math3.util.MathArrays

Transformer to Nordsieck vectors for Adams integrators.

This class is used by Adams-Bashforth and Adams-Moulton integrators to convert between classical representation with several previous first derivatives and Nordsieck representation with higher order scaled derivatives.

We define scaled derivatives si(n) at step n as:

s1(n) = h y'n for first derivative
s2(n) = h2/2 y''n for second derivative
s3(n) = h3/6 y'''n for third derivative
...
sk(n) = hk/k! y(k)n for kth derivative

With the previous definition, the classical representation of multistep methods uses first derivatives only, i.e. it handles yn, s1(n) and qn where qn is defined as:

  qn = [ s1(n-1) s1(n-2) ... s1(n-(k-1)) ]T
(we omit the k index in the notation for clarity).

Another possible representation uses the Nordsieck vector with higher degrees scaled derivatives all taken at the same step, i.e it handles yn, s1(n) and rn) where rn is defined as:

rn = [ s2(n), s3(n) ... sk(n) ]T
(here again we omit the k index in the notation for clarity)

Taylor series formulas show that for any index offset i, s1(n-i) can be computed from s1(n), s2(n) ... sk(n), the formula being exact for degree k polynomials.

s1(n-i) = s1(n) + ∑j>0 (j+1) (-i)j sj+1(n)
The previous formula can be used with several values for i to compute the transform between classical representation and Nordsieck vector at step end. The transform between rn and qn resulting from the Taylor series formulas above is:
qn = s1(n) u + P rn
where u is the [ 1 1 ... 1 ]T vector and P is the (k-1)×(k-1) matrix built with the (j+1) (-i)j terms with i being the row number starting from 1 and j being the column number starting from 1:
       [  -2   3   -4    5  ... ]
       [  -4  12  -32   80  ... ]
  P =  [  -6  27 -108  405  ... ]
       [  -8  48 -256 1280  ... ]
       [          ...           ]

Changing -i into +i in the formula above can be used to compute a similar transform between classical representation and Nordsieck vector at step start. The resulting matrix is simply the absolute value of matrix P.

For Adams-Bashforth method, the Nordsieck vector at step n+1 is computed from the Nordsieck vector at step n as follows:

where A is a rows shifting matrix (the lower left part is an identity matrix):
       [ 0 0   ...  0 0 | 0 ]
       [ ---------------+---]
       [ 1 0   ...  0 0 | 0 ]
   A = [ 0 1   ...  0 0 | 0 ]
       [       ...      | 0 ]
       [ 0 0   ...  1 0 | 0 ]
       [ 0 0   ...  0 1 | 0 ]

For Adams-Moulton method, the predicted Nordsieck vector at step n+1 is computed from the Nordsieck vector at step n as follows:

From this predicted vector, the corrected vector is computed as follows: where the upper case Yn+1, S1(n+1) and Rn+1 represent the predicted states whereas the lower case yn+1, sn+1 and rn+1 represent the corrected states.

We observe that both methods use similar update formulas. In both cases a P-1u vector and a P-1 A P matrix are used that do not depend on the state, they only depend on k. This class handles these transformations.

Since
3.6

Field Summary

Modifier and TypeField and Description
private final T[]
c1

Update coefficients of the higher order derivatives wrt y'.

private static final Map<Integer, Map<Field<? extends RealFieldElement<?>>, AdamsNordsieckFieldTransformer<? extends RealFieldElement<?>>>>
CACHE

Cache for already computed coefficients.

private final Field<T>
field

Field to which the time and state vector elements belong.

private final Array2DRowFieldMatrix<T>
update

Update matrix for the higher order derivatives h2/2 y'', h3/6 y''' ...

Constructor Summary

AccessConstructor and Description
private
AdamsNordsieckFieldTransformer(final Field<T>
field to which the time and state vector elements belong
field
,
final int
number of steps of the multistep method (excluding the one being computed)
n
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
private FieldMatrix<T>

Returns:

P matrix
buildP
(final int
number of rows of the matrix
rows
)

Build the P matrix.

public static <
the type of the field elements
T extends RealFieldElement<T>
>
AdamsNordsieckFieldTransformer<T>

Returns:

Nordsieck transformer for the specified field and number of steps
getInstance
(final Field<T>
field to which the time and state vector elements belong
field
,
final int
number of steps of the multistep method (excluding the one being computed)
nSteps
)

Get the Nordsieck transformer for a given field and number of steps.

public Array2DRowFieldMatrix<T>

Returns:

Nordieck vector at start of first step (h2/2 y''n, h3/6 y'''n ... hk/k! y(k)n)
initializeHighOrderDerivatives
(final T
step size to use for scaling
h
,
final T[]
first steps times
t
,
final T[][]
first steps states
y
,
final T[][]
first steps derivatives
yDot
)

Initialize the high order scaled derivatives at step start.

public Array2DRowFieldMatrix<T>

Returns:

updated high order derivatives
updateHighOrderDerivativesPhase1
(final Array2DRowFieldMatrix<T>
high order scaled derivatives (h2/2 y'', ... hk/k! y(k))
highOrder
)

Update the high order scaled derivatives for Adams integrators (phase 1).

public void
updateHighOrderDerivativesPhase2(final T[]
first order scaled derivatives at step start
start
,
final T[]
first order scaled derivatives at step end
end
,
final Array2DRowFieldMatrix<T>
high order scaled derivatives, will be modified (h2/2 y'', ... hk/k! y(k))
highOrder
)

Update the high order scaled derivatives Adams integrators (phase 2).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

c1back to summary
private final T[] c1

Update coefficients of the higher order derivatives wrt y'.

CACHEback to summary
private static final Map<Integer, Map<Field<? extends RealFieldElement<?>>, AdamsNordsieckFieldTransformer<? extends RealFieldElement<?>>>> CACHE

Cache for already computed coefficients.

fieldback to summary
private final Field<T> field

Field to which the time and state vector elements belong.

updateback to summary
private final Array2DRowFieldMatrix<T> update

Update matrix for the higher order derivatives h2/2 y'', h3/6 y''' ...

Constructor Detail

AdamsNordsieckFieldTransformerback to summary
private AdamsNordsieckFieldTransformer(final Field<T> field, final int n)

Simple constructor.

Parameters
field:Field<T>

field to which the time and state vector elements belong

n:int

number of steps of the multistep method (excluding the one being computed)

Method Detail

buildPback to summary
private FieldMatrix<T> buildP(final int rows)

Build the P matrix.

The P matrix general terms are shifted (j+1) (-i)j terms with i being the row number starting from 1 and j being the column number starting from 1:

       [  -2   3   -4    5  ... ]
       [  -4  12  -32   80  ... ]
  P =  [  -6  27 -108  405  ... ]
       [  -8  48 -256 1280  ... ]
       [          ...           ]

Parameters
rows:int

number of rows of the matrix

Returns:FieldMatrix<T>

P matrix

getInstanceback to summary
public static <T extends RealFieldElement<T>> AdamsNordsieckFieldTransformer<T> getInstance(final Field<T> field, final int nSteps)

Get the Nordsieck transformer for a given field and number of steps.

Parameters
<T>
the type of the field elements
field:Field<T>

field to which the time and state vector elements belong

nSteps:int

number of steps of the multistep method (excluding the one being computed)

Returns:AdamsNordsieckFieldTransformer<T>

Nordsieck transformer for the specified field and number of steps

Annotations
@SuppressWarnings:unchecked
initializeHighOrderDerivativesback to summary
public Array2DRowFieldMatrix<T> initializeHighOrderDerivatives(final T h, final T[] t, final T[][] y, final T[][] yDot)

Initialize the high order scaled derivatives at step start.

Parameters
h:T

step size to use for scaling

t:T[]

first steps times

y:T[][]

first steps states

yDot:T[][]

first steps derivatives

Returns:Array2DRowFieldMatrix<T>

Nordieck vector at start of first step (h2/2 y''n, h3/6 y'''n ... hk/k! y(k)n)

updateHighOrderDerivativesPhase1back to summary
public Array2DRowFieldMatrix<T> updateHighOrderDerivativesPhase1(final Array2DRowFieldMatrix<T> highOrder)

Update the high order scaled derivatives for Adams integrators (phase 1).

The complete update of high order derivatives has a form similar to:

rn+1 = (s1(n) - s1(n+1)) P-1 u + P-1 A P rn
this method computes the P-1 A P rn part.

Parameters
highOrder:Array2DRowFieldMatrix<T>

high order scaled derivatives (h2/2 y'', ... hk/k! y(k))

Returns:Array2DRowFieldMatrix<T>

updated high order derivatives

See Also
updateHighOrderDerivativesPhase2(RealFieldElement[], RealFieldElement[], Array2DRowFieldMatrix)
updateHighOrderDerivativesPhase2back to summary
public void updateHighOrderDerivativesPhase2(final T[] start, final T[] end, final Array2DRowFieldMatrix<T> highOrder)

Update the high order scaled derivatives Adams integrators (phase 2).

The complete update of high order derivatives has a form similar to:

rn+1 = (s1(n) - s1(n+1)) P-1 u + P-1 A P rn
this method computes the (s1(n) - s1(n+1)) P-1 u part.

Phase 1 of the update must already have been performed.

Parameters
start:T[]

first order scaled derivatives at step start

end:T[]

first order scaled derivatives at step end

highOrder:Array2DRowFieldMatrix<T>

high order scaled derivatives, will be modified (h2/2 y'', ... hk/k! y(k))

See Also
updateHighOrderDerivativesPhase1(Array2DRowFieldMatrix)