idamax(3f) - [M_odepack::matrix] Find the smallest index of that component of a vector having the maximum magnitude.
function idamax(n,dx,incx)
integer :: idamax
integer,intent(in) :: n
real(kind=dp),intent(in) :: dx(*)
integer , intent(in) :: incx
Find smallest index of maximum magnitude of double precision DX. IDAMAX = first I, I = 1 to N, to maximize ABS(DX(IX+(I-1)INCX)), where IX = 1 if INCX .GE. 0, else IX = 1+(1-N)INCX.
C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T. Krogh, Basic linear algebra subprograms for Fortran usage, Algorithm No. 539, Transactions on Mathematical Software 5, 3 (September 1979), pp. 308-323.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | N | |||
real(kind=dp), | intent(in) | :: | Dx(*) | |||
integer, | intent(in) | :: | Incx |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=dp), | public | :: | dmax | ||||
integer, | public | :: | i | ||||
integer, | public | :: | ix | ||||
real(kind=dp), | public | :: | xmag |
function idamax(N,Dx,Incx) ! integer :: idamax integer,intent(in) :: N real(kind=dp),intent(in) :: Dx(*) integer,intent(in) :: Incx ! real(kind=dp) :: dmax , xmag integer :: i , ix ! idamax = 0 if (n .le. 0) return idamax = 1 if (n .eq. 1) return if (incx .ne. 1) then ! ! Code for increments not equal to 1. ! ix = 1 if (incx .lt. 0) ix = (-n+1)*incx + 1 dmax = abs(dx(ix)) ix = ix + incx do i = 2,n xmag = abs(dx(ix)) if (xmag .gt. dmax) then idamax = i dmax = xmag endif ix = ix + incx enddo else ! ! Code for increments equal to 1. ! dmax = abs(dx(1)) do i = 2,n xmag = abs(dx(i)) if (xmag .gt. dmax) then idamax = i dmax = xmag endif enddo endif end function idamax