1 ! Program to test the MATMUL intrinsic
2 program intrinsic_matmul
4 integer, dimension(2, 3) :: a
5 integer, dimension(3, 2) :: b
6 integer, dimension(2) :: x
7 integer, dimension(3) :: y
8 integer, dimension(2, 2) :: r
9 integer, dimension(3) :: v
10 real, dimension (2,2) :: aa
11 real, dimension (4,2) :: cc
13 a
= reshape((/1, 2, 2, 3, 3, 4/), (/2, 3/))
14 b
= reshape((/1, 2, 3, 3, 4, 5/), (/3, 2/))
19 if (any(r
.ne
. reshape((/14, 20, 26, 38/), (/2, 2/)))) STOP 1
22 if (any(v
.ne
. (/5, 8, 11/))) STOP 2
25 if (any(v(1:2) .ne
. (/14, 20/))) STOP 3
27 aa
= reshape((/ 1.0, 1.0, 0.0, 1.0/), shape(aa
))
29 cc(1:2,1:2) = matmul(aa
, transpose(aa
))
30 if (any(cc(1:2,1:2) .ne
. reshape((/ 1.0, 1.0, 1.0, 2.0 /), (/2,2/)))) STOP 4
31 if (any(cc(3:4,1:2) .ne
. 42.)) STOP 5