# cupyx.scipy.sparse.csc_matrix¶

class cupyx.scipy.sparse.csc_matrix(arg1, shape=None, dtype=None, copy=False)

Compressed Sparse Column matrix.

Now it has only part of initializer formats:

csc_matrix(D)
D is a rank-2 cupy.ndarray.
csc_matrix(S)
S is another sparse matrix. It is equivalent to S.tocsc().
csc_matrix((M, N), [dtype])
It constructs an empty matrix whose shape is (M, N). Default dtype is float64.
csc_matrix((data, indices, indptr))
All data, indices and indptr are one-dimenaional cupy.ndarray.
Parameters: arg1 – Arguments for the initializer. shape (tuple) – Shape of a matrix. Its length must be two. dtype – Data type. It must be an argument of numpy.dtype. copy (bool) – If True, copies of given arrays are always used.

Methods

__getitem__(slices)
__len__()
__iter__()
arcsin()

Elementwise arcsin.

arcsinh()

Elementwise arcsinh.

arctan()

Elementwise arctan.

arctanh()

Elementwise arctanh.

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: dtype – Type specifier. A copy of the array with a given type.
ceil()

Elementwise ceil.

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()

Returns number of non-zero entries.

Note

This method counts the actual number of non-zero entories, which does not include explicit zero entries. Instead nnz returns the number of entries including explicit zeros.

Returns: Number of non-zero entries.
deg2rad()

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

eliminate_zeros()

Removes zero entories in place.

expm1()

Elementwise expm1.

floor()

Elementwise floor.

get(stream=None)

Returns a copy of the array on host memory.

Warning

You need to install SciPy to use this method.

Parameters: stream (cupy.cuda.Stream) – CUDA stream object. If it is given, the copy runs asynchronously. Otherwise, the copy is synchronous. Copy of the array on host memory. scipy.sparse.csc_matrix
getH()
get_shape()

Returns the shape of the matrix.

Returns: Shape of the matrix. tuple
getformat()
getmaxprint()
getnnz(axis=None)

Returns the number of stored values, including explicit zeros.

Parameters: axis – Not supported yet. The number of stored values. int
log1p()

Elementwise log1p.

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

Point-wise multiplication by another matrix

power(n, dtype=None)

Elementwise power function.

Parameters: n – Exponent. dtype – Type specifier.
rad2deg()

reshape(shape, order='C')

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

rint()

Elementwise rint.

set_shape(shape)
sign()

Elementwise sign.

sin()

Elementwise sin.

sinh()

Elementwise sinh.

sort_indices()

Sorts the indices of the matrix in place.

sqrt()

Elementwise sqrt.

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
sum_duplicates()
tan()

Elementwise tan.

tanh()

Elementwise tanh.

toarray(order=None, out=None)

Returns a dense matrix representing the same value.

Parameters: order ({'C', 'F', None}) – Whether to store data in C (row-major) order or F (column-major) order. Default is C-order. out – Not supported. Dense array representing the same matrix. cupy.ndarray
tobsr(blocksize=None, copy=False)

Convert this matrix to Block Sparse Row format.

tocoo(copy=False)

Converts the matrix to COOdinate format.

Parameters: copy (bool) – If False, it shares data arrays as much as possible. Converted matrix. cupyx.scipy.sparse.coo_matrix
tocsc(copy=None)

Converts the matrix to Compressed Sparse Column format.

Parameters: copy (bool) – If False, the method returns itself. Otherwise it makes a copy of the matrix. Converted matrix. cupyx.scipy.sparse.csc_matrix
tocsr(copy=False)

Converts the matrix to Compressed Sparse Row format.

Parameters: copy (bool) – If False, it shares data arrays as much as possible. Actually this option is ignored because all arrays in a matrix cannot be shared in csr to csc conversion. Converted matrix. cupyx.scipy.sparse.csr_matrix
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)

Returns a transpose matrix.

Parameters: axes – This option is not supported. copy (bool) – If True, a returned matrix shares no data. Otherwise, it shared data arrays as much as possible. Transpose matrix. cupyx.scipy.sparse.spmatrix
trunc()

Elementwise trunc.

__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.

dtype

Data type of the matrix.

format = 'csc'
has_canonical_format
ndim
nnz
shape
size