Class TriangularSolver_FSCC

java.lang.Object
org.ejml.sparse.csc.misc.TriangularSolver_FSCC

@Generated("org.ejml.sparse.csc.misc.TriangularSolver_DSCC") public class TriangularSolver_FSCC extends Object
  • Constructor Details

    • TriangularSolver_FSCC

      public TriangularSolver_FSCC()
  • Method Details

    • solveL

      public static void solveL(FMatrixSparseCSC L, float[] x)
      Solves for a lower triangular matrix against a dense matrix. L*x = b
      Parameters:
      L - Lower triangular matrix. Diagonal elements are assumed to be non-zero
      x - (Input) Solution matrix 'b'. (Output) matrix 'x'
    • solveTranL

      public static void solveTranL(FMatrixSparseCSC L, float[] x)
      Solves for the transpose of a lower triangular matrix against a dense matrix. LT*x = b
      Parameters:
      L - Lower triangular matrix. Diagonal elements are assumed to be non-zero
      x - (Input) Solution matrix 'b'. (Output) matrix 'x'
    • solveU

      public static void solveU(FMatrixSparseCSC U, float[] x)
      Solves for an upper triangular matrix against a dense vector. U*x = b
      Parameters:
      U - Upper triangular matrix. Diagonal elements are assumed to be non-zero
      x - (Input) Solution matrix 'b'. (Output) matrix 'x'
    • solveTran

      public static void solveTran(FMatrixSparseCSC G, boolean lower, FMatrixSparseCSC B, FMatrixSparseCSC X, @Nullable @org.jetbrains.annotations.Nullable int[] pinv, @Nullable @Nullable FGrowArray g_x, @Nullable @Nullable IGrowArray g_xi, @Nullable @Nullable IGrowArray g_w)
      Solution to a sparse transposed triangular system with sparse B and sparse X

      GT*X = B

      Parameters:
      G - (Input) Lower or upper triangular matrix. diagonal elements must be non-zero. Not modified.
      lower - true for lower triangular and false for upper
      B - (Input) Matrix. Not modified.
      X - (Output) Solution
      pinv - (Input, Optional) Permutation vector. Maps col j to G. Null if no pivots.
      g_x - (Optional) Storage for workspace.
      g_xi - (Optional) Storage for workspace.
      g_w - (Optional) Storage for workspace.
    • solve

      public static void solve(FMatrixSparseCSC G, boolean lower, FMatrixSparseCSC B, FMatrixSparseCSC X, @Nullable @org.jetbrains.annotations.Nullable int[] pinv, @Nullable @Nullable FGrowArray g_x, @Nullable @Nullable IGrowArray g_xi, @Nullable @Nullable IGrowArray g_w)
      Computes the solution to the triangular system.
      Parameters:
      G - (Input) Lower or upper triangular matrix. diagonal elements must be non-zero. Not modified.
      lower - true for lower triangular and false for upper
      B - (Input) Matrix. Not modified.
      X - (Output) Solution
      pinv - (Input, Optional) Permutation vector. Maps col j to G. Null if no pivots.
      g_x - (Optional) Storage for workspace.
      g_xi - (Optional) Storage for workspace.
      g_w - (Optional) Storage for workspace.
    • solveColB

      public static int solveColB(FMatrixSparseCSC G, boolean lower, FMatrixSparseCSC B, int colB, float[] x, @Nullable @org.jetbrains.annotations.Nullable int[] pinv, @Nullable @Nullable IGrowArray g_xi, int[] w)
      Computes the solution to a triangular system with (optional) pivots. Only a single column in B is solved for. Diagonals in G are assumed to filled in and either the first or last entry for lower or upper triangle, respectively.
      Parameters:
      G - (Input) Lower or upper triangular matrix. diagonal elements must be non-zero and last or first entry in a column. Not modified.
      lower - true for lower triangular and false for upper
      B - (Input) Matrix. Not modified.
      colB - The column in B which is solved for
      x - (Output) Storage for dense solution. length = G.numRows
      pinv - (Input, Optional) Permutation vector. Maps col j to G. Null if no pivots.
      g_xi - (Optional) Storage for workspace. Will contain nonzero pattern. See searchNzRowsInX(FMatrixSparseCSC, FMatrixSparseCSC, int, int[], int[], int[])
      w - Storage for workspace. Must be of length B.numRows*2 or more. First N elements must be zero.
      Returns:
      Return number of zeros in 'x', ignoring cancellations.
    • searchNzRowsInX

      public static int searchNzRowsInX(FMatrixSparseCSC G, FMatrixSparseCSC B, int colB, @Nullable @org.jetbrains.annotations.Nullable int[] pinv, int[] xi, int[] w)

      Determines which elements in 'X' will be non-zero when the system below is solved for.

      G*X = B

      xi will contain a list of ordered row indexes in B which will be modified starting at xi[top] to xi[n-1]. top is the value returned by this function.

      See cs_reach in dsparse library to understand the algorithm. This code follow the spirit but not the details because of differences in the contract.

      Parameters:
      G - (Input) Lower triangular system matrix. Diagonal elements are assumed to be not zero. Not modified.
      B - (Input) Matrix B. Not modified.
      colB - Column in B being solved for
      pinv - (Input, Optional) Column pivots in G. Null if no pivots.
      xi - (Output) List of row indices in X which are non-zero in graph order. Must have length G.numCols
      w - workspace array used internally. Must have a length of G.numCols*2 or more. Assumed to be filled with 0 in first N elements.
      Returns:
      Returns the index of the first element in the xi list. Also known as top.
    • eliminationTree

      public static void eliminationTree(FMatrixSparseCSC A, boolean ata, int[] parent, @Nullable @Nullable IGrowArray gwork)

      If ata=false then it computes the elimination tree for sparse lower triangular square matrix generated from Cholesky decomposition. If ata=true then it computes the elimination tree of ATA without forming ATA explicitly. In an elimination tree the parent of node 'i' is 'j', where the first off-diagonal non-zero in column 'i' has row index 'j'; j > i for which l[k,i] != 0.

      This tree encodes the non-zero elements in L given A, e.g. L*L' = A, and enables faster to compute solvers than the general purpose implementations.

      Functionally identical to cs_etree in csparse

      Parameters:
      A - (Input) M by N sparse upper triangular matrix. If ata is false then M=N otherwise M ≥ N
      ata - If true then it computes elimination treee of A'A without forming A'A otherwise computes elimination tree for cholesky factorization
      parent - (Output) Parent of each node in tree. This is the elimination tree. -1 if no parent. Size N.
      gwork - (Optional) Internal workspace. Can be null.
    • postorder

      public static void postorder(int[] parent, int N, int[] post, @Nullable @Nullable IGrowArray gwork)

      Sorts an elimination tree eliminationTree(org.ejml.data.FMatrixSparseCSC, boolean, int[], org.ejml.data.IGrowArray) into postorder. In a postoredered tree, the d proper descendants of any node k are numbered k-d through k-1. Non-recursive implementation for better performance.

      post[k] = i means node 'i' of the original tree is node 'k' in the postordered tree.

      See page 44

      Parameters:
      parent - (Input) The elimination tree.
      N - Number of elements in parent
      post - (Output) Postordering permutation.
      gwork - (Optional) Internal workspace. Can be null
    • postorder_dfs

      protected static int postorder_dfs(int j, int k, int[] w, int[] post, int N)
    • searchNzRowsElim

      public static int searchNzRowsElim(FMatrixSparseCSC A, int k, int[] parent, int[] s, int[] w)

      Given an elimination tree compute the non-zero elements in the specified row of L given the symmetric A matrix. This is in general much faster than general purpose algorithms

      Functionally equivalent to cs_ereach() in csparse

      Parameters:
      A - Symmetric matrix.
      k - Row in A being processed.
      parent - elimination tree.
      s - (Output) s[top:(n-1)] = pattern of L[k,:]. Must have length A.numCols
      w - workspace array used internally. All elements must be ≥ 0 on input. Must be of size A.numCols
      Returns:
      Returns the index of the first element in the xi list. Also known as top.
    • qualityTriangular

      public static float qualityTriangular(FMatrixSparseCSC T)
      Computes the quality of a triangular matrix, where the quality of a matrix is defined in LinearSolver.quality(). In this situation the quality os the absolute value of the product of each diagonal element divided by the magnitude of the largest diagonal element. If all diagonal elements are zero then zero is returned.
      Parameters:
      T - A matrix.
      Returns:
      the quality of the system.