2005-06-07 Thomas Koenig <Thomas.Koenig@online.de>
[official-gcc.git] / gcc / testsuite / gfortran.fortran-torture / execute / intrinsic_matmul.f90
blob9364f1e1d8b0c620114cb08e6735dc342aaa2db2
1 ! Program to test the MATMUL intrinsic
2 program intrinsic_matmul
3 implicit none
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/))
15 x = (/1, 2/)
16 y = (/1, 2, 3/)
18 r = matmul(a, b)
19 if (any(r .ne. reshape((/14, 20, 26, 38/), (/2, 2/)))) call abort
21 v = matmul(x, a)
22 if (any(v .ne. (/5, 8, 11/))) call abort
24 v(1:2) = matmul(a, y)
25 if (any(v(1:2) .ne. (/14, 20/))) call abort
27 aa = reshape((/ 1.0, 1.0, 0.0, 1.0/), shape(aa))
28 cc = 42.
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/)))) call abort
31 if (any(cc(3:4,1:2) .ne. 42.)) call abort
32 end program