Broadcast array multiplication in Fortran 90/95

后端 未结 3 498
花落未央
花落未央 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条回答
  •  猫巷女王i
    2020-12-19 07:33

    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
    

    ..

提交回复
热议问题