idamax(3f) - [BLAS:AUX_BLAS]
integer function idamax(n,dx,incx)
.. Scalar Arguments ..
integer,intent(in) :: incx,n
..
.. Array Arguments ..
double precision,intent(in) :: dx(*)
..
IDAMAX finds the index of the first element having maximum absolute value.
N
N is INTEGER
number of elements in input vector(s)
DX
DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
INCX
INCX is INTEGER
storage spacing between elements of DX
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 | |||
double precision, | intent(in) | :: | dx(*) | |||
integer, | intent(in) | :: | incx |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
double precision, | public | :: | dmax | ||||
integer, | public | :: | i | ||||
integer, | public | :: | ix |
pure integer function idamax(n,dx,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 ..
double precision,intent(in) :: dx(*)
! ..
! =====================================================================
! .. Local Scalars ..
double precision dmax
integer i,ix
! ..
! .. Intrinsic Functions ..
intrinsic dabs
! ..
idamax = 0
if (n.lt.1 .or. incx.le.0) return
idamax = 1
if (n.eq.1) return
if (incx.eq.1) then
!
! code for increment equal to 1
!
dmax = dabs(dx(1))
do i = 2,n
if (dabs(dx(i)).gt.dmax) then
idamax = i
dmax = dabs(dx(i))
endif
enddo
else
!
! code for increment not equal to 1
!
ix = 1
dmax = dabs(dx(1))
ix = ix + incx
do i = 2,n
if (dabs(dx(ix)).gt.dmax) then
idamax = i
dmax = dabs(dx(ix))
endif
ix = ix + incx
enddo
endif
end function idamax