PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / matmul_1.f90
blob9bf276ac43563848bb61a506f095a11adef0f259
1 !{ dg-do run }
2 ! Test MATMUL for various arguments and results
3 ! (test values checked with GNU octave).
4 ! PR18857 was due to an incorrect assertion that component base==0
5 ! for both input arguments and the result.
6 ! provided by Paul Thomas - pault@gcc.gnu.org
8 Program matmul_1
9 integer, parameter :: N = 5
10 integer, parameter :: T = 4
11 integer :: i
12 real(kind=T), dimension(:,:), allocatable :: a, b, c
13 real(kind=T), dimension(N,N) :: x, y, z
15 allocate (a(2*N, N), b(N, N), c(2*N, N))
17 do i = 1, 2*N
18 a(i, :) = real (i)
19 end do
20 b = 4.0_T
22 do i = 1, N
23 x(i, :) = real (i)
24 end do
25 y = 2.0_T
27 ! whole array
29 z = 0.0_T
30 z = matmul (x, y)
31 if (sum (z) /= 750.0_T) STOP 1
33 ! array sections
35 c = 0.0_T
36 c(1:3,1:2) = matmul (a(7:9,3:N), b(3:N,3:4))
37 if (sum (c) /= 576.0_T) STOP 2
39 ! uses a temp
41 c = 0.0_T
42 c = matmul (a, b + x)
43 if (sum (c) /= 9625.0_T) STOP 3
45 ! returns to a temp
47 c = 0.0_T
48 c = a + matmul (a, b)
49 if (sum (c) /= 5775.0_T) STOP 4
51 deallocate (a, b, c)
53 end program matmul_1