Native Representation¶
The csr.CSR
class provides the primary objectoriented interface to
the sparse matrix capabilities for use from Python, but is not directly usable
in functions written for use with Numba’s nopython mode. Therefore, the Python
class is written as a thin wrapper around a Numba jitclass, csr._CSR
,
that can be efficiently used from compiled code.
This class only provides storage, not methods. Native functions corresponding
to most of the CSR operations are provided by csr.native_ops
and the
kernels.

class
csr.
_CSR
(*args, **kwargs)¶ Internal storage for
csr.CSR
. If you work with CSRs from Numba, you will use this type instead of the CSR class itself, with functions fromcsr.native_ops
.This has the same key attributes as
csr.CSR
, except that it always has avalues
array; if only structure is stored, this array has length 0.
rowptrs
¶ starting position of each row (length
nrows + 1
) Type

colinds
¶ column indices (length
nnz
) Type

values
¶ matrix cell values (length
nnz
or 0). If only the matrix structure is stored, this has length 0. Type

Native Operations¶
Backend implementations of Numba operations.

csr.native_ops.
row_extent
(csr, row)¶ Get the extent of a row in the matrix storage.

csr.native_ops.
row
(csr, row)¶ Get a row as a dense vector.

csr.native_ops.
row_cs
(csr, row)¶ Get the column indices for a row.

csr.native_ops.
row_vs
(csr, row)¶ Get the nonzero values for a row.

csr.native_ops.
rowinds
(csr)¶ Get the row indices for the nonzero values in a matrix.

csr.native_ops.
subset_rows
(csr, begin, end)¶ Take a subset of the rows of a CSR.

csr.native_ops.
center_rows
(csr)¶ Meancenter the nonzero values of each row of a CSR.

csr.native_ops.
unit_rows
(csr)¶ Normalize the rows of a CSR to unit vectors.

csr.native_ops.
transpose
(csr, include_values)¶ Transpose a CSR.

csr.native_ops.
sort_rows
(csr)¶ Sort the rows of a CSR by increasing column index