Class TriDiagonalTransformer
- java.lang.Object
-
- org.apache.commons.math3.linear.TriDiagonalTransformer
-
class TriDiagonalTransformer extends java.lang.ObjectClass transforming a symmetrical matrix to tridiagonal shape.A symmetrical m × m matrix A can be written as the product of three matrices: A = Q × T × QT with Q an orthogonal matrix and T a symmetrical tridiagonal matrix. Both Q and T are m × m matrices.
This implementation only uses the upper part of the matrix, the part below the diagonal is not accessed at all.
Transformation to tridiagonal shape 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.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description private RealMatrixcachedQCached value of Q.private RealMatrixcachedQtCached value of Qt.private RealMatrixcachedTCached value of T.private double[][]householderVectorsHouseholder vectors.private double[]mainMain diagonal.private double[]secondarySecondary diagonal.
-
Constructor Summary
Constructors Constructor Description TriDiagonalTransformer(RealMatrix matrix)Build the transformation to tridiagonal shape of a symmetrical matrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) double[][]getHouseholderVectorsRef()Get the Householder vectors of the transform.(package private) double[]getMainDiagonalRef()Get the main diagonal elements of the matrix T of the transform.RealMatrixgetQ()Returns the matrix Q of the transform.RealMatrixgetQT()Returns the transpose of the matrix Q of the transform.(package private) double[]getSecondaryDiagonalRef()Get the secondary diagonal elements of the matrix T of the transform.RealMatrixgetT()Returns the tridiagonal matrix T of the transform.private voidtransform()Transform original matrix to tridiagonal form.
-
-
-
Field Detail
-
householderVectors
private final double[][] householderVectors
Householder vectors.
-
main
private final double[] main
Main diagonal.
-
secondary
private final double[] secondary
Secondary diagonal.
-
cachedQ
private RealMatrix cachedQ
Cached value of Q.
-
cachedQt
private RealMatrix cachedQt
Cached value of Qt.
-
cachedT
private RealMatrix cachedT
Cached value of T.
-
-
Constructor Detail
-
TriDiagonalTransformer
TriDiagonalTransformer(RealMatrix matrix)
Build the transformation to tridiagonal shape of a symmetrical matrix.The specified matrix is assumed to be symmetrical without any check. Only the upper triangular part of the matrix is used.
- Parameters:
matrix- Symmetrical matrix to transform.- Throws:
NonSquareMatrixException- if the matrix is not square.
-
-
Method Detail
-
getQ
public RealMatrix getQ()
Returns the matrix Q of the transform.Q is an orthogonal matrix, i.e. its transpose is also its inverse.
- Returns:
- the Q matrix
-
getQT
public RealMatrix getQT()
Returns the transpose of the matrix Q of the transform.Q is an orthogonal matrix, i.e. its transpose is also its inverse.
- Returns:
- the Q matrix
-
getT
public RealMatrix getT()
Returns the tridiagonal matrix T of the transform.- Returns:
- the T matrix
-
getHouseholderVectorsRef
double[][] getHouseholderVectorsRef()
Get the Householder vectors of the transform.Note that since this class is only intended for internal use, it returns directly a reference to its internal arrays, not a copy.
- Returns:
- the main diagonal elements of the B matrix
-
getMainDiagonalRef
double[] getMainDiagonalRef()
Get the main diagonal elements of the matrix T of the transform.Note that since this class is only intended for internal use, it returns directly a reference to its internal arrays, not a copy.
- Returns:
- the main diagonal elements of the T matrix
-
getSecondaryDiagonalRef
double[] getSecondaryDiagonalRef()
Get the secondary diagonal elements of the matrix T of the transform.Note that since this class is only intended for internal use, it returns directly a reference to its internal arrays, not a copy.
- Returns:
- the secondary diagonal elements of the T matrix
-
transform
private void transform()
Transform original matrix to tridiagonal form.Transformation is done using Householder transforms.
-
-