Class DecompositionFactory_FDRM


  • public class DecompositionFactory_FDRM
    extends java.lang.Object

    Contains operations related to creating and evaluating the quality of common matrix decompositions. Except in specialized situations, matrix decompositions should be instantiated from this factory instead of being directly constructed. Low level implementations are more prone to changes and new algorithms will be automatically placed here.

    Several functions are also provided to evaluate the quality of a decomposition. This is provided as a way to sanity check a decomposition. Often times a significant error in a decomposition will result in a poor (larger) quality value. Typically a quality value of around 1e-15 means it is within machine precision.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.ejml.interfaces.decomposition.CholeskyDecomposition_F32<org.ejml.data.FMatrixRMaj> chol​(boolean lower)
      Returns a CholeskyDecomposition_F32 that isn't specialized for any specific matrix size.
      static org.ejml.interfaces.decomposition.CholeskyDecomposition_F32<org.ejml.data.FMatrixRMaj> chol​(int matrixSize, boolean lower)
      Returns a CholeskyDecomposition_F32 that has been optimized for the specified matrix size.
      static org.ejml.interfaces.decomposition.CholeskyLDLDecomposition_F32<org.ejml.data.FMatrixRMaj> cholLDL()  
      static org.ejml.interfaces.decomposition.CholeskyLDLDecomposition_F32<org.ejml.data.FMatrixRMaj> cholLDL​(int matrixSize)
      Returns a CholeskyDecompositionLDL_FDRM that has been optimized for the specified matrix size.
      static <T extends org.ejml.data.FMatrix>
      boolean
      decomposeSafe​(org.ejml.interfaces.decomposition.DecompositionInterface<T> decomp, T M)
      A simple convinience function that decomposes the matrix but automatically checks the input ti make sure is not being modified.
      static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(boolean needVectors)  
      static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(boolean computeVectors, boolean isSymmetric)  
      static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(int matrixSize, boolean needVectors)
      Returns an EigenDecomposition that has been optimized for the specified matrix size.
      static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(int matrixSize, boolean computeVectors, boolean isSymmetric)
      Returns an EigenDecomposition which is specialized for symmetric matrices or the general problem.
      static org.ejml.interfaces.decomposition.LUDecomposition_F32<org.ejml.data.FMatrixRMaj> lu()  
      static org.ejml.interfaces.decomposition.LUDecomposition_F32<org.ejml.data.FMatrixRMaj> lu​(int numRows, int numCol)
      Returns a LUDecomposition that has been optimized for the specified matrix size.
      static org.ejml.interfaces.decomposition.QRDecomposition<org.ejml.data.FMatrixRMaj> qr()  
      static org.ejml.interfaces.decomposition.QRDecomposition<org.ejml.data.FMatrixRMaj> qr​(int numRows, int numCols)
      Returns a QRDecomposition that has been optimized for the specified matrix size.
      static org.ejml.interfaces.decomposition.QRPDecomposition_F32<org.ejml.data.FMatrixRMaj> qrp()  
      static org.ejml.interfaces.decomposition.QRPDecomposition_F32<org.ejml.data.FMatrixRMaj> qrp​(int numRows, int numCols)
      Returns a QRPDecomposition_F32 that has been optimized for the specified matrix size.
      static float quality​(org.ejml.data.FMatrixRMaj orig, org.ejml.data.FMatrixRMaj U, org.ejml.data.FMatrixRMaj W, org.ejml.data.FMatrixRMaj Vt)  
      static float quality​(org.ejml.data.FMatrixRMaj orig, org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig)
      Computes a metric which measures the the quality of an eigen value decomposition.
      static float quality​(org.ejml.data.FMatrixRMaj orig, org.ejml.interfaces.decomposition.SingularValueDecomposition<org.ejml.data.FMatrixRMaj> svd)
      Computes a metric which measures the the quality of a singular value decomposition.
      static org.ejml.interfaces.decomposition.SingularValueDecomposition_F32<org.ejml.data.FMatrixRMaj> svd​(boolean needU, boolean needV, boolean compact)
      Returns a SingularValueDecomposition that is NOT optimized for any specified matrix size.
      static org.ejml.interfaces.decomposition.SingularValueDecomposition_F32<org.ejml.data.FMatrixRMaj> svd​(int numRows, int numCols, boolean needU, boolean needV, boolean compact)
      Returns a SingularValueDecomposition that has been optimized for the specified matrix size.
      static org.ejml.interfaces.decomposition.TridiagonalSimilarDecomposition_F32<org.ejml.data.FMatrixRMaj> tridiagonal​(int matrixSize)
      Checks to see if the passed in tridiagonal decomposition is of the appropriate type for the matrix of the provided size.
      • Methods inherited from class java.lang.Object

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

      • DecompositionFactory_FDRM

        public DecompositionFactory_FDRM()
    • Method Detail

      • chol

        public static org.ejml.interfaces.decomposition.CholeskyDecomposition_F32<org.ejml.data.FMatrixRMaj> chol​(int matrixSize,
                                                                                                                  boolean lower)

        Returns a CholeskyDecomposition_F32 that has been optimized for the specified matrix size.

        Parameters:
        matrixSize - Number of rows and columns that the returned decomposition is optimized for.
        lower - should a lower or upper triangular matrix be used. If not sure set to true.
        Returns:
        A new CholeskyDecomposition.
      • chol

        public static org.ejml.interfaces.decomposition.CholeskyDecomposition_F32<org.ejml.data.FMatrixRMaj> chol​(boolean lower)
        Returns a CholeskyDecomposition_F32 that isn't specialized for any specific matrix size.
        Parameters:
        lower - should a lower or upper triangular matrix be used. If not sure set to true.
        Returns:
        A new CholeskyDecomposition.
      • cholLDL

        public static org.ejml.interfaces.decomposition.CholeskyLDLDecomposition_F32<org.ejml.data.FMatrixRMaj> cholLDL​(int matrixSize)

        Returns a CholeskyDecompositionLDL_FDRM that has been optimized for the specified matrix size.

        Parameters:
        matrixSize - Number of rows and columns that the returned decomposition is optimized for.
        Returns:
        CholeskyLDLDecomposition_F32
      • cholLDL

        public static org.ejml.interfaces.decomposition.CholeskyLDLDecomposition_F32<org.ejml.data.FMatrixRMaj> cholLDL()
      • lu

        public static org.ejml.interfaces.decomposition.LUDecomposition_F32<org.ejml.data.FMatrixRMaj> lu​(int numRows,
                                                                                                          int numCol)

        Returns a LUDecomposition that has been optimized for the specified matrix size.

        Parameters:
        numRows - Shape of the matrix that the code should be targeted towards. Does not need to be exact.
        numCol - Shape of the matrix that the code should be targeted towards. Does not need to be exact.
        Returns:
        LUDecomposition
      • lu

        public static org.ejml.interfaces.decomposition.LUDecomposition_F32<org.ejml.data.FMatrixRMaj> lu()
      • svd

        public static org.ejml.interfaces.decomposition.SingularValueDecomposition_F32<org.ejml.data.FMatrixRMaj> svd​(int numRows,
                                                                                                                      int numCols,
                                                                                                                      boolean needU,
                                                                                                                      boolean needV,
                                                                                                                      boolean compact)

        Returns a SingularValueDecomposition that has been optimized for the specified matrix size. For improved performance only the portion of the decomposition that the user requests will be computed.

        Parameters:
        numRows - Number of rows the returned decomposition is optimized for.
        numCols - Number of columns that the returned decomposition is optimized for.
        needU - Should it compute the U matrix. If not sure set to true.
        needV - Should it compute the V matrix. If not sure set to true.
        compact - Should it compute the SVD in compact form. If not sure set to false.
        Returns:
        SVD
      • svd

        public static org.ejml.interfaces.decomposition.SingularValueDecomposition_F32<org.ejml.data.FMatrixRMaj> svd​(boolean needU,
                                                                                                                      boolean needV,
                                                                                                                      boolean compact)
        Returns a SingularValueDecomposition that is NOT optimized for any specified matrix size.
        Parameters:
        needU - Should it compute the U matrix. If not sure set to true.
        needV - Should it compute the V matrix. If not sure set to true.
        compact - Should it compute the SVD in compact form. If not sure set to false.
        Returns:
        SVD
      • qr

        public static org.ejml.interfaces.decomposition.QRDecomposition<org.ejml.data.FMatrixRMaj> qr​(int numRows,
                                                                                                      int numCols)

        Returns a QRDecomposition that has been optimized for the specified matrix size.

        Parameters:
        numRows - Number of rows the returned decomposition is optimized for.
        numCols - Number of columns that the returned decomposition is optimized for.
        Returns:
        QRDecomposition
      • qr

        public static org.ejml.interfaces.decomposition.QRDecomposition<org.ejml.data.FMatrixRMaj> qr()
      • qrp

        public static org.ejml.interfaces.decomposition.QRPDecomposition_F32<org.ejml.data.FMatrixRMaj> qrp​(int numRows,
                                                                                                            int numCols)

        Returns a QRPDecomposition_F32 that has been optimized for the specified matrix size.

        Parameters:
        numRows - Number of rows the returned decomposition is optimized for.
        numCols - Number of columns that the returned decomposition is optimized for.
        Returns:
        QRPDecomposition_F32
      • qrp

        public static org.ejml.interfaces.decomposition.QRPDecomposition_F32<org.ejml.data.FMatrixRMaj> qrp()
      • eig

        public static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(int matrixSize,
                                                                                                              boolean needVectors)

        Returns an EigenDecomposition that has been optimized for the specified matrix size. If the input matrix is symmetric within tolerance then the symmetric algorithm will be used, otherwise a general purpose eigenvalue decomposition is used.

        Parameters:
        matrixSize - Number of rows and columns that the returned decomposition is optimized for.
        needVectors - Should eigenvectors be computed or not. If not sure set to true.
        Returns:
        A new EigenDecomposition
      • eig

        public static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(boolean needVectors)
      • eig

        public static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(int matrixSize,
                                                                                                              boolean computeVectors,
                                                                                                              boolean isSymmetric)

        Returns an EigenDecomposition which is specialized for symmetric matrices or the general problem.

        Parameters:
        matrixSize - Number of rows and columns that the returned decomposition is optimized for.
        computeVectors - Should it compute the eigenvectors or just eigenvalues.
        isSymmetric - If true then the returned algorithm is specialized only for symmetric matrices, if false then a general purpose algorithm is returned.
        Returns:
        EVD for any matrix.
      • eig

        public static org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig​(boolean computeVectors,
                                                                                                              boolean isSymmetric)
      • quality

        public static float quality​(org.ejml.data.FMatrixRMaj orig,
                                    org.ejml.interfaces.decomposition.SingularValueDecomposition<org.ejml.data.FMatrixRMaj> svd)

        Computes a metric which measures the the quality of a singular value decomposition. If a value is returned that is close to or smaller than 1e-15 then it is within machine precision.

        SVD quality is defined as:

        Quality = || A - U W VT|| / || A ||
        where A is the original matrix , U W V is the decomposition, and ||A|| is the norm-f of A.

        Parameters:
        orig - The original matrix which was decomposed. Not modified.
        svd - The decomposition after processing 'orig'. Not modified.
        Returns:
        The quality of the decomposition.
      • quality

        public static float quality​(org.ejml.data.FMatrixRMaj orig,
                                    org.ejml.data.FMatrixRMaj U,
                                    org.ejml.data.FMatrixRMaj W,
                                    org.ejml.data.FMatrixRMaj Vt)
      • quality

        public static float quality​(org.ejml.data.FMatrixRMaj orig,
                                    org.ejml.interfaces.decomposition.EigenDecomposition_F32<org.ejml.data.FMatrixRMaj> eig)

        Computes a metric which measures the the quality of an eigen value decomposition. If a value is returned that is close to or smaller than 1e-15 then it is within machine precision.

        EVD quality is defined as:

        Quality = ||A*V - V*D|| / ||A*V||.

        Parameters:
        orig - The original matrix. Not modified.
        eig - EVD of the original matrix. Not modified.
        Returns:
        The quality of the decomposition.
      • tridiagonal

        public static org.ejml.interfaces.decomposition.TridiagonalSimilarDecomposition_F32<org.ejml.data.FMatrixRMaj> tridiagonal​(int matrixSize)
        Checks to see if the passed in tridiagonal decomposition is of the appropriate type for the matrix of the provided size. Returns the same instance or a new instance.
        Parameters:
        matrixSize - Number of rows and columns that the returned decomposition is optimized for.
      • decomposeSafe

        public static <T extends org.ejml.data.FMatrix> boolean decomposeSafe​(org.ejml.interfaces.decomposition.DecompositionInterface<T> decomp,
                                                                              T M)
        A simple convinience function that decomposes the matrix but automatically checks the input ti make sure is not being modified.
        Type Parameters:
        T - Matrix type.
        Parameters:
        decomp - Decomposition which is being wrapped
        M - THe matrix being decomposed.
        Returns:
        If the decomposition was successful or not.