回 帖 发 新 帖 刷新版面

主题:[讨论]两个矩阵相乘错误提示

两个矩阵相乘的程序:
先上错误提示:
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

回复列表 (共4个回复)

沙发

这样数据赋值最好用reshape. 直接用等号, 好像是不符合标准.
在不同编译器下可能有问题.(据说ivf可以, gfortran有问题.)

楼主, 你怎么一时打中文一时打英文? 搞什么鬼?

板凳

Thank u
your reply should be greatly appreciated, so I am never stingy,distributing...money!!!!!

3 楼

sorry, the salary is for your other reply to my question, not this one

4 楼

I also want to know what trick the kludge plays by only allowing the new post to show chinese characters, and the reply to show english however

我来回复

您尚未登录,请登录后再回复。点此登录或注册