cupyx.scipy.sparse.spmatrix#

class cupyx.scipy.sparse.spmatrix(*args, maxprint=50, **kwargs)[source]#

Mixin for sparse matrix classes.

Sparse matrix classes follow legacy numpy.matrix semantics: * is matrix multiplication and ** is matrix power. Provides backward-compatibility methods (.A, .H, getrow, getcol, etc.) that do not exist on sparse arrays. These APIs are deprecated in favor of the sparse array interface.

Methods

asfptype()[source]#

Upcasts matrix to a floating point format.

When the matrix has floating point type, the method returns itself. Otherwise it makes a copy with floating point type and the same format.

Returns:

A matrix with float type.

Return type:

cupyx.scipy.sparse.spmatrix

getH()[source]#

Hermitian (conjugate) transpose of this matrix.

get_shape()[source]#

Return the shape of the matrix.

getcol(j)[source]#

Return a copy of column j as a (m x 1) sparse column vector.

Matrix-only API; for sparse arrays use A[:, j] (or A[:, [j]] for a 2-D result).

getformat()[source]#

Return the format string of this matrix (e.g. 'csr').

getmaxprint()[source]#

Return the maximum number of stored values shown in __str__.

getnnz(axis=None)[source]#

Number of stored values, including explicit zeros.

Parameters:

axis (None, 0, or 1) – Select between the number of values across the whole matrix, in each column (axis=0), or in each row (axis=1).

getrow(i)[source]#

Return a copy of row i as a (1 x n) sparse row vector.

Matrix-only API; for sparse arrays use A[i] (or A[[i], :] for a 2-D result).

set_shape(shape)[source]#

Set the shape of the matrix in-place.

__eq__(value, /)#

Return self==value.

__ne__(value, /)#

Return self!=value.

__lt__(value, /)#

Return self<value.

__le__(value, /)#

Return self<=value.

__gt__(value, /)#

Return self>value.

__ge__(value, /)#

Return self>=value.

Attributes

A#

Dense ndarray representation of this matrix.

Deprecated since version 15.0: Use toarray() instead.

H#

Hermitian (conjugate) transpose of this matrix.

Deprecated since version 15.0: Use .T.conj() instead.

shape#

Shape of the matrix.