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

Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- Element-by-Element matrix multiplication

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

Gaston_N_

Beginner

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

02-15-2017
09:28 AM

137 Views

Element-by-Element matrix multiplication

Hi all,

I have a simple task at hand. I want to compute an element-by-element multiplication of two matrices A and B.

If use C = A*B it delivers the result I want, but it is very slow.

Do you know any faster way to make this computation?

For instance, if A and B were vectors, vdmul would be an efficient way to proceed. I'm looking for something similar, but using matrices.

Thanks!

Gaston

Link Copied

3 Replies

Zhen_Z_Intel

Employee

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

02-15-2017
05:12 PM

137 Views

Dear customer,

For the element-by-element multiplication, I am afraid there's no specify function for matrix, but only vector. If you would like to improve the performance, you could try with multi-threading calculation by using

#pragma omp parallel for for (int i = 0; i < row; i++) { vdMul(col, a, b, y); }

More physical core you have for your CPU, the higher performance you will get. Please also provide the testing performance with your hardware information to us, we will see if the performance acceptable. Thank you.

Best regards,

Fiona

SKost

Valued Contributor II

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

02-17-2017
12:09 PM

137 Views

Mikhail_K_

Beginner

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

02-19-2017
01:18 AM

137 Views

Sergey Kostrov wrote:

>>...I have a simple task at hand. I want to compute an element-by-element multiplication of two matrices A and B.

If your matrices are stored as vectors, that is as

1-Ddata sets, like double dMxA[ size ], dMxB[ size ], etc,, thenvdMulneeds to be used.

1-Drepresentation of a matrix is very efficient ( contiguous memory blocks ).

In this case you can even do hadamard with BLAS functions tbmv or sbmv. Both allow the input matrix to be stored in banded matrix form. With number of super-diagonals = 0 you only need to supply the diagonal, which in this case is one of the vectors

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