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}shapetuple of intTuple of matrix dimensions
(M, N).dtypedpnp dtypeData type of stored values.
nnzintNumber of stored nonzero entries.
has_sorted_indicesboolWhether 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.ndarrayorusm_ndarray).csr_matrix((M, N), [dtype=...])-- an empty (all-zero) matrix of shape(M, N);dtypedefaults 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).shapeis inferred from the index arrays when omitted. Components are stored as given; indices are sorted lazily (seesort_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 raiseNotImplementedError). Convert withtoarray()and use dpnp for those.