1
votes

I wonder whether the following 2 matrices could be multiplied in Octave in this way without using any "for" loop (i.e. vectorized) :

D is a 3 x m matrix with m columns, e.g. [d1c,d2c,d3c,d4c] (where m=4 and the d*c means 3 x 1 column vector).

A is a m x 2 matrix with m rows, e.g. [a1r;a2r;a3r;a4r] (where the a*r means 1 x 2 row vector).

I want to calculate the output :

result = d1c * a1r + d2c * a2r + d3c * a3r + d4c * a4r;

where every d*c * a*r is a 3 x 2 matrix.

I want to know that could I treat D as a row vector with matrix/vector elements d*c and A as a column vector with matrix/vector elements a*r and then perform the calculation as a special matrix multiplication :

result = D ?*? A; where "?*?" means a special multiplication as specified above

So that this vectorized multiplication would do the job faster when m is large.

Is there any built-in function / approach in Octave that let me do the task in this way ?

Any idea. Thanks for any suggestion.

1

1 Answers

0
votes

After some studies, I find that, in fact, the normal matrix multiplication would do the task for me. That is :

result = D * A;   # just use the normal matrix multiplication in Octave

There is no need for a special matrix multiplication.