IDAMAX finds the index of the first element having maximum absolute value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ilp), | intent(in) | :: | n | |||
real(kind=dp), | intent(in) | :: | dx(*) | |||
integer(kind=ilp), | intent(in) | :: | incx |
pure integer(ilp) function stdlib_idamax(n,dx,incx) !! IDAMAX 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(dp), intent(in) :: dx(*) ! ===================================================================== ! Local Scalars real(dp) :: dmax integer(ilp) :: i, ix ! Intrinsic Functions intrinsic :: abs stdlib_idamax = 0 if (n<1 .or. incx<=0) return stdlib_idamax = 1 if (n==1) return if (incx==1) then ! code for increment equal to 1 dmax = abs(dx(1)) do i = 2,n if (abs(dx(i))>dmax) then stdlib_idamax = i dmax = abs(dx(i)) end if end do else ! code for increment not equal to 1 ix = 1 dmax = abs(dx(1)) ix = ix + incx do i = 2,n if (abs(dx(ix))>dmax) then stdlib_idamax = i dmax = abs(dx(ix)) end if ix = ix + incx end do end if return end function stdlib_idamax