Skip to content

Commit d70c8c0

Browse files
author
Weslley da Silva Pereira
committed
Improvements following @angsch's review
1 parent e338bb8 commit d70c8c0

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

BLAS/SRC/icamax.f90

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ integer function icamax(n, x, incx)
8383
! ..
8484
! .. Local Scalars ..
8585
integer :: i, j, ix, jx
86-
real(wp) :: val, smax, scaledsmax
86+
real(wp) :: val, smax
87+
logical :: scaledsmax
8788
!
8889
! Quick return if possible
8990
!
@@ -94,11 +95,11 @@ integer function icamax(n, x, incx)
9495
if (n == 1) return
9596
!
9697
icamax = 0
97-
scaledsmax = 0
98+
scaledsmax = .false.
9899
smax = -1
99100
!
100-
! scaledsmax = 1 indicates that x(i) finite but
101-
! abs(real(x(i))) + abs(imag(x(i))) is not finite
101+
! scaledsmax = .true. indicates that x(icamax) is finite but
102+
! abs(real(x(icamax))) + abs(imag(x(icamax))) overflows
102103
!
103104
if (incx == 1) then
104105
! code for increment equal to 1
@@ -120,18 +121,18 @@ integer function icamax(n, x, incx)
120121
icamax = i
121122
return
122123
else ! still no Inf found yet
123-
if (scaledsmax == 0) then
124+
if (.not. scaledsmax) then
124125
! no abs(real(x(i))) + abs(imag(x(i))) = Inf yet
125126
val = abs(real(x(i))) + abs(imag(x(i)))
126-
if (abs(val) > hugeval) then
127-
scaledsmax = 1
127+
if (val > hugeval) then
128+
scaledsmax = .true.
128129
smax = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
129130
icamax = i
130131
elseif (val > smax) then ! everything finite so far
131132
smax = val
132133
icamax = i
133134
endif
134-
else ! scaledsmax = 1
135+
else ! scaledsmax
135136
val = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
136137
if (val > smax) then
137138
smax = val
@@ -163,18 +164,18 @@ integer function icamax(n, x, incx)
163164
icamax = i
164165
return
165166
else ! still no Inf found yet
166-
if (scaledsmax == 0) then
167+
if (.not. scaledsmax) then
167168
! no abs(real(x(ix))) + abs(imag(x(ix))) = Inf yet
168169
val = abs(real(x(ix))) + abs(imag(x(ix)))
169-
if (abs(val) > hugeval) then
170-
scaledsmax = 1
170+
if (val > hugeval) then
171+
scaledsmax = .true.
171172
smax = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
172173
icamax = i
173174
elseif (val > smax) then ! everything finite so far
174175
smax = val
175176
icamax = i
176177
endif
177-
else ! scaledsmax = 1
178+
else ! scaledsmax
178179
val = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
179180
if (val > smax) then
180181
smax = val

BLAS/SRC/izamax.f90

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ integer function izamax(n, x, incx)
8383
! ..
8484
! .. Local Scalars ..
8585
integer :: i, j, ix, jx
86-
real(wp) :: val, smax, scaledsmax
86+
real(wp) :: val, smax
87+
logical :: scaledsmax
8788
!
8889
! Quick return if possible
8990
!
@@ -94,11 +95,11 @@ integer function izamax(n, x, incx)
9495
if (n == 1) return
9596
!
9697
izamax = 0
97-
scaledsmax = 0
98+
scaledsmax = .false.
9899
smax = -1
99100
!
100-
! scaledsmax = 1 indicates that x(i) finite but
101-
! abs(real(x(i))) + abs(imag(x(i))) is not finite
101+
! scaledsmax = .true. indicates that x(izamax) is finite but
102+
! abs(real(x(izamax))) + abs(imag(x(izamax))) overflows
102103
!
103104
if (incx == 1) then
104105
! code for increment equal to 1
@@ -120,18 +121,18 @@ integer function izamax(n, x, incx)
120121
izamax = i
121122
return
122123
else ! still no Inf found yet
123-
if (scaledsmax == 0) then
124+
if (.not. scaledsmax) then
124125
! no abs(real(x(i))) + abs(imag(x(i))) = Inf yet
125126
val = abs(real(x(i))) + abs(imag(x(i)))
126-
if (abs(val) > hugeval) then
127-
scaledsmax = 1
127+
if (val > hugeval) then
128+
scaledsmax = .true.
128129
smax = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
129130
izamax = i
130131
elseif (val > smax) then ! everything finite so far
131132
smax = val
132133
izamax = i
133134
endif
134-
else ! scaledsmax = 1
135+
else ! scaledsmax
135136
val = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
136137
if (val > smax) then
137138
smax = val
@@ -163,18 +164,18 @@ integer function izamax(n, x, incx)
163164
izamax = i
164165
return
165166
else ! still no Inf found yet
166-
if (scaledsmax == 0) then
167+
if (.not. scaledsmax) then
167168
! no abs(real(x(ix))) + abs(imag(x(ix))) = Inf yet
168169
val = abs(real(x(ix))) + abs(imag(x(ix)))
169-
if (abs(val) > hugeval) then
170-
scaledsmax = 1
170+
if (val > hugeval) then
171+
scaledsmax = .true.
171172
smax = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
172173
izamax = i
173174
elseif (val > smax) then ! everything finite so far
174175
smax = val
175176
izamax = i
176177
endif
177-
else ! scaledsmax = 1
178+
else ! scaledsmax
178179
val = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
179180
if (val > smax) then
180181
smax = val

0 commit comments

Comments
 (0)