Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7222 Discussions

Selective row/column to use for mat-mat and mat-vec multiplication

ssylee
Beginner
1,463 Views
Sorry to double-post in advance. I initially posted at http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=892 to ask about my question in the link. However, as I'm aware that there are probably more people using Intel or AMD math calculation tools when working with matrices, which includes Lapack, BLAS, and Sparse BLAS, I think I would have much better luck on asking for opinions here. It would be great if you have any tips on if there's a library function available for performing mat-mat, row-col, and mat-vec calculations while being able to select which rows/columns to multiply. The matrix is not densely sparse. It's more so randomly sparse along the matrix diagonal.
0 Kudos
4 Replies
Victor_Gladkikh
New Contributor I
1,463 Views
Quoting - ssylee
Sorry to double-post in advance. I initially posted at http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=892 to ask about my question in the link. However, as I'm aware that there are probably more people using Intel or AMD math calculation tools when working with matrices, which includes Lapack, BLAS, and Sparse BLAS, I think I would have much better luck on asking for opinions here. It would be great if you have any tips on if there's a library function available for performing mat-mat, row-col, and mat-vec calculations while being able to select which rows/columns to multiply. The matrix is not densely sparse. It's more so randomly sparse along the matrix diagonal.


MKL BLAS level1 and MKL Sparse BLAS level 1 contain functions for vector-vector operations.

These routines can be used for performing multiplication of selected row of one matrix and a column of other matrix.

1.Dot product the i-th row of dense matrix A (m by n matrix stored in 2 dimensional FORTRAN array) and the j-th column of dense matrix B (n by n) can be computed with the help of "?dot" routine from BLAS level 1.

res = ddot(n, a(i, 1), m, b(1,j), 1)

2.Dot product the i-th row of sparse matrix A (m by n matrix stored in the CSR matrix format) and the j-th column of dense matrix B (n by n) can be computed with the help of "?doti" routine from Sparse BLAS level 1.

res = ddoti( pointere(i)-pointerb(i), values(pointerb(i)), columns(pointerb(i)), b(1,j))

See MKL Reference Manual for more details.

0 Kudos
ssylee
Beginner
1,463 Views


MKL BLAS level1 and MKL Sparse BLAS level 1 contain functions for vector-vector operations.

These routines can be used for performing multiplication of selected row of one matrix and a column of other matrix.

1.Dot product the i-th row of dense matrix A (m by n matrix stored in 2 dimensional FORTRAN array) and the j-th column of dense matrix B (n by n) can be computed with the help of "?dot" routine from BLAS level 1.

res = ddot(n, a(i, 1), m, b(1,j), 1)

2.Dot product the i-th row of sparse matrix A (m by n matrix stored in the CSR matrix format) and the j-th column of dense matrix B (n by n) can be computed with the help of "?doti" routine from Sparse BLAS level 1.

res = ddoti( pointere(i)-pointerb(i), values(pointerb(i)), columns(pointerb(i)), b(1,j))

See MKL Reference Manual for more details.


Would I need to extract a(i, 1) or b(1, j) in a vector manually first before calling the dot product function?
0 Kudos
Victor_Gladkikh
New Contributor I
1,463 Views

This is not actually needed.

0 Kudos
TimP
Honored Contributor III
1,463 Views
Quoting - ssylee

Would I need to extract a(i, 1) or b(1, j) in a vector manually first before calling the dot product function?
It seems that a Fortran dot_product would be appropriate.
0 Kudos
Reply