Class SparseAssembly

java.lang.Object
de.labathome.trustconstr.sparse.SparseAssembly

public final class SparseAssembly extends Object
Sparse-aware structured assembly: vstack, hstack, blockArray, and the specialised KKT/Jacobian builders that trust-constr relies on.

These mirror the slice of scipy.sparse that the trust-region constrained optimiser actually uses. The block constructors in scipy live in scipy.sparse._construct and are reached via sps.vstack, sps.hstack, sps.block_array.

  • Method Details

    • vstack

      public static CSRMatrix vstack(CSRMatrix... blocks)
      Vertical stack of CSR matrices: rows are concatenated, columns must agree. Empty input yields an empty 0 x 0 matrix; if all blocks have a common positive column count, the result has that column count.
      Parameters:
      blocks - CSR blocks to stack (in row order)
      Returns:
      concatenated CSR matrix
      See Also:
    • hstack

      public static CSRMatrix hstack(CSRMatrix... blocks)
      Horizontal stack of CSR matrices: columns are concatenated, rows must agree.
      Parameters:
      blocks - CSR blocks to stack (in column order)
      Returns:
      concatenated CSR matrix
      See Also:
    • blockArray

      public static CSRMatrix blockArray(CSRMatrix[][] blocks)
      2D block assembly. blocks[i][j] is the block at row-band i, column-band j; null represents a zero block. Within a row band all non-null blocks must share row count; within a column band all non-null blocks must share column count. At least one block per row band and per column band must be non-null so the band size can be inferred.
      Parameters:
      blocks - 2-D grid of CSRMatrix blocks (rows by columns); null = zero block
      Returns:
      assembled CSR matrix
      See Also:
    • zeros

      public static CSRMatrix zeros(int rows, int cols)
      Parameters:
      rows - number of rows
      cols - number of columns
      Returns:
      a rows x cols CSR matrix with no stored entries
    • assembleJacobianWithSlacks

      public static CSRMatrix assembleJacobianWithSlacks(CSRMatrix jEq, CSRMatrix jIneq, double[] s)
      Build the augmented Jacobian used inside the interior-point method:
           [ J_eq      0     ]
           [ J_ineq   diag(s) ]
       
      Equivalent to blockArray([[J_eq, null], [J_ineq, diag(s)]]) but inlined for the specific structure -- this is the optimised path _assemble_sparse_jacobian from tr_interior_point.py:187.
      Parameters:
      jEq - n_eq x n_vars CSR equality Jacobian
      jIneq - n_ineq x n_vars CSR inequality Jacobian
      s - n_ineq slack-variable values
      Returns:
      (n_eq + n_ineq) x (n_vars + n_ineq) CSR