主题:[讨论]两个矩阵相乘错误提示
两个矩阵相乘的程序:
先上错误提示:
ex0719.f90:3.14:
real :: a(3,4)=(/1,2,3,4,5,6,7,8,9,10,11,12/)
1
Error: Incompatible ranks 2 and 1 in assignment at (1)
ex0719.f90:4.14:
real :: b(4,2)=(/1,2,3,4,5,6,7,8/)
1
Error: Incompatible ranks 2 and 1 in assignment at (1)
ex0719.f90:11.25:
c(i,j)=c(i,j)+a(i,k)*b(k,j)
1
Error: Function 'b' at (1) has no IMPLICIT type
再上程序:
program ex0719
implicit none
real :: a(3,4)=(/1,2,3,4,5,6,7,8,9,10,11,12/)
real :: b(4,2)=(/1,2,3,4,5,6,7,8/)
real :: c(3,2)
integer :: i,j,k
do i=1,3
do j=1,2
c(i,j)=0.
do k=1,4
c(i,j)=c(i,j)+a(i,k)*b(k,j)
end do
end do
end do
write(*,"(6i2)")c
end
先上错误提示:
ex0719.f90:3.14:
real :: a(3,4)=(/1,2,3,4,5,6,7,8,9,10,11,12/)
1
Error: Incompatible ranks 2 and 1 in assignment at (1)
ex0719.f90:4.14:
real :: b(4,2)=(/1,2,3,4,5,6,7,8/)
1
Error: Incompatible ranks 2 and 1 in assignment at (1)
ex0719.f90:11.25:
c(i,j)=c(i,j)+a(i,k)*b(k,j)
1
Error: Function 'b' at (1) has no IMPLICIT type
再上程序:
program ex0719
implicit none
real :: a(3,4)=(/1,2,3,4,5,6,7,8,9,10,11,12/)
real :: b(4,2)=(/1,2,3,4,5,6,7,8/)
real :: c(3,2)
integer :: i,j,k
do i=1,3
do j=1,2
c(i,j)=0.
do k=1,4
c(i,j)=c(i,j)+a(i,k)*b(k,j)
end do
end do
end do
write(*,"(6i2)")c
end