Is there an in-built function in octave to multiply each column of a m X n element-wise with a column vector of size m that is more efficient than using a loop?
21
votes
2 Answers
39
votes
3
votes
I haven't tried Anna Lear's answer but as nobar commented in that answer, Octave now does broadcasting. So you just have to do A.*B. You will get a warning that'll say an automatic product broadcasting is being applied
>> A.*B
warning: product: automatic broadcasting operation applied
ans =
1 2
6 8
15 18