Reputation: 398
from scipy import sparse
from sparse_dot_mkl import dot_product_mkl
data =[1,1,1,1]
Row=[1, 100, 2, 200]
Col=[53, 21, 18, 32]
N=210
A=sparse.csc_matrix((data, (Row,Col)), shape=(N,N) )
M=A.copy()
dot_product_mkl(A,A)
I get this error:
> ValueError Traceback (most recent call
> last) <ipython-input-10-fa6e7f71b940> in <module>
> ----> 1 dot_product_mkl(A,A)
>
> ~\anaconda3\lib\site-packages\sparse_dot_mkl\sparse_dot.py in
> dot_product_mkl(matrix_a, matrix_b, cast, copy, reorder_output, dense,
> debug, out, out_scalar)
> 56
> 57 elif num_sparse == 2:
> ---> 58 return _sds(matrix_a, matrix_b, cast=cast, reorder_output=reorder_output, dense=dense)
> 59
> 60 # SPARSE (DOT) VECTOR #
>
> ~\anaconda3\lib\site-packages\sparse_dot_mkl\_sparse_sparse.py in
> _sparse_dot_sparse(matrix_a, matrix_b, cast, reorder_output, dense)
> 127
> 128 # Check dtypes
> --> 129 matrix_a, matrix_b = _type_check(matrix_a, matrix_b, cast=cast)
> 130
> 131 t = debug_timer()
>
> ~\anaconda3\lib\site-packages\sparse_dot_mkl\_mkl_interface\_common.py
> in _type_check(matrix_a, matrix_b, cast)
> 624 err_msg = "Matrix data types must be in concordance; {a} and {b} provided".format(a=matrix_a.dtype,
> 625 b=matrix_b.dtype)
> --> 626 raise ValueError(err_msg)
> 627
> 628 def _mkl_scalar(scalar, complex_type, double_precision):
>
> ValueError: Matrix data types must be in concordance; int32 and int32
> provided
The two matrices are copies of each other so I don't understand what this message means.
Upvotes: 0
Views: 410
Reputation: 862
This package only works with float or complex float data.
The below link will help you to understand sparse dot product in detail.
https://pypi.org/project/sparse-dot-mkl/
Here it is clearly mentioned that, this package only works with float or complex float data. cast=True will convert data to double-precision floats or complex floats by making an internal copy if necessary. If A and B are both single-precision floats or complex floats they will be used as is. cast=False will raise a ValueError if the input arrays are not both double-precision or both single-precision. This defaults to False on the principle that potentially unsafe dtype conversions should not occur without explicit instruction.
Upvotes: 1