Record Class LU

Record Components:
lu - the LU decomposition matrix.
ipiv - the pivot vector.
info - the information code. If info = 0, the LU decomposition was successful. If info = i > 0, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.info > 0 if the matrix is singular.
All Implemented Interfaces:
Serializable

public record LU(DenseMatrix lu, int[] ipiv, int info) extends Record implements Serializable
The LU decomposition. For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(piv,:) = L*U. If m < n, then L is m-by-m and U is m-by-n.

The LU decomposition with pivoting always exists, even if the matrix is singular. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations if it is not singular. The decomposition can also be used to calculate the determinant.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    LU(DenseMatrix lu, int[] ipiv, int info)
    Creates an instance of a LU record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    det()
    Returns the matrix determinant.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the info record component.
    Returns the inverse of matrix.
    int[]
    Returns the value of the ipiv record component.
    boolean
    Returns true if the matrix is singular.
    lu()
    Returns the value of the lu record component.
    solve(double[] b)
    Solve A * x = b.
    solve(float[] b)
    Solve A * x = b.
    void
    Solve A * X = B.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LU

      public LU(DenseMatrix lu, int[] ipiv, int info)
      Creates an instance of a LU record class.
      Parameters:
      lu - the value for the lu record component
      ipiv - the value for the ipiv record component
      info - the value for the info record component
  • Method Details

    • isSingular

      public boolean isSingular()
      Returns true if the matrix is singular.
      Returns:
      true if the matrix is singular.
    • det

      public double det()
      Returns the matrix determinant.
      Returns:
      the matrix determinant.
    • inverse

      public DenseMatrix inverse()
      Returns the inverse of matrix. For pseudo inverse, use QRDecomposition.
      Returns:
      the inverse of matrix.
    • solve

      public Vector solve(double[] b)
      Solve A * x = b.
      Parameters:
      b - the right hand side of linear systems.
      Returns:
      the solution vector.
      Throws:
      RuntimeException - when the matrix is singular.
    • solve

      public Vector solve(float[] b)
      Solve A * x = b.
      Parameters:
      b - the right hand side of linear systems.
      Returns:
      the solution vector.
      Throws:
      RuntimeException - when the matrix is singular.
    • solve

      public void solve(DenseMatrix B)
      Solve A * X = B. B will be overwritten with the solution matrix on output.
      Parameters:
      B - the right hand side of linear system. On output, B will be overwritten with the solution matrix.
      Throws:
      RuntimeException - when the matrix is singular.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • lu

      public DenseMatrix lu()
      Returns the value of the lu record component.
      Returns:
      the value of the lu record component
    • ipiv

      public int[] ipiv()
      Returns the value of the ipiv record component.
      Returns:
      the value of the ipiv record component
    • info

      public int info()
      Returns the value of the info record component.
      Returns:
      the value of the info record component