Package org.flag4j.linalg
Class Eigen
java.lang.Object
org.flag4j.linalg.Eigen
This class provides several methods useful for computing eigenvalues and eigenvectors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CNumber[]
get2x2EigenValues
(double a11, double a12, double a21, double a22) Computes the eigenvalues of a 2x2 matrix explicitly.static CVector
get2x2EigenValues
(CMatrix src) Computes the eigenvalues of a 2x2 matrix explicitly.static CVector
get2x2EigenValues
(Matrix src) Computes the eigenvalues of a 2x2 matrix explicitly.static CNumber[]
get2x2EigenValues
(CNumber a11, CNumber a12, CNumber a21, CNumber a22) static CMatrix[]
getEigenPairs
(CMatrix src) Computes the eigenvalues and eigenvectors of a square real matrix.static CMatrix[]
getEigenPairs
(Matrix src) Computes the eigenvalues and eigenvectors of a square real matrix.static CVector
getEigenValues
(CMatrix src) Computes the eigenvalues of a square complex dense matrix.static CVector
getEigenValues
(CMatrix src, long seed) Computes the eigenvalues of a square complex dense matrix.static CVector
getEigenValues
(CMatrix src, long seed, int maxIterationFactor) Computes the eigenvalues of a square complex dense matrix.private static CVector
getEigenValues
(CMatrix src, ComplexSchur schur) Computes the eigenvalues of a square complex dense matrix.static CVector
getEigenValues
(Matrix src) Computes the eigenvalues of a square real dense matrix.static CVector
getEigenValues
(Matrix src, long seed) Computes the eigenvalues of a square real dense matrix.static CVector
getEigenValues
(Matrix src, long seed, int maxIterationFactor) Computes the eigenvalues of a square real dense matrix.private static CVector
getEigenValues
(Matrix src, RealSchur schur) Computes the eigenvalues of a real dense square matrix.static CMatrix
getEigenVectors
(CMatrix src) Computes the eigenvectors of a square real dense matrix.static CMatrix
getEigenVectors
(CMatrix src, long seed) Computes the eigenvectors of a square real dense matrix.static CMatrix
getEigenVectors
(CMatrix src, long seed, int maxIterationFactor) Computes the eigenvectors of a square real dense matrix.private static CMatrix
getEigenVectors
(CMatrix src, ComplexSchur schur) Computes the eigenvectors of a square complex dense matrix.static CMatrix
getEigenVectors
(Matrix src) Computes the eigenvectors of a square real dense matrix.static CMatrix
getEigenVectors
(Matrix src, long seed) Computes the eigenvectors of a square real dense matrix.static CMatrix
getEigenVectors
(Matrix src, long seed, int maxIterationFactor) Computes the eigenvectors of a square real dense matrix.private static CMatrix
getEigenVectors
(Matrix src, RealSchur schur) Computes the eigenvectors of a square real dense matrix.static CMatrix
Computes the eigenvectors of an upper triangular matrix.static Matrix
Computes the eigenvectors of an upper triangular matrix.private static void
makeSystem
(CMatrix T, int j, CMatrix S_hat, CVector r) Constructs the matrix(T - lambda*I)[0:j][0:j]
for use in computing the eigenvalue of the upper triangular matrixT
associated with the jth eigenvaluelambda
.private static void
makeSystem
(Matrix T, int j, Matrix S_hat, Vector r) Constructs the matrix(T - lambda*I)[0:j][0:j]
for use in computing the eigenvalue of the upper triangular matrixT
associated with the jth eigenvaluelambda
.
-
Constructor Details
-
Eigen
public Eigen()
-
-
Method Details
-
get2x2EigenValues
-
get2x2EigenValues
Computes the eigenvalues of a 2x2 matrix explicitly.- Parameters:
a11
- First entry in matrix (at index (0, 0)).a12
- Second entry in matrix (at index (0, 1)).a21
- Third entry in matrix (at index (1, 0)).a22
- Fourth entry in matrix (at index (1, 1)).- Returns:
- A complex array containing the eigenvalues of the 2x2
src
matrix.
-
get2x2EigenValues
-
get2x2EigenValues
-
getEigenValues
Computes the eigenvalues of a square real dense matrix. For reproducibility seegetEigenValues(Matrix, long)
. If the algorithm fails to converge within the default maximum number of iterations,getEigenValues(Matrix, long, int)
can be used to specify a larger number of iterations to attempt.- Parameters:
src
- The matrix to compute the eigenvalues of.- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a square real dense matrix. If the algorithm fails to converge within the default maximum number of iterations,getEigenValues(Matrix, long, int)
can be used to specify a larger number of iterations to attempt.- Parameters:
src
- The matrix to compute the eigenvalues of.seed
- Seed for random shifts used in computing the eigenvalues.- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a square real dense matrix.- Parameters:
src
- The matrix to compute the eigenvalues of.seed
- Seed for random shifts used in computing the eigenvalues.maxIterationFactor
- maximum iteration factor for use in computing the total maximum number of iterations to run theQR
algorithm for during eigenvalue computation. The maximum number of iterations will be computed as:maxIteration = maxIterationFactor * src.numRows;
- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a real dense square matrix.- Parameters:
src
- Matrix to compute eigenvalues of.schur
- Schur decomposer to use in the eigenvalue computation.- Returns:
- The eigenvalues of the
src
matrix stored in a complex vector (CVector
).
-
getEigenValues
Computes the eigenvalues of a square complex dense matrix. For reproducibility seegetEigenValues(CMatrix, long)
.- Parameters:
src
- The matrix to compute the eigenvalues of.- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a square complex dense matrix.- Parameters:
src
- The matrix to compute the eigenvalues of.seed
- Seed for random shifts used in computing the eigenvalues. This allows for reproducibility despite randomness in the eigenvalue computation algorithm.- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a square complex dense matrix.- Parameters:
src
- The matrix to compute the eigenvalues of.seed
- Seed for random shifts used in computing the eigenvalues.maxIterationFactor
- maximum iteration factor for use in computing the total maximum number of iterations to run theQR
algorithm for during eigenvalue computation. The maximum number of iterations will be computed as:maxIteration = maxIterationFactor * src.numRows;
- Returns:
- The eigenvalues of the
src
matrix. - See Also:
-
getEigenValues
Computes the eigenvalues of a square complex dense matrix.- Parameters:
src
- The matrix to compute the eigenvalues of.schur
- The schur decomposer to use in the eigenvalue decomposition.- Returns:
- The eigenvalues of the
src
matrix.
-
getEigenVectors
-
getEigenVectors
Computes the eigenvectors of a square real dense matrix. This method accepts a seed for the random number generator involved in the algorithm for computing the eigenvalues. This allows for reproducibility between calls.- Parameters:
src
- The matrix to compute the eigenvectors of.seed
- Seed for random shifts used in the algorithm to compute the eigenvalues of.- Returns:
- A matrix containing the eigenvectors of
src
as its columns. - See Also:
-
getEigenVectors
Computes the eigenvectors of a square real dense matrix. This method accepts a seed for the random number generator involved in the algorithm for computing the eigenvalues. This allows for reproducibility between calls.- Parameters:
src
- The matrix to compute the eigenvectors of.seed
- Seed for random shifts used in the algorithm to compute the eigenvalues of.maxIterationFactor
- maximum iteration factor for use in computing the total maximum number of iterations to run theQR
algorithm for during eigenvalue computation. The maximum number of iterations will be computed as:maxIteration = maxIterationFactor * src.numRows;
- Returns:
- A matrix containing the eigenvectors of
src
as its columns. - See Also:
-
getEigenVectors
Computes the eigenvectors of a square real dense matrix.- Parameters:
src
- The matrix to compute the eigenvectors of.schur
- Schur decomposer to use in the computation of the eigenvectors.- Returns:
- A matrix containing the eigenvectors of
src
as its columns.
-
getEigenVectors
-
getEigenVectors
Computes the eigenvectors of a square real dense matrix. This method accepts a seed for the random number generator involved in the algorithm for computing the eigenvalues. This allows for reproducibility between calls.- Parameters:
src
- The matrix to compute the eigenvectors of.seed
- Seed for random shifts used in the algorithm to compute the eigenvalues of.- Returns:
- A matrix containing the eigenvectors of
src
as its columns. - See Also:
-
getEigenVectors
Computes the eigenvectors of a square real dense matrix. This method accepts a seed for the random number generator involved in the algorithm for computing the eigenvalues. This allows for reproducibility between calls.- Parameters:
src
- The matrix to compute the eigenvectors of.seed
- Seed for random shifts used in the algorithm to compute the eigenvalues of.maxIterationFactor
- maximum iteration factor for use in computing the total maximum number of iterations to run theQR
algorithm for during eigenvalue computation. The maximum number of iterations will be computed as:maxIteration = maxIterationFactor * src.numRows;
- Returns:
- A matrix containing the eigenvectors of
src
as its columns. - See Also:
-
getEigenVectors
Computes the eigenvectors of a square complex dense matrix.- Parameters:
src
- The matrix to compute the eigenvectors of.schur
- Schur decomposer to use when computing the eigenvectors.- Returns:
- A matrix containing the eigenvectors of
src
as its columns.
-
getEigenVectorsTriu
-
getEigenVectorsTriu
-
makeSystem
Constructs the matrix(T - lambda*I)[0:j][0:j]
for use in computing the eigenvalue of the upper triangular matrixT
associated with the jth eigenvaluelambda
.- Parameters:
T
- The upper triangular matrix (Assumed to be square).j
- The diagonal index ofT
where the eigenvaluelambda
appears.
-
makeSystem
Constructs the matrix(T - lambda*I)[0:j][0:j]
for use in computing the eigenvalue of the upper triangular matrixT
associated with the jth eigenvaluelambda
.- Parameters:
T
- The upper triangular matrix (Assumed to be square).j
- The diagonal index ofT
where the eigenvaluelambda
appears.
-
getEigenPairs
Computes the eigenvalues and eigenvectors of a square real matrix.- Parameters:
src
- The matrix to compute the eigenvalues and vectors of.- Returns:
- An array containing two matrices. The first matrix has shape
1xsrc.numCols
and contains the eigenvalues of thesrc
matrix. The second matrix has shapesrc.numRowsxsrc.numCols
and contains the eigenvectors of thesrc
matrix as its columns.
-
getEigenPairs
Computes the eigenvalues and eigenvectors of a square real matrix.- Parameters:
src
- The matrix to compute the eigenvalues and vectors of.- Returns:
- An array containing two matrices. The first matrix has shape
1xsrc.numCols
and contains the eigenvalues of thesrc
matrix. The second matrix has shapesrc.numRowsxsrc.numCols
and contains the eigenvectors of thesrc
matrix as its columns.
-