# cupyx.scipy.sparse.spmatrix¶

class cupyx.scipy.sparse.spmatrix(maxprint=50)

Base class of all sparse matrixes.

Methods

__len__()
__iter__()
asformat(format)

Return this matrix in a given sparse format.

Parameters: format (str or None) – Format you need.
asfptype()

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. cupyx.scipy.sparse.spmatrix
astype(t)

Casts the array to given data type.

Parameters: t – Type specifier. A copy of the array with the given type and the same format. cupyx.scipy.sparse.spmatrix
conj(copy=True)

Element-wise complex conjugation.

If the matrix is of non-complex data type and copy is False, this method does nothing and the data is not copied.

Parameters: copy (bool) – If True, the result is guaranteed to not share data with self. The element-wise complex conjugate. cupyx.scipy.sparse.spmatrix
conjugate(copy=True)

Element-wise complex conjugation.

If the matrix is of non-complex data type and copy is False, this method does nothing and the data is not copied.

Parameters: copy (bool) – If True, the result is guaranteed to not share data with self. The element-wise complex conjugate. cupyx.scipy.sparse.spmatrix
copy()

Returns a copy of this matrix.

No data/indices will be shared between the returned value and current matrix.

count_nonzero()

Number of non-zero entries, equivalent to

diagonal(k=0)

Returns the k-th diagonal of the matrix.

Parameters: k (int, optional) – Which diagonal to get, corresponding to elements i+k] Default (a[i,) – 0 (the main diagonal). The k-th diagonal. cupy.ndarray
dot(other)

Ordinary dot product

get(stream=None)

Return a copy of the array on host memory.

Parameters: stream (cupy.cuda.Stream) – CUDA stream object. If it is given, the copy runs asynchronously. Otherwise, the copy is synchronous. An array on host memory. scipy.sparse.spmatrix
getH()
get_shape()
getformat()
getmaxprint()
getnnz(axis=None)

Number of stored values, including explicit zeros.

maximum(other)
minimum(other)
multiply(other)

Point-wise multiplication by another matrix

power(n, dtype=None)
reshape(shape, order='C')

Gives a new shape to a sparse matrix without changing its data.

set_shape(shape)
sum(axis=None, dtype=None, out=None)

Sums the matrix elements over a given axis.

Parameters: axis (int or None) – Axis along which the sum is comuted. If it is None, it computes the sum of all the elements. Select from {None, 0, 1, -2, -1}. dtype – The type of returned matrix. If it is not specified, type of the array is used. out (cupy.ndarray) – Output matrix. Summed array. cupy.ndarray
toarray(order=None, out=None)

Return a dense ndarray representation of this matrix.

tobsr(blocksize=None, copy=False)

Convert this matrix to Block Sparse Row format.

tocoo(copy=False)

Convert this matrix to COOrdinate format.

tocsc(copy=False)

Convert this matrix to Compressed Sparse Column format.

tocsr(copy=False)

Convert this matrix to Compressed Sparse Row format.

todense(order=None, out=None)

Return a dense matrix representation of this matrix.

todia(copy=False)

Convert this matrix to sparse DIAgonal format.

todok(copy=False)

Convert this matrix to Dictionary Of Keys format.

tolil(copy=False)

Convert this matrix to LInked List format.

transpose(axes=None, copy=False)

Reverses the dimensions of the sparse matrix.

__eq__(other)

Return self==value.

__ne__(other)

Return self!=value.

__lt__(other)

Return self<value.

__le__(other)

Return self<=value.

__gt__(other)

Return self>value.

__ge__(other)

Return self>=value.

__nonzero__()
__bool__()

Attributes

A

Dense ndarray representation of this matrix.

This property is equivalent to toarray() method.

H
T
device

CUDA device on which this array resides.

ndim
nnz
shape
size