scipy.sparse.csr_matrix.
dot#
- csr_matrix.dot(other)[source]#
Ordinary dot product.
- Parameters:
- otherarray_like or sparse array
Array to take dot product with.
- Returns:
- sparse array/matrix or ndarray
Result of dot product. The type depends on other:
If other is a scalar, the result is a sparse array/matrix.
If other is an ndarray, the result is an ndarray.
Notes
Sparse results are not guaranteed to have sorted indices, even when both inputs have sorted indices. For CSR and CSC results, use
has_sorted_indicesto check the ordering andsort_indicesto sort the indices in place when needed.Examples
>>> import numpy as np >>> from scipy.sparse import csr_array >>> A = csr_array([[1, 2, 0], [0, 0, 3], [4, 0, 5]]) >>> v = np.array([1, 0, -1]) >>> A.dot(v) array([ 1, -3, -1], dtype=int64)