# Use Which Routine for Sparse Matrix-Sparse Vector Multiplication

## Use Which Routine for Sparse Matrix-Sparse Vector Multiplication

I have a huge matrix with very few non-zero elements. Some of the columns and rows may also be completely zero. This matrix should be multiplied by a very long vector which has only few non-zero elements. I know that mkl_?cscmv performs the sparse matrix-vector multiplication but apparently only the matrix can be sparse. I am wondering if there is any MKL routine to calculate the production of such matrix and vector.

4 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

You can have a look at mkl_?csrmm, mkl_?bsrmm, mkl_?cscmm, or mkl_?coomm and simply treat the vector as a sparse matrix.

The answer depends quite a bit on the representation that you have used for the sparse vector that you wish to multiply the sparse matrix into. Do you know the indices of the vector entries that are not equal to zero? Do you know the indices of the result vector that are not equal to zero?

Quote:

mecej4 wrote:

The answer depends quite a bit on the representation that you have used for the sparse vector that you wish to multiply the sparse matrix into. Do you know the indices of the vector entries that are not equal to zero? Do you know the indices of the result vector that are not equal to zero?

Each sparse vector is represented by <nz, nRows, ind, data>, where nz and nRows represent number of non-zero elements and number of rows, ind is an array representing index for non-zero elements, and data is an array representing value of non-zero elements. So, I do have the indices of input vector.

For the resulting vector, I know everything except data, i.e. I know what the indices for non-zero elements will be.

Thanks