1
I am encountering a problem to compile a program in Fortran. The build error accuses that the Shape of the matrices are not compliant. However, I understand that it is mathematically allowed to multiply a 2x3 Matrix by a 3x2 matrix2.
mtx1 = | 2 4 1 | mtx2 = | 3 4 | Resultado esperado: | 12 18 |
| 1 3 6 | | 1 1 | | 15 25 |
| 2 3 |
This is the build error message:
print*, mtx1*mtx2 1 2 Error: Shapes for operands at (1) and (2) are not conformable
source code
program test
integer :: mtx1(2,3) = reshape((/2,4,1, 1,3,6/),(/2,3/))
integer :: mtx2(3,2) = reshape((/3,4, 1,1, 2,3/),(/3,2/))
print*, mtx1*mtx2
end program teste
Hans, could you put your question in English?
– Woss
I tried to use intrinsic function
matmul(mtx1,mtx2)
, compiled, however result is not consistent.– Hans Zimermann
Use the [Edit button]
– Woss