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 bspline_blas_module::idamax proc~dwnlit bspline_defc_module::dwnlit proc~dwnlit->proc~idamax proc~dwnlt1 bspline_defc_module::dwnlt1 proc~dwnlit->proc~dwnlt1 proc~dwnlsm bspline_defc_module::dwnlsm proc~dwnlsm->proc~idamax proc~dwnlsm->proc~dwnlit proc~dwnlt1->proc~idamax proc~dwnnls bspline_defc_module::dwnnls proc~dwnnls->proc~dwnlsm proc~dlpdp bspline_defc_module::dlpdp proc~dlpdp->proc~dwnnls proc~dlsi bspline_defc_module::dlsi proc~dlsi->proc~dlpdp proc~dlsei bspline_defc_module::dlsei proc~dlsei->proc~dlsi proc~dfcmn bspline_defc_module::dfcmn proc~dfcmn->proc~dlsei proc~dfc bspline_defc_module::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