I was wondering that would there be a better (succinct) way to code this in Fortran? I am trying to multiply each column of a(3, 3)
by each value in b(3)<
If you are reusing a particular b frequently you could define:
b(3, 3)=reshape([1, 1, 1, 2, 2, 2, 3, 3, 3], [3, 3])
then you just can do:
a=a*b
..
The do loop can be replaced by a one-liner using FORALL:
forall (i=1:3) a(:, i) = a(:, i) * b(i)
The expression
a * SPREAD(b,1,3)
will produce the same result as your loop. I'll leave it to you and to others to judge whether this is more succinct or in any way better than the loop.