lacuna.sparse.csc#
Classes
|
Compressed Sparse Column (CSC) matrix. |
- class lacuna.sparse.csc.CSC(indptr, indices, data, shape, dtype=<class 'numpy.float64'>, check=True)[source]#
Bases:
SparseMatrixCompressed Sparse Column (CSC) matrix.
- Parameters:
indptr (array_like of int64, shape
(ncols + 1,)) – Column pointer array.indices (array_like of int64, shape
(nnz,)) – Row indices of nonzero values.data (array_like of float64, shape
(nnz,)) – Nonzero values.dtype (numpy.dtype, optional) – Value dtype, defaults to
np.float64.check (bool, optional) – If True, validate invariants in the native layer (may be slower).
- indptr, indices, data
Storage arrays for CSC structure and values.
- Type:
- dtype#
Value dtype.
- Type:
Notes
Backed by Rust kernels through
lacuna._core.Csc64; operations release the GIL.Examples
Construct a small CSC and run basic ops:
>>> import numpy as np >>> from lacuna.sparse import CSC >>> indptr = np.array([0, 1, 2, 3]) >>> indices = np.array([0, 1, 1]) >>> data = np.array([1.0, 2.0, 3.0]) >>> a = CSC(indptr, indices, data, shape=(2, 3)) >>> a.nnz 3 >>> (a @ np.array([1.0, 0.0, 1.0])).tolist() # SpMV [1.0, 3.0] >>> a.sum() 6.0
- property T#
- classmethod from_arrays(indptr, indices, data, shape, check=True)[source]#
Construct from CSC arrays.
- property nnz#
Number of stored values.