# Sparse Matrix Matrix multiplication using Intel MKL

Let $$D$$ be a sparse matrix. I want to compute $$D\times D^T$$. As $$D$$ is fairly large, so I am row-slicing $$D$$. That means for a range $$(i,j)$$, I am computing $$C = D(i:j,:) \times D^T$$ and performing some post-processing on $$C$$. I am choosing the index according to my available memory. I want to know whether there is any built-in function for doing that in Intel MKL. What I am doing now is:

1. Pre-compute $$D^T$$.
2. For a row-slice $$(i,j)$$, compute CSR-handler for $$D(i:j,:)$$
3. $$C = D(i:j,:) \times D^T$$, using mkl_sparse_s_spmmd

This approach uses extra memory to compute and save $$D^T$$ as a pre-processing step. I am using spmmd because the resultant matrix will be dense. spmmd allows us to take operation on the first matrix but not the second. There is also an sp2m, but in this case, the multiplied matrix is sparse. Any methods I have missed?

• The usual question applies for matrix-matrix products: What do you actually need the product for? Couldn't you get away with just implementing the action? – Wolfgang Bangerth Apr 3 '20 at 21:20
• Is there some way to pass a transposed view to the method? Since all you really have to do is flip the iteration indices for the transposed matrix, doing a full precomputation seems to waste memory. – MPIchael Apr 6 '20 at 9:09