Class SchurTransformer
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Internal data structure holding the current shift information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RealMatrix
Cached value of P.private RealMatrix
Cached value of PT.private RealMatrix
Cached value of T.private final double
Epsilon criteria taken from JAMA code (originally was 2^-52).private final double[][]
P matrix.private final double[][]
T matrix.private static final int
Maximum allowed iterations for convergence of the transformation. -
Constructor Summary
ConstructorsConstructorDescriptionSchurTransformer
(RealMatrix matrix) Build the transformation to Schur form of a general real matrix. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
computeShift
(int l, int idx, int iteration, SchurTransformer.ShiftInfo shift) Compute the shift for the current iteration.private int
findSmallSubDiagonalElement
(int startIdx, double norm) Find the first small sub-diagonal element and returns its index.private double
getNorm()
Computes the L1 norm of the (quasi-)triangular matrix T.getP()
Returns the matrix P of the transform.getPT()
Returns the transpose of the matrix P of the transform.getT()
Returns the quasi-triangular Schur matrix T of the transform.private int
initQRStep
(int il, int iu, SchurTransformer.ShiftInfo shift, double[] hVec) Initialize the householder vectors for the QR step.private void
performDoubleQRStep
(int il, int im, int iu, SchurTransformer.ShiftInfo shift, double[] hVec) Perform a double QR step involving rows l:idx and columns m:nprivate void
Transform original matrix to Schur form.
-
Field Details
-
MAX_ITERATIONS
private static final int MAX_ITERATIONSMaximum allowed iterations for convergence of the transformation.- See Also:
-
matrixP
private final double[][] matrixPP matrix. -
matrixT
private final double[][] matrixTT matrix. -
cachedP
Cached value of P. -
cachedT
Cached value of T. -
cachedPt
Cached value of PT. -
epsilon
private final double epsilonEpsilon criteria taken from JAMA code (originally was 2^-52).
-
-
Constructor Details
-
SchurTransformer
SchurTransformer(RealMatrix matrix) Build the transformation to Schur form of a general real matrix.- Parameters:
matrix
- matrix to transform- Throws:
NonSquareMatrixException
- if the matrix is not square
-
-
Method Details
-
getP
Returns the matrix P of the transform.P is an orthogonal matrix, i.e. its inverse is also its transpose.
- Returns:
- the P matrix
-
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:
- the transpose of the P matrix
-
getT
Returns the quasi-triangular Schur matrix T of the transform.- Returns:
- the T matrix
-
transform
private void transform()Transform original matrix to Schur form.- Throws:
MaxCountExceededException
- if the transformation does not converge
-
getNorm
private double getNorm()Computes the L1 norm of the (quasi-)triangular matrix T.- Returns:
- the L1 norm of matrix T
-
findSmallSubDiagonalElement
private int findSmallSubDiagonalElement(int startIdx, double norm) Find the first small sub-diagonal element and returns its index.- Parameters:
startIdx
- the starting index for the searchnorm
- the L1 norm of the matrix- Returns:
- the index of the first small sub-diagonal element
-
computeShift
Compute the shift for the current iteration.- Parameters:
l
- the index of the small sub-diagonal elementidx
- the current eigenvalue indexiteration
- the current iterationshift
- holder for shift information
-
initQRStep
Initialize the householder vectors for the QR step.- Parameters:
il
- the index of the small sub-diagonal elementiu
- the current eigenvalue indexshift
- shift information holderhVec
- the initial houseHolder vector- Returns:
- the start index for the QR step
-
performDoubleQRStep
private void performDoubleQRStep(int il, int im, int iu, SchurTransformer.ShiftInfo shift, double[] hVec) Perform a double QR step involving rows l:idx and columns m:n- Parameters:
il
- the index of the small sub-diagonal elementim
- the start index for the QR stepiu
- the current eigenvalue indexshift
- shift information holderhVec
- the initial houseHolder vector
-