Is it possible to access sub-matrices?

Is it possible to access sub-matrices?

Bild des Benutzers Deleted user

I'm evaluating the MKL for a fastconvolution implementation. Basically I haveone big (800x600) matrix from which I have to cut out small (5x5) sub-matrices which are then further used for multiplication whith a second (fix) matrix.

In the manual I didn't find any function which would allowslicing from an existing matrix. Any hint how MKL can be used for this kind of problem?

5 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Community Admin


Are you seeking to use something like dgemm on the 5x5 submatrices to multiply onto the second matrix? While this could certainly be done, you would likely be unhappy with the results because this is a pretty small operation count to use with dgemm.

With more information we might be able to address this question better.
--Bruce

Bild des Benutzers Deleted user



Well I had seen the ?gemm before which are used for matrix multiplications, however I can't see how to access sub-matrices. Take the following 7x3 matrix:

a b c d e f g
h i j k l m n 
o p q r s t u

from that I'd like to slice out 3x2 matrix like

i j k 
p q r

That slice then should be multiplied with another matrix (e.g. by using the ?gemm function).

Bild des Benutzers Community Admin



All of the BLAS functions were designed with to be used in linear algebra applications. One of the most widely used applications for dgemm is in the update of a matrix which is being factored. A single matrix has a set of rows and columns which have been factored and those factored sections are then used to "update" the rest of the matrix in an operation: C = C - A*B, where A and B are the factored portions of the matrix, C is the balance of the matrix.


There are three 6 numerical parameters that are crucial to the function of dgemm (ignoring, for the moment, the scaling values alpha and beta. If we assume we are performing an operation like C = A*B (I will use Fortran matrix storage nomenclature), the dimensions of portion of A that will be multiplied are m rows and k columns. The dimensions of the portion of B that will be multiplied are k rows and n columns and that leaves that portion of C which will receive the results as having m rows and n columns.


Where the operations will begin for each of the 3 matrices depends on the address of each matrix passed to dgemm, such as C(13, 4), for instance. But dgemm must also know the size of the overall matrices in which A, B, and C are located so there are the parameters lda, ldb, and ldc which, for Fortran, are the number of rows in the underlying matrices.


Returning to the factorization example, let's assume that we are factoring 32 columns at a time and that we have factored the first 32 columns/rows. Furthermore, let's assume that there are 1000 equations and the matrix has 1000 rows. Then, the first call to dgemm would look like this (we are going to perform C = C - A*B). Let us call the matrix A.


call dgemm( 'n', 'n', 968, 968, 32, -1.0, A(33, 1), 1000, A(1, 33), 1000, 1.0, A(33, 33), 1000 )


So this will multiply a submatrix 968 rows long by 32 columns wide times a submatrix 32 rows long by 968 columns wide and subtract it from a matrix 968 rows long by 968 columns wide, all within a matrix with 1000 rows.

Bruce
Bild des Benutzers Deleted user

Many thanks for the detailed answer. It solves my question perfectly.

Melden Sie sich an, um einen Kommentar zu hinterlassen.