Intrinsic `matmul` returns `0` matrix
Shaikh-Ubaid opened this issue · comments
Shaikh Ubaid commented
% cat examples/expr2.f90
program expr2
implicit none
double precision :: matrix1(2, 3), matrix2(3, 1)
double precision :: matrix3(2, 1)
integer :: k, i, j
k = 1
do i = 1, 2
do j = 1, 3
matrix1(i, j) = k
k = k + 1
end do
end do
do i = 1, 3
do j = 1, 1
matrix2(i, j) = k
k = k + 1
end do
end do
! print *, matrix1
! print *, matrix2
call matmul2d(matrix1, 2, 3, matrix2, 3, 1, matrix3)
print *, matrix3
contains
subroutine matmul2d(matrix1, rows1, cols1, matrix2, rows2, cols2, matrix3)
integer, intent(in) :: rows1, cols1, rows2, cols2
double precision, intent(in) :: matrix1(rows1, cols1), matrix2(cols1, cols2)
double precision, intent(out) :: matrix3(rows1, cols2)
matrix3 = matmul(matrix1, matrix2)
end subroutine
end program
% gfortran examples/expr2.f90
% ./a.out
50.000000000000000 122.00000000000000
% lfortran examples/expr2.f90
0.00000000000000000e+00
0.00000000000000000e+00