stdlib_izamax Function

public pure function stdlib_izamax(n, zx, incx)

IZAMAX finds the index of the first element having maximum |Re(.)| + |Im(.)|

Arguments

Type IntentOptional Attributes Name
integer(kind=ilp), intent(in) :: n
complex(kind=dp), intent(in) :: zx(*)
integer(kind=ilp), intent(in) :: incx

Return Value integer(kind=ilp)


Source Code

     pure integer(ilp) function stdlib_izamax(n,zx,incx)
     !! IZAMAX finds the index of the first element having maximum |Re(.)| + |Im(.)|
        ! -- 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 
           complex(dp), intent(in) :: zx(*)
        ! =====================================================================
           ! Local Scalars 
           real(dp) :: dmax
           integer(ilp) :: i, ix
           stdlib_izamax = 0
           if (n<1 .or. incx<=0) return
           stdlib_izamax = 1
           if (n==1) return
           if (incx==1) then
              ! code for increment equal to 1
              dmax = stdlib_dcabs1(zx(1))
              do i = 2,n
                 if (stdlib_dcabs1(zx(i))>dmax) then
                    stdlib_izamax = i
                    dmax = stdlib_dcabs1(zx(i))
                 end if
              end do
           else
              ! code for increment not equal to 1
              ix = 1
              dmax = stdlib_dcabs1(zx(1))
              ix = ix + incx
              do i = 2,n
                 if (stdlib_dcabs1(zx(ix))>dmax) then
                    stdlib_izamax = i
                    dmax = stdlib_dcabs1(zx(ix))
                 end if
                 ix = ix + incx
              end do
           end if
           return
     end function stdlib_izamax