Community
cancel
Showing results for 
Search instead for 
Did you mean: 
76 Views

Dense-Sparse Matrix Multiplication routine instead if sparse-dense multiplication

Hello,

I have a problem where I need to multiply a dense matrix by a sparse matrix. The function "mkl_?csrmm" asks for the first matrix to be sparse and the second to be dense. But my case is opposite.

Problem: C = A * B + C , where A is dense and B is sparse. 

I know that I can use "mkl_?csrmm" after taking the transpose of both matrices A and B but the transpose operation will be costly. Is there a better way or existing routine for dense-sparse matrix multiplication?

I am beginner so kindly forgive for mistakes. Thanks in advance! 

Regards
Shailesh Tripathi

 

 

0 Kudos
2 Replies
Zhen_Z_Intel
Employee
76 Views

Hi Tripathi,

I do not understand why you would like to be multiplied by sparse matrix. MKL only provide mm API that 1st matrix is sparse, and 2nd is dense. For the "mkl_sparse_?_mm" function, you can control transposition(A or AT) and layout(row-major or col-major) for both A and B, that would be easier for you. Thanks.

Best regards,
Fiona

76 Views

Hello Fiona, 

Thanks a lot you for your help. So you mean to say that if my dense matrix is row major but during the function call, if I treat it as column major (which means transpose), I would inherently get the product of two transpose (sparse also transposed). And the result matrix will also be returned as column major but it is basically the transpose of the row major. So basically, that would yield me what I want. Am I right?

Thanks in advance!

Regards

Shailesh Tripathi