Skip to main content

Module sparse_functions

Module sparse_functions 

Source
Expand description

Sparse matrix utility functions

This module provides convenience functions that return concrete typed sparse matrices (CsrArray<T>) instead of trait objects, plus additional utility functions for common sparse matrix constructions.

Functions provided:

  • sparse_eye(n) - Sparse identity matrix
  • sparse_random(m, n, density) - Random sparse matrix
  • sparse_kron(A, B) - Kronecker product
  • sparse_hstack(arrays) - Horizontal stacking
  • sparse_vstack(arrays) - Vertical stacking
  • sparse_block_diag(arrays) - Block diagonal construction
  • sparse_diags(diags, offsets, shape) - Construct from diagonals

Functionsยง

sparse_block_diag
Construct a block diagonal sparse matrix from a list of sub-matrices.
sparse_diag_matrix
Create a sparse matrix with given values on the specified diagonal.
sparse_diags
Construct a sparse matrix from diagonals.
sparse_eye
Create a sparse identity matrix of size n x n in CSR format.
sparse_eye_rect
Create a rectangular sparse identity-like matrix of size m x n in CSR format.
sparse_hstack
Stack sparse matrices horizontally (column-wise).
sparse_kron
Compute the Kronecker product of two sparse matrices.
sparse_kronsum
Kronecker sum of two sparse matrices: A (x) I_q + I_p (x) B
sparse_random
Create a random sparse matrix in CSR format.
sparse_vstack
Stack sparse matrices vertically (row-wise).