cupyx.scipy.sparse.dia_matrix¶
-
class
cupyx.scipy.sparse.dia_matrix(arg1, shape=None, dtype=None, copy=False)[source]¶ Sparse matrix with DIAgonal storage.
Now it has only one initializer format below:
dia_matrix((data, offsets))- 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.
See also
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
-
astype(t)[source]¶ Casts the array to given data type.
- Parameters
dtype – Type specifier.
- Returns
A copy of the array with a given type.
-
conj(copy=True)[source]¶ 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.
- Returns
The element-wise complex conjugate.
- Return type
-
conjugate(copy=True)[source]¶ 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.
- Returns
The element-wise complex conjugate.
- Return type
-
copy()[source]¶ Returns a copy of this matrix.
No data/indices will be shared between the returned value and current matrix.
-
count_nonzero()[source]¶ 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
nnzreturns the number of entries including explicit zeros.- Returns
Number of non-zero entries.
-
diagonal(k=0)[source]¶ Returns the k-th diagonal of the matrix.
- Parameters
k (int, optional) – Which diagonal to get, corresponding to elements
a[i – 0 (the main diagonal).
Default (i+k]) – 0 (the main diagonal).
- Returns
The k-th diagonal.
- Return type
-
get(stream=None)[source]¶ Returns 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.
- Returns
Copy of the array on host memory.
- Return type
-
getnnz(axis=None)[source]¶ Returns the number of stored values, including explicit zeros.
- Parameters
axis – Not supported yet.
- Returns
The number of stored values.
- Return type
-
mean(axis=None, dtype=None, out=None)[source]¶ Compute the arithmetic mean along the specified axis.
- Parameters
axis (int or
None) – Axis along which the sum is computed. If it isNone, it computes the average of all the elements. Select from{None, 0, 1, -2, -1}.- Returns
Summed array.
- Return type
See also
-
power(n, dtype=None)[source]¶ Elementwise power function.
- Parameters
n – Exponent.
dtype – Type specifier.
-
sum(axis=None, dtype=None, out=None)[source]¶ Sums the matrix elements over a given axis.
- Parameters
axis (int or
None) – Axis along which the sum is comuted. If it isNone, 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.
- Returns
Summed array.
- Return type
See also
-
tocsc(copy=False)[source]¶ Converts the matrix to Compressed Sparse Column 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 dia to csc conversion.- Returns
Converted matrix.
- Return type
-
tocsr(copy=False)[source]¶ 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 dia to csr conversion.- Returns
Converted matrix.
- Return type
Attributes
-
H¶
-
T¶
-
device¶ CUDA device on which this array resides.
-
dtype¶ Data type of the matrix.
-
format= 'dia'¶
-
ndim¶
-
nnz¶
-
shape¶
-
size¶