ISAMAX finds the index of the first element having maximum absolute value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ilp), | intent(in) | :: | n | |||
real(kind=sp), | intent(in) | :: | sx(*) | |||
integer(kind=ilp), | intent(in) | :: | incx |
pure integer(ilp) function stdlib_isamax(n,sx,incx) !! ISAMAX finds the index of the first element having maximum absolute value. ! -- reference blas level1 routine -- ! -- reference blas is a software package provided by univ. of tennessee, -- ! -- univ. of california berkeley, univ. of colorado denver and nag ltd..-- ! Scalar Arguments integer(ilp), intent(in) :: incx, n ! Array Arguments real(sp), intent(in) :: sx(*) ! ===================================================================== ! Local Scalars real(sp) :: smax integer(ilp) :: i, ix ! Intrinsic Functions intrinsic :: abs stdlib_isamax = 0 if (n<1 .or. incx<=0) return stdlib_isamax = 1 if (n==1) return if (incx==1) then ! code for increment equal to 1 smax = abs(sx(1)) do i = 2,n if (abs(sx(i))>smax) then stdlib_isamax = i smax = abs(sx(i)) end if end do else ! code for increment not equal to 1 ix = 1 smax = abs(sx(1)) ix = ix + incx do i = 2,n if (abs(sx(ix))>smax) then stdlib_isamax = i smax = abs(sx(ix)) end if ix = ix + incx end do end if return end function stdlib_isamax