idamax Function

public pure function idamax(n, dx, incx)

NAME

idamax(3f) - [BLAS:AUX_BLAS]

SYNOPSIS

 integer function idamax(n,dx,incx)

   .. Scalar Arguments ..
   integer,intent(in)          :: incx,n
   ..
   .. Array Arguments ..
   double precision,intent(in) :: dx(*)
   ..

DEFINITION

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

OPTIONS

N

       N is INTEGER
      number of elements in input vector(s)

DX

       DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )

INCX

       INCX is INTEGER
      storage spacing between elements of DX

AUTHORS

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

date:November 2017

FURTHER DETAILS

  jack dongarra, linpack, 3/11/78.
  modified 3/93 to return if incx .le. 0.
  modified 12/3/93, array(1) declarations changed to array(*)

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
double precision, intent(in) :: dx(*)
integer, intent(in) :: incx

Return Value integer


Contents

Source Code


Variables

Type Visibility Attributes Name Initial
double precision, public :: dmax
integer, public :: i
integer, public :: ix

Source Code

pure integer function idamax(n,dx,incx)
      implicit none
!
!  -- Reference BLAS level1 routine (version 3.8.0) --
!  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
!  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
!     November 2017
!
!     .. Scalar Arguments ..
      integer,intent(in)          :: incx,n
!     ..
!     .. Array Arguments ..
      double precision,intent(in) :: dx(*)
!     ..
!  =====================================================================
!     .. Local Scalars ..
      double precision dmax
      integer i,ix
!     ..
!     .. Intrinsic Functions ..
      intrinsic dabs
!     ..
      idamax = 0
      if (n.lt.1 .or. incx.le.0) return
      idamax = 1
      if (n.eq.1) return
      if (incx.eq.1) then
!
!        code for increment equal to 1
!
         dmax = dabs(dx(1))
         do i = 2,n
            if (dabs(dx(i)).gt.dmax) then
               idamax = i
               dmax = dabs(dx(i))
            endif
         enddo
      else
!
!        code for increment not equal to 1
!
         ix = 1
         dmax = dabs(dx(1))
         ix = ix + incx
         do i = 2,n
            if (dabs(dx(ix)).gt.dmax) then
               idamax = i
               dmax = dabs(dx(ix))
            endif
            ix = ix + incx
         enddo
      endif

end function idamax