- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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 A^{T}) and layout(row-major or col-major) for both A and B, that would be easier for you. Thanks.

Best regards,

Fiona

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I ran into a similar problem. What I need to compute is C = A * B or C = A * B^T with A sparse and B, C dense. The solution I came up with is to rewrite these expressions into C = (B^T * A^T)^T and C = (B * A^T)^T. The remaining dense times sparse matrix multiplications are supported by MKL. This approach introduces a few extra transpose operations on dense matrices. But thanks to your suggestion I found out that these operations can be done without actually changing the underlying data, by swapping the rows/columns and row/column major attributes.

Of course it's possible to do all of this by yourself. What puzzles me is why such routines for sparse times dense matrix multiplication are missing in the MKL library. Perhaps for historical reasons the linear algebra packages offer only a minimal set of operations. But from a user's perspective this is far from ideal.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page