BitMatrixCSR#

class cuquantum.stabilizer.BitMatrixCSR(
row_offsets: ndarray | ndarray,
col_indices: ndarray | ndarray,
nnz: int,
shape: Tuple[int, int],
)[source]#

CSR representation of a binary (GF(2)) matrix.

All nonzero entries are implicitly 1. Storage-agnostic: holds numpy or cupy arrays depending on how it was constructed.

Attributes

row_offsets#

Row pointer array, shape (num_rows + 1,), dtype int64.

col_indices#

Column index array, shape (nnz,), dtype int64.

nnz#

Number of nonzero entries.

shape#

(num_rows, num_cols) of the logical matrix.

Methods

__init__(
row_offsets: ndarray | ndarray,
col_indices: ndarray | ndarray,
nnz: int,
shape: Tuple[int, int],
)[source]#
classmethod from_sparse(mat: SparseCSR) BitMatrixCSR[source]#

Create from a scipy.sparse or cupyx.scipy.sparse CSR matrix.

Accepts csr_array, csr_matrix (scipy), or csr_matrix (cupyx). The data array is ignored – all stored entries are treated as 1.

to_cupyx_sparse() cupyx.scipy.sparse.csr_matrix[source]#

Convert to cupyx.scipy.sparse.csr_matrix. Transfers to GPU if needed.

to_scipy_sparse() scipy.sparse.csr_array[source]#

Convert to scipy.sparse.csr_array. Transfers to CPU if needed.