Top Description Inners Fields Constructors Methods
org.apache.commons.math3.linear

pack-priv Class SchurTransformer

extends Object
Class Inheritance
Imports
org.apache.commons.math3.exception.MaxCountExceededException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.FastMath, .Precision

Class transforming a general real matrix to Schur form.

A m × m matrix A can be written as the product of three matrices: A = P × T × PT with P an orthogonal matrix and T an quasi-triangular matrix. Both P and T are m × m matrices.

Transformation to Schur form is often not a goal by itself, but it is an intermediate step in more general decomposition algorithms like eigen decomposition. This class is therefore intended for internal use by the library and is not public. As a consequence of this explicitly limited scope, many methods directly returns references to internal arrays, not copies.

This class is based on the method hqr2 in class EigenvalueDecomposition from the JAMA library.

Since
3.1
See Also
Schur Decomposition - MathWorld, Schur Decomposition - Wikipedia, Householder Transformations

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SchurTransformer.ShiftInfo

Internal data structure holding the current shift information.

Field Summary

Modifier and TypeField and Description
private RealMatrix
cachedP

Cached value of P.

private RealMatrix
cachedPt

Cached value of PT.

private RealMatrix
cachedT

Cached value of T.

private final double
epsilon

Epsilon criteria taken from JAMA code (originally was 2^-52).

private final double[][]
matrixP

P matrix.

private final double[][]
matrixT

T matrix.

private static final int
MAX_ITERATIONS

Maximum allowed iterations for convergence of the transformation.

Constructor Summary

AccessConstructor and Description
pack-priv
SchurTransformer(final RealMatrix
matrix to transform
matrix
)

Build the transformation to Schur form of a general real matrix.

Method Summary

Modifier and TypeMethod and Description
private void
computeShift(final int
the index of the small sub-diagonal element
l
,
final int
the current eigenvalue index
idx
,
final int
the current iteration
iteration
,
final SchurTransformer.ShiftInfo
holder for shift information
shift
)

Compute the shift for the current iteration.

private int

Returns:

the index of the first small sub-diagonal element
findSmallSubDiagonalElement
(final int
the starting index for the search
startIdx
,
final double
the L1 norm of the matrix
norm
)

Find the first small sub-diagonal element and returns its index.

private double

Returns:

the L1 norm of matrix T
getNorm
()

Computes the L1 norm of the (quasi-)triangular matrix T.

public RealMatrix

Returns:

the P matrix
getP
()

Returns the matrix P of the transform.

public RealMatrix

Returns:

the transpose of the P matrix
getPT
()

Returns the transpose of the matrix P of the transform.

public RealMatrix

Returns:

the T matrix
getT
()

Returns the quasi-triangular Schur matrix T of the transform.

private int

Returns:

the start index for the QR step
initQRStep
(int
the index of the small sub-diagonal element
il
,
final int
the current eigenvalue index
iu
,
final SchurTransformer.ShiftInfo
shift information holder
shift
,
double[]
the initial houseHolder vector
hVec
)

Initialize the householder vectors for the QR step.

private void
performDoubleQRStep(final int
the index of the small sub-diagonal element
il
,
final int
the start index for the QR step
im
,
final int
the current eigenvalue index
iu
,
final SchurTransformer.ShiftInfo
shift information holder
shift
,
final double[]
the initial houseHolder vector
hVec
)

Perform a double QR step involving rows l:idx and columns m:n

private void
transform()

Transform original matrix to Schur form.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedPback to summary
private RealMatrix cachedP

Cached value of P.

cachedPtback to summary
private RealMatrix cachedPt

Cached value of PT.

cachedTback to summary
private RealMatrix cachedT

Cached value of T.

epsilonback to summary
private final double epsilon

Epsilon criteria taken from JAMA code (originally was 2^-52).

matrixPback to summary
private final double[][] matrixP

P matrix.

matrixTback to summary
private final double[][] matrixT

T matrix.

MAX_ITERATIONSback to summary
private static final int MAX_ITERATIONS

Maximum allowed iterations for convergence of the transformation.

Constructor Detail

SchurTransformerback to summary
pack-priv SchurTransformer(final RealMatrix matrix)

Build the transformation to Schur form of a general real matrix.

Parameters
matrix:RealMatrix

matrix to transform

Exceptions
NonSquareMatrixException:
if the matrix is not square

Method Detail

computeShiftback to summary
private void computeShift(final int l, final int idx, final int iteration, final SchurTransformer.ShiftInfo shift)

Compute the shift for the current iteration.

Parameters
l:int

the index of the small sub-diagonal element

idx:int

the current eigenvalue index

iteration:int

the current iteration

shift:SchurTransformer.ShiftInfo

holder for shift information

findSmallSubDiagonalElementback to summary
private int findSmallSubDiagonalElement(final int startIdx, final double norm)

Find the first small sub-diagonal element and returns its index.

Parameters
startIdx:int

the starting index for the search

norm:double

the L1 norm of the matrix

Returns:int

the index of the first small sub-diagonal element

getNormback to summary
private double getNorm()

Computes the L1 norm of the (quasi-)triangular matrix T.

Returns:double

the L1 norm of matrix T

getPback to summary
public RealMatrix getP()

Returns the matrix P of the transform.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Returns:RealMatrix

the P matrix

getPTback to summary
public RealMatrix getPT()

Returns the transpose of the matrix P of the transform.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Returns:RealMatrix

the transpose of the P matrix

getTback to summary
public RealMatrix getT()

Returns the quasi-triangular Schur matrix T of the transform.

Returns:RealMatrix

the T matrix

initQRStepback to summary
private int initQRStep(int il, final int iu, final SchurTransformer.ShiftInfo shift, double[] hVec)

Initialize the householder vectors for the QR step.

Parameters
il:int

the index of the small sub-diagonal element

iu:int

the current eigenvalue index

shift:SchurTransformer.ShiftInfo

shift information holder

hVec:double[]

the initial houseHolder vector

Returns:int

the start index for the QR step

performDoubleQRStepback to summary
private void performDoubleQRStep(final int il, final int im, final int iu, final SchurTransformer.ShiftInfo shift, final double[] hVec)

Perform a double QR step involving rows l:idx and columns m:n

Parameters
il:int

the index of the small sub-diagonal element

im:int

the start index for the QR step

iu:int

the current eigenvalue index

shift:SchurTransformer.ShiftInfo

shift information holder

hVec:double[]

the initial houseHolder vector

transformback to summary
private void transform()

Transform original matrix to Schur form.

Exceptions
MaxCountExceededException:
if the transformation does not converge
org.apache.commons.math3.linear back to summary

private Class SchurTransformer.ShiftInfo

extends Object
Class Inheritance

Internal data structure holding the current shift information. Contains variable names as present in the original JAMA code.

Field Summary

Modifier and TypeField and Description
pack-priv double
exShift

Indicates an exceptional shift.

pack-priv double
w

w shift info

pack-priv double
x

x shift info

pack-priv double
y

y shift info

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exShiftback to summary
pack-priv double exShift

Indicates an exceptional shift.

wback to summary
pack-priv double w

w shift info

xback to summary
pack-priv double x

x shift info

yback to summary
pack-priv double y

y shift info

Constructor Detail

ShiftInfoback to summary
private ShiftInfo()