Broadcast array multiplication in Fortran 90/95

后端 未结 3 497
花落未央
花落未央 2020-12-19 07:27

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)<

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 07:39

    The do loop can be replaced by a one-liner using FORALL:

    forall (i=1:3) a(:, i) = a(:, i) * b(i)
    

提交回复
热议问题