dpnp.scipy.sparse.csr_matrix

class dpnp.scipy.sparse.csr_matrix(arg1, shape=None, dtype=None, copy=False, *, device=None, usm_type=None, sycl_queue=None)[source]

Compressed Sparse Row matrix on a SYCL device.

Attributes:
data{dpnp.ndarray, usm_ndarray}

Non-zero values, one per stored entry (read-only).

indices{dpnp.ndarray, usm_ndarray}

Column index of each stored entry (read-only).

indptr{dpnp.ndarray, usm_ndarray}

Row-start offsets into data / indices (read-only).

shapetuple of int

Tuple of matrix dimensions (M, N).

dtypedpnp dtype

Data type of stored values.

nnzint

Number of stored nonzero entries.

has_sorted_indicesbool

Whether column indices are sorted per row (scipy-compatible).

formatstr

Always 'csr'.

ndimint

Always 2.

Notes

Construction:

  • csr_matrix(D) -- from a 2-D array (dpnp.ndarray or usm_ndarray).

  • csr_matrix((M, N), [dtype=...]) -- an empty (all-zero) matrix of shape (M, N); dtype defaults to the default floating-point type of the device on which the matrix is allocated.

  • csr_matrix((data, indices, indptr), [shape=(M, N)]) -- from raw CSR component arrays (1-D, on the same SYCL queue). shape is inferred from the index arrays when omitted. Components are stored as given; indices are sorted lazily (see sort_indices) when required by the SpMV path.

  • csr_matrix(other_csr) -- copy of another csr_matrix.

Duplicate column indices within a row are not supported (unlike scipy, which sums them); each column must appear at most once per row. This matches the CSR produced by dense construction and the solvers, which never generate duplicates.

Supported operations: construction, dot (matvec) via cached oneMKL SpMV, toarray, copy. This is a solver-support subset of the scipy/cupy CSR API; arithmetic, indexing, reductions, transpose, format conversion and element-wise math are not implemented (the most common such methods raise NotImplementedError). Convert with toarray() and use dpnp for those.