GerritGroot
Technical User
Hi,
I'v got some strange unexpected behaviour of MATMUL in F90, which seems to be compiler independent, so I think I didn't get the point of how MATMUL works
I got:
Gives as output
While I expected it to give the same result as Octave. The following code in Octave or Matlab
Gives the result:
How canI get it right in MATMUL?
I'v got some strange unexpected behaviour of MATMUL in F90, which seems to be compiler independent, so I think I didn't get the point of how MATMUL works
I got:
Code:
PROGRAM TestMatMul
IMPLICIT NONE
REAL, DIMENSION(4,4) :: A
REAL, DIMENSION(4) :: x,y
A=RESHAPE(SOURCE=(/1.0000000,0.0000000,0.0000000,-30.000000, &
0.0000000,1.0000000,0.0000000, 0.0000000, &
0.0000000,0.0000000,1.0000000, 0.0000000, &
0.0000000,0.0000000,0.0000000, 1.0000000/),SHAPE=(/4,4/))
x =RESHAPE(SOURCE=(/30,0,0,1/),SHAPE=(/4/))
y=MATMUL(A,x)
WRITE(*,*)y
END PROGRAM TestMatMul
Code:
30.000000 0.000000E+00 0.000000E+00 -899.000000
Code:
x=[30
0
0
1];
M=[1.0000000 0.0000000 0.0000000 -30.000000
0.0000000 1.0000000 0.0000000 0.0000000
0.0000000 0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 0.0000000 1.0000000];
y=M*x;
Code:
ans =
0
0
0
1
How canI get it right in MATMUL?