Skip to content

SparseMatrix

Module: strata.core • Kind: trait
Source: strata/core/sparse.mojo

trait SparseMatrix
from strata.core import SparseMatrix

Base interface trait for 2D sparse matrix representations.

Provides common dimension queries (num_rows, num_cols) and structural sparsity counts (nnz) for Compressed Sparse Row (CSR) and Compressed Sparse Column (CSC) formats.


Method Description
SparseMatrix.num_rows() Return the number of rows.
SparseMatrix.num_cols() Return the number of columns.
SparseMatrix.nnz() Return the number of stored non-zero entries.

def num_rows(self) -> Int

Return the number of rows.

Returns: Int


def num_cols(self) -> Int

Return the number of columns.

Returns: Int


def nnz(self) -> Int

Return the number of stored non-zero entries.

Returns: Int