Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Question about mkl_?omatadd

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

Guillaume_A_

New Contributor I

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

03-06-2015
05:25 AM

101 Views

Question about mkl_?omatadd

Hi,

The description of mkl_?omatadd function in the manual is a bit confusing:

- parameter m is described as "The number of matrix rows". Which one ? (A, B or C ?) What if I want to transpose A or B ?

- same question about parameter n.

- Why is ldc an output parameter ??

I wanna do this kind of operation "C = alpha*A + beta*B^t".

Thanks in advance for your help,

Guix

1 Solution

Evarist_F_Intel

Employee

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

03-06-2015
09:03 PM

101 Views

Hi Guix,

Yes, you are right, omatadd documentation is slightly confusing.

Thank you for the question. Let me try to clarify.

Parameters **m** and **n** stand for rows and columns of matrix C (the only matrix to which op() is not applied). Since you specify the **m** and **n**, the matrices op(A) and op(B) should have the same sizes.

**lda**, **ldb** and **ldc** are leading dimensions for original matrices (i.e. with-out any op operations). Of course **ldc** is not 'out' parameter, but 'in'. This is a typo.

A small examples that performs

C <-- alpha*A + beta*B^T

#include <stdio.h> #include "mkl.h" static inline printA(double *x, int rows, int cols, int lda) { for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { printf("%8.0f", x[i*lda + j]); } printf("\n"); } printf("\n"); } int main() { double a[] = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 0, 0, 0 }; double b[] = { 1, 2, 3, 0, 0, 4, 5, 6, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0 }; double c[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char transa, transb; double alpha = 1., beta = 1.; size_t m, n; size_t lda = 3, ldb = 5, ldc = 3; transa = 'N'; transb = 'T'; m = 2; n = 3; mkl_domatadd('R', transa, transb, m, n, alpha, a, lda, beta, b, ldb, c, ldc); printA(c, 2, 3, ldc); return 0; }

Here we get matrix C of form 2x3 with **ldc** = 3 using block 2x3 from matrix A and 3x2 from matrix B.

The result is:

101 204 307 402 505 608

Link Copied

2 Replies

Evarist_F_Intel

Employee

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

03-06-2015
09:03 PM

102 Views

Hi Guix,

Yes, you are right, omatadd documentation is slightly confusing.

Thank you for the question. Let me try to clarify.

Parameters **m** and **n** stand for rows and columns of matrix C (the only matrix to which op() is not applied). Since you specify the **m** and **n**, the matrices op(A) and op(B) should have the same sizes.

**lda**, **ldb** and **ldc** are leading dimensions for original matrices (i.e. with-out any op operations). Of course **ldc** is not 'out' parameter, but 'in'. This is a typo.

A small examples that performs

C <-- alpha*A + beta*B^T

#include <stdio.h> #include "mkl.h" static inline printA(double *x, int rows, int cols, int lda) { for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { printf("%8.0f", x[i*lda + j]); } printf("\n"); } printf("\n"); } int main() { double a[] = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 0, 0, 0 }; double b[] = { 1, 2, 3, 0, 0, 4, 5, 6, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0 }; double c[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char transa, transb; double alpha = 1., beta = 1.; size_t m, n; size_t lda = 3, ldb = 5, ldc = 3; transa = 'N'; transb = 'T'; m = 2; n = 3; mkl_domatadd('R', transa, transb, m, n, alpha, a, lda, beta, b, ldb, c, ldc); printA(c, 2, 3, ldc); return 0; }

Here we get matrix C of form 2x3 with **ldc** = 3 using block 2x3 from matrix A and 3x2 from matrix B.

The result is:

101 204 307 402 505 608

Guillaume_A_

New Contributor I

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

03-07-2015
12:08 PM

101 Views

Thank you for your explanation Evarist, it makes sense now !

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

For more complete information about compiler optimizations, see our Optimization Notice.