icamax(3f) -- [BLAS:AUX_BLAS] Return index of maximum "absolute value" in CX.
integer function icamax(n,cx,incx)
.. scalar arguments ..
integer,intent(in) :: incx,n
..
.. array arguments ..
complex,intent(in) :: cx(*)
..
ICAMAX finds the index of the first element having maximum |Re(.)| + |Im(.)|
N
N is INTEGER
number of elements in input vector(s)
CX
CX is COMPLEX array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
INCX
INCX is INTEGER
storage spacing between elements of CX
date:November 2017
FURTHER DETAILS
jack dongarra, linpack, 3/11/78.
modified 3/93 to return if incx .le. 0.
modified 12/3/93, array(1) declarations changed to array(*)
Online html documentation available at
http://www.netlib.org/lapack/explore-html/
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
complex, | intent(in) | :: | cx(*) | |||
integer, | intent(in) | :: | incx |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | i | ||||
integer, | public | :: | ix | ||||
real, | public | :: | smax |
pure integer function icamax(n,cx,incx)
implicit none
!
! -- Reference BLAS level1 routine (version 3.8.0) --
! -- Reference BLAS is a software package provided by Univ. of Tennessee, --
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! November 2017
!
! .. Scalar Arguments ..
integer,intent(in) :: incx,n
! ..
! .. Array Arguments ..
complex,intent(in) :: cx(*)
! ..
! =====================================================================
! .. Local Scalars ..
real smax
integer i,ix
! ..
! .. External Functions .. REAL SCABS1
! ..
icamax = 0
if (n.lt.1 .or. incx.le.0) return
icamax = 1
if (n.eq.1) return
if (incx.eq.1) then
!
! code for increment equal to 1
!
smax = scabs1(cx(1))
do i = 2,n
if (scabs1(cx(i)).gt.smax) then
icamax = i
smax = scabs1(cx(i))
endif
enddo
else
!
! code for increment not equal to 1
!
ix = 1
smax = scabs1(cx(1))
ix = ix + incx
do i = 2,n
if (scabs1(cx(ix)).gt.smax) then
icamax = i
smax = scabs1(cx(ix))
endif
ix = ix + incx
enddo
endif
end function icamax