【发布时间】:2015-03-14 04:25:14
【问题描述】:
我想知道在 Fortran 中是否有更好(简洁)的编码方式?我试图将a(3, 3) 的每一列乘以b(3) 中的每个值。我知道 Python 中有 np.multiply,但不确定 Fortran。
!!! test.f90
program test
implicit none
integer, parameter :: dp=kind(0.d0)
real(dp) :: a(3, 3)=reshape([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]),&
b(3)=[1, 2, 3]
integer :: i
do i = 1, 3
a(:, i) = a(:, i) * b(i)
end do
write(*, *) a
end program test
提前致谢!
【问题讨论】: