Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Multiplication of multidimensional arrays and computation speed

Subject: Multiplication of multidimensional arrays and computation speed

From: Andrey Orlov

Date: 15 Apr, 2010 14:00:23

Message: 1 of 5

Hello,

I have a question. I need to get an elementwise product of two 1000 x 7 x 2 x 80 arrays. What would you recommend me to do (regarding computation time): just directly use .* between these two arrays or set up two for-cycles so to limit elementwise multiplication .* to only matrix elementwise operations (for each i,j obtain M1(:,:,i,j) .* M2(:,:,i,j))?

Subject: Multiplication of multidimensional arrays and computation speed

From: James Tursa

Date: 15 Apr, 2010 15:18:05

Message: 2 of 5

"Andrey Orlov" <user771-30@freemail.ru> wrote in message <hq765n$aoc$1@fred.mathworks.com>...
> Hello,
>
> I have a question. I need to get an elementwise product of two 1000 x 7 x 2 x 80 arrays. What would you recommend me to do (regarding computation time): just directly use .* between these two arrays or set up two for-cycles so to limit elementwise multiplication .* to only matrix elementwise operations (for each i,j obtain M1(:,:,i,j) .* M2(:,:,i,j))?

Definitely just use the .* operator on the original multi-dimensional matrices. The other way you propose will involve a lot of needless and wasteful data copying to form the M1(:,:,i,j) and M2(:,:,i,j) slices.

James Tursa

Subject: Multiplication of multidimensional arrays and computation speed

From: Andrey Orlov

Date: 15 Apr, 2010 15:39:06

Message: 3 of 5

Thanks.

Subject: Multiplication of multidimensional arrays and computation speed

From: Andrey Orlov

Date: 15 Apr, 2010 15:39:06

Message: 4 of 5

Thanks.

Subject: Multiplication of multidimensional arrays and computation speed

From: Andrey Orlov

Date: 15 Apr, 2010 15:39:06

Message: 5 of 5

Thanks.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us