Documentation of 'jsat.linear.SingularValueDecomposition' Java class
SingularValueDecomposition
jsat.linear

Class SingularValueDecomposition

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class SingularValueDecomposition
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    The Singular Value Decomposition (SVD) of a matrix Am,n = Um,n Σn,n VTn,n , where S is the diagonal matrix of the singular values sorted in descending order and are all non negative.
    The SVD of a matrix has many practical uses, but is expensive to compute.

    Implementation adapted from the Public Domain work of JAMA: A Java Matrix Package
    NOTE: The current implementation has been revised and is now passing all test cases. However, it is still being tested. Use with awareness that it used to be bugged. Note left at revision 597
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double absDet()
      Computes the absolute value of the determinant for the full matrix.
      SingularValueDecomposition clone() 
      double getCondition()
      Returns the condition number of the matrix.
      double[] getInverseSingularValues()
      Returns an array containing the inverse singular values.
      double[] getInverseSingularValues(double tol)
      Returns an array containing the inverse singular values.
      double getNorm2()
      Returns the 2 norm of the matrix, which is the maximal singular value.
      double getPseudoDet()
      Computes the pseudo determinant of the matrix, which corresponds to absolute value of the determinant of the full rank square sub matrix that contains all non zero singular values.
      double getPseudoDet(double tol)
      Computes the pseudo determinant of the matrix, which corresponds to absolute value of the determinant of the full rank square sub matrix that contains all non singular values > tol.
      Matrix getPseudoInverse()
      Returns the Moore–Penrose pseudo inverse of the matrix.
      Matrix getPseudoInverse(double tol)
      Returns the Moore–Penrose pseudo inverse of the matrix.
      int getRank()
      Returns the numerical rank of the matrix.
      int getRank(double tol)
      Returns the numerical rank of the matrix.
      Matrix getS()
      Returns the diagonal matrix S such that the SVD product results in the original matrix.
      double[] getSingularValues()
      Returns a copy of the sorted array of the singular values, include the near zero ones.
      Matrix getU()
      Returns the backing matrix U of the SVD.
      Matrix getV()
      Returns the backing matrix V of the SVD.
      boolean isFullRank()
      Indicates whether or not the input matrix was of full rank, full rank matrices are more numerically stable.
      Matrix solve(Matrix B)
      Solves the linear system of equations for A x = B by using the equation
      x = A-1 B = V S-1 UT B
      When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
      Matrix solve(Matrix b, java.util.concurrent.ExecutorService threadpool)
      Solves the linear system of equations for A x = B by using the equation
      x = A-1 B = V S-1 UT B
      When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
      Vec solve(Vec b)
      Solves the linear system of equations for A x = b by using the equation
      x = A-1 b = V S-1 UT b
      When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SingularValueDecomposition

        public SingularValueDecomposition(Matrix A)
        Creates a new SVD of the matrix A such that A = U Σ VT. The matrix A will be modified and used as temp space when computing the SVD.
        Parameters:
        A - the matrix to create the SVD of
      • SingularValueDecomposition

        public SingularValueDecomposition(Matrix A,
                                          int maxIterations)
        Creates a new SVD of the matrix A such that A = U Σ VT. The matrix A will be modified and used as temp space when computing the SVD.
        Parameters:
        A - the matrix to create the SVD of
        maxIterations - the maximum number of iterations to perform per singular value till convergence.
      • SingularValueDecomposition

        public SingularValueDecomposition(Matrix U,
                                          Matrix V,
                                          double[] s)
        Sets the values for a SVD explicitly. This is not a copy constructor, and will hold the given values.
        Parameters:
        U - the U matrix of an SVD
        V - the V matrix of an SVD
        s - the singular sorted by magnitude of an SVD
    • Method Detail

      • getU

        public Matrix getU()
        Returns the backing matrix U of the SVD. Do not alter this matrix.
        Returns:
        the matrix U of the SVD
      • getV

        public Matrix getV()
        Returns the backing matrix V of the SVD. Do not later this matrix.
        Returns:
        the matrix V of the SVD
      • getSingularValues

        public double[] getSingularValues()
        Returns a copy of the sorted array of the singular values, include the near zero ones.
        Returns:
        a copy of the sorted array of the singular values, including the near zero ones.
      • getS

        public Matrix getS()
        Returns the diagonal matrix S such that the SVD product results in the original matrix. The diagonal contains the singular values.
        Returns:
        a dense diagonal matrix containing the singular values
      • getNorm2

        public double getNorm2()
        Returns the 2 norm of the matrix, which is the maximal singular value.
        Returns:
        the 2 norm of the matrix
      • getCondition

        public double getCondition()
        Returns the condition number of the matrix. The condition number is a positive measure of the numerical instability of the matrix. The larger the value, the less stable the matrix. For singular matrices, the result is Double.POSITIVE_INFINITY.
        Returns:
        the condition number of the matrix
      • getRank

        public int getRank()
        Returns the numerical rank of the matrix. Near zero values will be ignored.
        Returns:
        the rank of the matrix
      • isFullRank

        public boolean isFullRank()
        Indicates whether or not the input matrix was of full rank, full rank matrices are more numerically stable.
        Returns:
        true if the matrix was of full tank
      • getRank

        public int getRank(double tol)
        Returns the numerical rank of the matrix. Values <= than tol will be ignored.
        Parameters:
        tol - the cut of for singular values
        Returns:
        the rank of the matrix
      • getInverseSingularValues

        public double[] getInverseSingularValues()
        Returns an array containing the inverse singular values. Near zero values are converted to zero.
        Returns:
        an array containing the inverse singular values
      • getInverseSingularValues

        public double[] getInverseSingularValues(double tol)
        Returns an array containing the inverse singular values. Values that are <= tol are converted to zero.
        Parameters:
        tol - the cut of for singular values
        Returns:
        an array containing the inverse singular values
      • getPseudoInverse

        public Matrix getPseudoInverse()
        Returns the Moore–Penrose pseudo inverse of the matrix. The pseudo inverse for a matrix is unique. If a matrix is non singular, the pseudo inverse is the inverse.
        Returns:
        the pseudo inverse of the matrix
      • getPseudoInverse

        public Matrix getPseudoInverse(double tol)
        Returns the Moore–Penrose pseudo inverse of the matrix. The pseudo inverse for a matrix is unique. If a matrix is non singular, the pseudo inverse is the inverse.
        Parameters:
        tol - the tolerance for singular values to ignore
        Returns:
        the pseudo inverse of the matrix
      • getPseudoDet

        public double getPseudoDet()
        Computes the pseudo determinant of the matrix, which corresponds to absolute value of the determinant of the full rank square sub matrix that contains all non zero singular values.
        Returns:
        the pseudo determinant.
      • getPseudoDet

        public double getPseudoDet(double tol)
        Computes the pseudo determinant of the matrix, which corresponds to absolute value of the determinant of the full rank square sub matrix that contains all non singular values > tol.
        Parameters:
        tol - the cut of for singular values
        Returns:
        the pseudo determinant
      • absDet

        public double absDet()
        Computes the absolute value of the determinant for the full matrix.
        Returns:
        abs(determinant)
      • solve

        public Vec solve(Vec b)
        Solves the linear system of equations for A x = b by using the equation
        x = A-1 b = V S-1 UT b
        When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
        Parameters:
        b - the vector to solve for
        Returns:
        the vector that gives the least squares solution to A x = b
      • solve

        public Matrix solve(Matrix B)
        Solves the linear system of equations for A x = B by using the equation
        x = A-1 B = V S-1 UT B
        When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
        Parameters:
        B - the matrix to solve for
        Returns:
        the matrix that gives the least squares solution to A x = B
      • solve

        public Matrix solve(Matrix b,
                            java.util.concurrent.ExecutorService threadpool)
        Solves the linear system of equations for A x = B by using the equation
        x = A-1 B = V S-1 UT B
        When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error.
        Parameters:
        b - the matrix to solve for
        threadpool -
        Returns:
        the matrix that gives the least squares solution to A x = B

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.