Package linalg

Class Decompose

java.lang.Object
linalg.Decompose

public class Decompose extends Object
This class provided support for several decompositions of real or complex matrices.

Supported Decompositions:
- LU Decomposition
- LUP Decomposition
- LUPQ Decomposition
- LDU Decomposition
- QR Decomposition
- Cholesky Decomposition
- Complex Schur Decomposition
- Real Schur Decomposition
- Optional Real or Complex Schur Decomposition
// TODO: Add Hessenburg decomposition. i.e. A=PHP*
  • Method Summary

    Modifier and Type
    Method
    Description
    static Matrix[]
    Computes the Cholesky decomposition of a Hermation, positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose.
    static Matrix[]
    LDU​(Matrix A)
    Decomposes a square matrix A into a Lower triangular matrix L, a diagonal matrix D, and an upper triangular matrix U such that A = LDU.
    static Matrix[]
    LU​(Matrix A)
    Factors a square matrix into a lower triangular matrix, L, and an upper triangular matrix, U, such that A = L*U.
    static Matrix[]
    LUP​(Matrix A)
    Factors a square matrix into a lower triangular matrix, L, and an upper triangular matrix, U using row swaps represented by a Matrix pivot matrix P such that PA = LU where P is the permutation matrix describing row swaps in A during partial pivoting.
    static Matrix[]
    LUPQ​(Matrix A)
    Factors a square matrix A into a lower triangular matrix, L, and an upper triangular matrix, U using row and column swaps represented by the permutation matrices P and Q such that PAQ = LU where P is the permutation matrix describing row swaps in A and Q is the permutation matrix describing column swaps in A.
    static Matrix[]
    QR​(Matrix A)
    Computes the QR decomposition of a matrix A such that A=QR, Q is an orthogonal matrix and R is an upper triangular matrix.
    static Matrix[]
    QR​(Matrix A, boolean countHouseholder)
    Computes the QR decomposition of a matrix A such that A=QR, Q is an orthogonal matrix and R is an upper triangular matrix.
    static Matrix[]
    schur​(Matrix A)
    Computes the complex Schur decomposition of this matrix.
    static Matrix[]
    schur​(Matrix A, boolean complex)
    Computes the real or complex Schur decomposition of this matrix.
    static Matrix[]
    Computes the real Schur decomposition of this matrix.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • LU

      public static Matrix[] LU(Matrix A)
      Factors a square matrix into a lower triangular matrix, L, and an upper triangular matrix, U, such that A = L*U.
      Note: This method does not use partial pivoting. To use partial pivoting see one of the following

      - LUP(Matrix A)
      - LUPQ(Matrix A)
      Also see LDU(Matrix A)
      Parameters:
      A - - Matrix to decompose.
      Returns:
      An array of matrices representing LU decomposition using NO pivoting. The array contains in order [L, U]
    • LUP

      public static Matrix[] LUP(Matrix A)
      Factors a square matrix into a lower triangular matrix, L, and an upper triangular matrix, U using row swaps represented by a Matrix pivot matrix P such that PA = LU where P is the permutation matrix describing row swaps in A during partial pivoting.

      Also see
      - LU(Matrix A)
      - LUPQ(Matrix A)
      - LDU(Matrix A)
      Parameters:
      A - - Matrix to decompose.
      Returns:
      An array of matrices representing LU decomposition using partial pivoting. The array contains in order [L, U, P]
    • LUPQ

      public static Matrix[] LUPQ(Matrix A)
      Factors a square matrix A into a lower triangular matrix, L, and an upper triangular matrix, U using row and column swaps represented by the permutation matrices P and Q such that PAQ = LU where P is the permutation matrix describing row swaps in A and Q is the permutation matrix describing column swaps in A.

      Also see
      - LU(Matrix A) for LU decomposition with NO pivoting
      - LUP(Matrix A) for LU decomposition using partial pivoting.
      - LDU(Matrix A)
      Parameters:
      A - - Matrix to decompose.
      Returns:
      An array of matrices representing LU decomposition using full pivoting. The array contains in order [L, U, P, Q]
    • LDU

      public static Matrix[] LDU(Matrix A)
      Decomposes a square matrix A into a Lower triangular matrix L, a diagonal matrix D, and an upper triangular matrix U such that A = LDU. - LU(Matrix A) for LU decomposition with NO pivoting - LUP(Matrix A) for LU decomposition using partial pivoting. - LUPQ(Matrix A) for LU decomposition using full pivoting
      Parameters:
      A - - Matrix to decompose.
      Returns:
      Returns an array of matrices containing in order, L, D, and U.
    • QR

      public static Matrix[] QR(Matrix A)
      Computes the QR decomposition of a matrix A such that A=QR, Q is an orthogonal matrix and R is an upper triangular matrix.

      If you would like to know the number of householder reflectors used in the QR decomposition, see QR(Matrix A, boolean countHouseholder)
      Parameters:
      A - - a rectangular matrix with linearly independent columns.
      Returns:
      An array of matrices of length 2 containing, in order, Q and R.
    • QR

      public static Matrix[] QR(Matrix A, boolean countHouseholder)
      Computes the QR decomposition of a matrix A such that A=QR, Q is an orthogonal matrix and R is an upper triangular matrix.

      If you are not interested in knowing the number of householder reflectors used in the QR decomposition, see QR(Matrix A)
      Parameters:
      A - - a rectangular matrix with linearly independent columns.
      countHouseholder -
      Returns:
      An array of matrices of length 2 or 3. The first and second matrix are always Q and R respectively. If countHouseholder flag is true, then a third 1-by-1 matrix containing the number of Householder reflectors used will also be returned.
    • cholesky

      public static Matrix[] cholesky(Matrix A)
      Computes the Cholesky decomposition of a Hermation, positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose. This is similar to the LU decomposition with the special requirement that L=U* where U* is the conjugate transpose of U.
      Parameters:
      A - - A hermation, positive-definite matrix to be decomposed.
      Returns:
      A matrix array containing in order a lower triangular matrix and its conjugate transpose.
    • schur

      public static Matrix[] schur(Matrix A)
      Computes the complex Schur decomposition of this matrix. That is decomposes a matrix A such that A = UTUH where U is a unitary matrix (i.e. UUH=I), and T is an upper triangular matrix which contains the corresponding eigenvalues of A along its diagonal.

      Also see schurReal(Matrix A) which defaults to the real Schur decomposition and schur(Matrix A, boolean complex) for optional real or complex Schur decomposition.
      Parameters:
      A - - Matrix to decompose
      Returns:
      An array of matrices of length three containing in order [U, T, UH].
    • schur

      public static Matrix[] schur(Matrix A, boolean complex)
      Computes the real or complex Schur decomposition of this matrix. That is decomposes a matrix A such that A = UTUH where U is a unitary matrix (i.e. UUH=I). In the complex Schur decomposition, T is an upper triangular matrix which contains the corresponding eigenvalues of A along its diagonal. In the real Schur decomposition, T is a block upper diagonal matrix containing real eigenvalues of A along the diagonal and representing any complex conjugate pair eigenvalues as a real 2-by-2 matrix. The eigenvalues of this 2-by-2 matrix are the complex conjugate eigenvalues of A.

      Also see schur(Matrix A) which defaults to the complex Schur decomposition and schurReal(Matrix A) which defaults to the real Schur decomposition.
      Parameters:
      A - - Matrix to decompose
      complex - - Flag to compute real or complex Schur decomposition. If true, the complex Schur decomposition will be computed. If false the real Schur decomposition will be computed.
      Returns:
      An array of matrices of length two containing in order [U, T, UH].
    • schurReal

      public static Matrix[] schurReal(Matrix A)
      Computes the real Schur decomposition of this matrix. That is decomposes a matrix A such that A = UTUH where U is a unitary matrix (i.e. UHU=I) and T is a block upper diagonal matrix containing real eigenvalues of A along the diagonal and representing any complex conjugate pair eigenvalues as a real 2-by-2 matrix. The eigenvalues of this 2-by-2 matrix are the complex conjugate eigenvalues of A.

      Also see schur(Matrix A) which defaults to the complex Schur decomposition and schur(Matrix A, boolean complex) for optional real or complex Schur decomposition.
      Parameters:
      A - - Matrix to decompose
      Returns:
      An array of matrices of length two containing in order [U, T, UH].