summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/minlocval_4.f90
blob: c42b01944213a57727e3c7d649fbc214e5bf72db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
! { dg-do run }
! { dg-add-options ieee }
! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
  real :: a(3,3), b(3), nan, minf, pinf, h
  logical :: l, l2
  logical :: l3(3,3), l4(3,3), l5(3,3)

  nan = 0.0
  minf = 0.0
  pinf = 0.0
  nan = 0.0/nan
  minf = -1.0/minf
  pinf = 1.0/pinf
  h = huge(h)
  l = .false.
  l2 = .true.
  l3 = .false.
  l4 = .true.
  l5 = .true.
  l5(1,1) = .false.
  l5(1,2) = .false.
  l5(2,3) = .false.
  a = reshape ((/ nan, nan, nan, pinf, pinf, pinf, pinf, minf, pinf /), (/ 3, 3 /))
  if (minval (a).ne.minf) call abort
  if (any (minloc (a).ne.(/ 2, 3 /))) call abort
  b = minval (a, dim = 1)
  if (.not.isnan(b(1))) call abort
  b(1) = 0.0
  if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
  if (any (minloc (a, dim = 1).ne.(/ 1, 1, 2 /))) call abort
  b = minval (a, dim = 2)
  if (any (b.ne.(/ pinf, minf, pinf /))) call abort
  if (any (minloc (a, dim = 2).ne.(/ 2, 3, 2 /))) call abort
  if (minval (a, mask = l).ne.h) call abort
  if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
  b = minval (a, dim = 1, mask = l)
  if (any (b.ne.(/ h, h, h /))) call abort
  if (any (minloc (a, dim = 1, mask = l).ne.(/ 0, 0, 0 /))) call abort
  b = minval (a, dim = 2, mask = l)
  if (any (b.ne.(/ h, h, h /))) call abort
  if (any (minloc (a, dim = 2, mask = l).ne.(/ 0, 0, 0 /))) call abort
  if (minval (a, mask = l3).ne.h) call abort
  if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
  b = minval (a, dim = 1, mask = l3)
  if (any (b.ne.(/ h, h, h /))) call abort
  if (any (minloc (a, dim = 1, mask = l3).ne.(/ 0, 0, 0 /))) call abort
  b = minval (a, dim = 2, mask = l3)
  if (any (b.ne.(/ h, h, h /))) call abort
  if (any (minloc (a, dim = 2, mask = l3).ne.(/ 0, 0, 0 /))) call abort
  if (minval (a, mask = l2).ne.minf) call abort
  if (minval (a, mask = l4).ne.minf) call abort
  if (any (minloc (a, mask = l2).ne.(/ 2, 3 /))) call abort
  if (any (minloc (a, mask = l4).ne.(/ 2, 3 /))) call abort
  b = minval (a, dim = 1, mask = l2)
  if (.not.isnan(b(1))) call abort
  b(1) = 0.0
  if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
  if (any (minloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
  b = minval (a, dim = 2, mask = l2)
  if (any (b.ne.(/ pinf, minf, pinf /))) call abort
  if (any (minloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
  b = minval (a, dim = 1, mask = l4)
  if (.not.isnan(b(1))) call abort
  b(1) = 0.0
  if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
  if (any (minloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
  b = minval (a, dim = 2, mask = l4)
  if (any (b.ne.(/ pinf, minf, pinf /))) call abort
  if (any (minloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
  if (minval (a, mask = l5).ne.pinf) call abort
  if (any (minloc (a, mask = l5).ne.(/ 2, 2 /))) call abort
  b = minval (a, dim = 1, mask = l5)
  if (.not.isnan(b(1))) call abort
  b(1) = 0.0
  if (any (b.ne.(/ 0.0, pinf, pinf /))) call abort
  if (any (minloc (a, dim = 1, mask = l5).ne.(/ 2, 2, 1 /))) call abort
  b = minval (a, dim = 2, mask = l5)
  if (any (b.ne.(/ pinf, pinf, pinf /))) call abort
  if (any (minloc (a, dim = 2, mask = l5).ne.(/ 3, 2, 2 /))) call abort
  a = nan
  if (.not.isnan(minval (a))) call abort
  if (minval (a, mask = l).ne.h) call abort
  if (.not.isnan(minval (a, mask = l2))) call abort
  if (minval (a, mask = l3).ne.h) call abort
  if (.not.isnan(minval (a, mask = l4))) call abort
  if (.not.isnan(minval (a, mask = l5))) call abort
  if (any (minloc (a).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
  a = pinf
  if (minval (a).ne.pinf) call abort
  if (minval (a, mask = l).ne.h) call abort
  if (minval (a, mask = l2).ne.pinf) call abort
  if (minval (a, mask = l3).ne.h) call abort
  if (minval (a, mask = l4).ne.pinf) call abort
  if (minval (a, mask = l5).ne.pinf) call abort
  if (any (minloc (a).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
  if (any (minloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
  a = nan
  a(1,3) = pinf
  if (minval (a).ne.pinf) call abort
  if (minval (a, mask = l).ne.h) call abort
  if (minval (a, mask = l2).ne.pinf) call abort
  if (minval (a, mask = l3).ne.h) call abort
  if (minval (a, mask = l4).ne.pinf) call abort
  if (minval (a, mask = l5).ne.pinf) call abort
  if (any (minloc (a).ne.(/ 1, 3 /))) call abort
  if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l2).ne.(/ 1, 3 /))) call abort
  if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
  if (any (minloc (a, mask = l4).ne.(/ 1, 3 /))) call abort
  if (any (minloc (a, mask = l5).ne.(/ 1, 3 /))) call abort
end