]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gfortran.fortran-torture/execute/cmplx.f90
Merge tree-ssa-20020619-branch into mainline.
[thirdparty/gcc.git] / gcc / testsuite / gfortran.fortran-torture / execute / cmplx.f90
1 ! Test complex munbers
2 program testcmplx
3 implicit none
4 complex(kind=4) c, d
5 complex(kind=8) z
6 real(kind=4) x, y
7 real(kind=8) q
8
9 ! cmplx intrinsic
10 x = 3
11 y = 4
12 c = cmplx(x,y)
13 if (c .ne. (3.0, 4.0)) call abort
14 x = 4
15 y = 3
16 z = cmplx(x, y, 8)
17 if (z .ne. (4.0, 3.0)) call abort
18 z = c
19 if (z .ne. (3.0, 4.0)) call abort
20
21 ! dcmplx intrinsic
22 x = 3
23 y = 4
24 z = dcmplx (x, y)
25 if (z .ne. (3.0, 4.0)) call abort
26
27 ! conjucates and aimag
28 c = (1.0, 2.0)
29 c = conjg (c)
30 x = aimag (c)
31 if (abs (c - (1.0, -2.0)) .gt. 0.001) call abort
32 if (x .ne. -2.0) call abort
33 z = (2.0, 1.0)
34 z = conjg (z)
35 q = aimag (z)
36 if (z .ne. (2.0, -1.0)) call abort
37 if (q .ne. -1.0) call abort
38
39 ! addition, subtraction and multiplication
40 c = (1, 3)
41 d = (5, 2)
42 if (c + d .ne. ( 6, 5)) call abort
43 if (c - d .ne. (-4, 1)) call abort
44 if (c * d .ne. (-1, 17)) call abort
45 end program