Module ojalgo

Class SparseQDLDL

    • Field Detail

      • myD

        private double[] myD
      • myDinv

        private double[] myDinv
      • myPositiveValuesInD

        private int myPositiveValuesInD
    • Constructor Detail

      • SparseQDLDL

        public SparseQDLDL()
    • Method Detail

      • computeEliminationTree

        private static SparseQDLDL.EliminationTree computeEliminationTree​(int n,
                                                                          int[] pointers,
                                                                          int[] indices)
      • ftranD

        private static void ftranD​(double[] inv,
                                   double[] x)
      • ftranL

        private static void ftranL​(int[] pointers,
                                   int[] indices,
                                   double[] values,
                                   double[] x)
      • ftranU

        private static void ftranU​(int[] pointers,
                                   int[] indices,
                                   double[] values,
                                   double[] x)
      • btran

        public void btran​(PhysicalStore<java.lang.Double> arg)
        Description copied from interface: InvertibleFactor
        Backwards-transformation

        Solve [x]T[A] = [b]T (equivalent to [A]T[x] = [b]) by transforming [b] into [x] in-place.

        Specified by:
        btran in interface InvertibleFactor<java.lang.Double>
        Parameters:
        arg - [b] transformed into [x]
      • countSignificant

        public int countSignificant​(double threshold)
        Specified by:
        countSignificant in interface MatrixDecomposition.RankRevealing<java.lang.Double>
        Parameters:
        threshold - Significance limit
        Returns:
        The number of elements in the diagonal matrix that are greater than the threshold
      • factor

        public boolean factor​(R064CSC matrix)
        Requirements on the input matrix and summary of the factorisation semantics:
        • Square.
        • Symmetric, with only the upper/right triangle stored. The lower/left triangle is not ignored; any explicitly stored non-zero entries there will cause the symbolic phase to fail.
        • Sparse (not strictly required, but this implementation is optimised for sparse structure).
        • Quasi-definite for a fully solvable system: during factorisation the diagonal entries D[i] are classified relative to a small, scale-dependent tolerance derived from the largest |D[i]| seen so far and the dimensional epsilon. All D[i] must be classified as positive for isSolvable() to return true.
        The underlying QDLDL-style algorithm will return false if any diagonal entry in D is classified as (numerically) zero. Indefinite or near-singular matrices may still factorise, but will typically yield isSolvable() == false and are not suitable for use as quasi-definite systems when solving or inverting.

        This method performs both the symbolic analysis (elimination tree) and numeric factorisation. For repeated factorisations with identical sparsity patterns and updated values, callers may instead use factor(R064CSC, EliminationTree) together with a cached symbolic tree obtained from #getSymbolic().

      • factor

        public boolean factor​(R064CSC matrix,
                              SparseQDLDL.EliminationTree eTree)
        Convenience for callers that have already computed the symbolic structure for a given sparsity pattern. The caller is responsible for ensuring that the supplied SparseQDLDL.EliminationTree matches the pattern of matrix; behaviour is undefined if they do not.
      • ftran

        public void ftran​(PhysicalStore<java.lang.Double> arg)
        Description copied from interface: InvertibleFactor
        Forward-transformation

        Solve [A][x] = [b] by transforming [b] into [x] in-place.

        Specified by:
        ftran in interface InvertibleFactor<java.lang.Double>
        Parameters:
        arg - [b] transformed into [x]
      • getColDim

        public int getColDim()
        Specified by:
        getColDim in interface Structure2D
        Returns:
        The number of columns
      • getD

        public MatrixStore<java.lang.Double> getD()
        Specified by:
        getD in interface LDL<java.lang.Double>
      • getDeterminant

        public java.lang.Double getDeterminant()
        Determinant of the factorised matrix.

        With no pivoting the determinant is computed as the product of the diagonal entries of D returned by the LDL factorisation. For a quasi-definite input (all diagonal entries classified as positive according to the internal tolerance) isSolvable() is true and the determinant is strictly positive. For general symmetric or indefinite inputs the determinant may be negative or close to zero and should be interpreted with care. If the factorisation has not been computed this method returns NaN.

        Specified by:
        getDeterminant in interface MatrixDecomposition.Determinant<java.lang.Double>
        Specified by:
        getDeterminant in interface Provider2D.Determinant<java.lang.Double>
        Returns:
        The matrix' determinant
      • getRowDim

        public int getRowDim()
        Specified by:
        getRowDim in interface Structure2D
        Returns:
        The number of rows
      • isSolvable

        public boolean isSolvable()
        Description copied from interface: MatrixDecomposition.Solver
        Please note that producing a pseudoinverse and/or a least squares solution is ok! The return value, of this method, is not an indication of if the decomposed matrix is square, has full rank, is postive definite or whatever. It's that in combination with the specific decomposition algorithm's capabilities.
        Specified by:
        isSolvable in interface MatrixDecomposition.Solver<java.lang.Double>
        Overrides:
        isSolvable in class AbstractDecomposition<java.lang.Double,​R064Store>
        Returns:
        true if this matrix decomposition is in a state to be able to deliver an inverse or an equation system solution (with some degree of numerical stability).
      • preallocate

        public PhysicalStore<java.lang.Double> preallocate​(int nbEquations,
                                                           int nbVariables,
                                                           int nbSolutions)
        Specified by:
        preallocate in interface SolverTask<java.lang.Double>
      • solve

        public double[] solve​(double[] b)
        Solve A x = b