Skip to content

Commit 0ab775d

Browse files
Merge branch 'master' into implement-axpby
2 parents 506f2b3 + 52a9434 commit 0ab775d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1234
-693
lines changed

BLAS/SRC/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
set(SBLAS1 isamax.f sasum.f saxpy.f saxpby.f scopy.f sdot.f snrm2.f90
3333
srot.f srotg.f90 sscal.f sswap.f sdsdot.f srotmg.f srotm.f)
3434

35-
set(CBLAS1 scabs1.f scasum.f scnrm2.f90 icamax.f caxpy.f caxpby.f ccopy.f
35+
set(CBLAS1 scabs1.f scasum.f scnrm2.f90 icamax.f90 caxpy.f caxpby.f ccopy.f
36+
set(CBLAS1 scabs1.f scasum.f scnrm2.f90 icamax.f90 caxpy.f ccopy.f
3637
cdotc.f cdotu.f csscal.f crotg.f90 cscal.f cswap.f csrot.f)
3738

3839
set(DBLAS1 idamax.f dasum.f daxpy.f daxpby.f dcopy.f ddot.f dnrm2.f90
3940
drot.f drotg.f90 dscal.f dsdot.f dswap.f drotmg.f drotm.f)
4041

4142
set(DB1AUX sscal.f isamax.f)
4243

43-
set(ZBLAS1 dcabs1.f dzasum.f dznrm2.f90 izamax.f zaxpy.f zaxpby.f zcopy.f
44+
set(ZBLAS1 dcabs1.f dzasum.f dznrm2.f90 izamax.f90 zaxpy.f zaxpby.f zcopy.f
4445
zdotc.f zdotu.f zdscal.f zrotg.f90 zscal.f zswap.f zdrot.f)
4546

4647
set(CB1AUX
@@ -49,7 +50,7 @@ set(CB1AUX
4950
sswap.f)
5051

5152
set(ZB1AUX
52-
icamax.f idamax.f
53+
icamax.f90 idamax.f
5354
cgemm.f cherk.f cscal.f ctrsm.f
5455
dasum.f daxpy.f dcopy.f ddot.f dgemm.f dgemv.f dnrm2.f90 drot.f dscal.f
5556
dswap.f
File renamed without changes.
File renamed without changes.

BLAS/SRC/dnrm2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function DNRM2( n, x, incx )
8989
integer, parameter :: wp = kind(1.d0)
9090
real(wp) :: DNRM2
9191
!
92-
! -- Reference BLAS level1 routine (version 3.9.1) --
92+
! -- Reference BLAS level1 routine --
9393
! -- Reference BLAS is a software package provided by Univ. of Tennessee, --
9494
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
9595
! March 2021

BLAS/SRC/dznrm2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function DZNRM2( n, x, incx )
9090
integer, parameter :: wp = kind(1.d0)
9191
real(wp) :: DZNRM2
9292
!
93-
! -- Reference BLAS level1 routine (version 3.9.1) --
93+
! -- Reference BLAS level1 routine --
9494
! -- Reference BLAS is a software package provided by Univ. of Tennessee, --
9595
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
9696
! March 2021

BLAS/SRC/icamax.f90

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
!> \brief \b ICAMAX
2+
!
3+
! =========== DOCUMENTATION ===========
4+
!
5+
! Online html documentation available at
6+
! http://www.netlib.org/lapack/explore-html/
7+
!
8+
! Definition:
9+
! ===========
10+
!
11+
! INTEGER FUNCTION ICAMAX(N,X,INCX)
12+
!
13+
! .. Scalar Arguments ..
14+
! INTEGER INCX,N
15+
! ..
16+
! .. Array Arguments ..
17+
! COMPLEX X(*)
18+
! ..
19+
!
20+
!
21+
!> \par Purpose:
22+
! =============
23+
!>
24+
!> \verbatim
25+
!>
26+
!> ICAMAX finds the index of the first element having maximum |Re(.)| + |Im(.)|
27+
!> \endverbatim
28+
!
29+
! Arguments:
30+
! ==========
31+
!
32+
!> \param[in] N
33+
!> \verbatim
34+
!> N is INTEGER
35+
!> number of elements in input vector(s)
36+
!> \endverbatim
37+
!>
38+
!> \param[in] X
39+
!> \verbatim
40+
!> X is COMPLEX array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
41+
!> \endverbatim
42+
!>
43+
!> \param[in] INCX
44+
!> \verbatim
45+
!> INCX is INTEGER
46+
!> storage spacing between elements of X
47+
!> \endverbatim
48+
!
49+
! Authors:
50+
! ========
51+
!
52+
!> James Demmel, University of California Berkeley, USA
53+
!> Weslley Pereira, National Renewable Energy Laboratory, USA
54+
!
55+
!> \ingroup iamax
56+
!
57+
!> \par Further Details:
58+
! =====================
59+
!>
60+
!> \verbatim
61+
!>
62+
!> James Demmel et al. Proposed Consistent Exception Handling for the BLAS and
63+
!> LAPACK, 2022 (https://arxiv.org/abs/2207.09281).
64+
!>
65+
!> \endverbatim
66+
!>
67+
! =====================================================================
68+
integer function icamax(n, x, incx)
69+
integer, parameter :: wp = kind(1.e0)
70+
!
71+
! -- Reference BLAS level1 routine --
72+
! -- Reference BLAS is a software package provided by Univ. of Tennessee, --
73+
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
74+
!
75+
! .. Constants ..
76+
real(wp), parameter :: hugeval = huge(0.0_wp)
77+
!
78+
! .. Scalar Arguments ..
79+
integer :: n, incx
80+
!
81+
! .. Array Arguments ..
82+
complex(wp) :: x(*)
83+
! ..
84+
! .. Local Scalars ..
85+
integer :: i, j, ix, jx
86+
real(wp) :: val, smax
87+
logical :: scaledsmax
88+
!
89+
! Quick return if possible
90+
!
91+
icamax = 0
92+
if (n < 1 .or. incx < 1) return
93+
!
94+
icamax = 1
95+
if (n == 1) return
96+
!
97+
icamax = 0
98+
scaledsmax = .false.
99+
smax = -1
100+
!
101+
! scaledsmax = .true. indicates that x(icamax) is finite but
102+
! abs(real(x(icamax))) + abs(imag(x(icamax))) overflows
103+
!
104+
if (incx == 1) then
105+
! code for increment equal to 1
106+
do i = 1, n
107+
if (x(i) /= x(i)) then
108+
! return when first NaN found
109+
icamax = i
110+
return
111+
elseif (abs(real(x(i))) > hugeval .or. abs(imag(x(i))) > hugeval) then
112+
! keep looking for first NaN
113+
do j = i+1, n
114+
if (x(j) /= x(j)) then
115+
! return when first NaN found
116+
icamax = j
117+
return
118+
endif
119+
enddo
120+
! record location of first Inf
121+
icamax = i
122+
return
123+
else ! still no Inf found yet
124+
if (.not. scaledsmax) then
125+
! no abs(real(x(i))) + abs(imag(x(i))) = Inf yet
126+
val = abs(real(x(i))) + abs(imag(x(i)))
127+
if (val > hugeval) then
128+
scaledsmax = .true.
129+
smax = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
130+
icamax = i
131+
elseif (val > smax) then ! everything finite so far
132+
smax = val
133+
icamax = i
134+
endif
135+
else ! scaledsmax
136+
val = 0.25*abs(real(x(i))) + 0.25*abs(imag(x(i)))
137+
if (val > smax) then
138+
smax = val
139+
icamax = i
140+
endif
141+
endif
142+
endif
143+
end do
144+
else
145+
! code for increment not equal to 1
146+
ix = 1
147+
do i = 1, n
148+
if (x(ix) /= x(ix)) then
149+
! return when first NaN found
150+
icamax = i
151+
return
152+
elseif (abs(real(x(ix))) > hugeval .or. abs(imag(x(ix))) > hugeval) then
153+
! keep looking for first NaN
154+
jx = ix + incx
155+
do j = i+1, n
156+
if (x(jx) /= x(jx)) then
157+
! return when first NaN found
158+
icamax = j
159+
return
160+
endif
161+
jx = jx + incx
162+
enddo
163+
! record location of first Inf
164+
icamax = i
165+
return
166+
else ! still no Inf found yet
167+
if (.not. scaledsmax) then
168+
! no abs(real(x(ix))) + abs(imag(x(ix))) = Inf yet
169+
val = abs(real(x(ix))) + abs(imag(x(ix)))
170+
if (val > hugeval) then
171+
scaledsmax = .true.
172+
smax = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
173+
icamax = i
174+
elseif (val > smax) then ! everything finite so far
175+
smax = val
176+
icamax = i
177+
endif
178+
else ! scaledsmax
179+
val = 0.25*abs(real(x(ix))) + 0.25*abs(imag(x(ix)))
180+
if (val > smax) then
181+
smax = val
182+
icamax = i
183+
endif
184+
endif
185+
endif
186+
ix = ix + incx
187+
end do
188+
endif
189+
end

0 commit comments

Comments
 (0)