idamax Function

public function idamax(n, dx, incx)

idamax finds the index of the first element having maximum absolute value.

Arguments

Type IntentOptional Attributes Name
integer(kind=ip) :: n
real(kind=wp) :: dx(*)
integer(kind=ip) :: incx

Return Value integer


Called by

proc~~idamax~~CalledByGraph proc~idamax idamax proc~dwnlit dwnlit proc~dwnlit->proc~idamax proc~dwnlt1 dwnlt1 proc~dwnlit->proc~dwnlt1 proc~dwnlsm dwnlsm proc~dwnlsm->proc~idamax proc~dwnlsm->proc~dwnlit proc~dwnlt1->proc~idamax proc~dwnnls dwnnls proc~dwnnls->proc~dwnlsm proc~dlpdp dlpdp proc~dlpdp->proc~dwnnls proc~dlsi dlsi proc~dlsi->proc~dlpdp proc~dlsei dlsei proc~dlsei->proc~dlsi proc~dfcmn dfcmn proc~dfcmn->proc~dlsei proc~dfc dfc proc~dfc->proc~dfcmn

Source Code

   integer function idamax(n,dx,incx)
         !! idamax finds the index of the first element having maximum absolute value.

         integer(ip) :: incx,n
         real(wp) :: dx(*)

         real(wp) :: dmax
         integer(ip) :: i,ix

         idamax = 0
         if (n<1 .or. incx<=0) return
         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
                  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
                  idamax = i
                  dmax = abs(dx(ix))
               end if
               ix = ix + incx
            end do
         end if

   end function idamax