isamax Function

public function isamax(n, sx, incx)

NAME

isamax(3f) - [BLAS:AUX_BLAS] Return index of maximum absolute value in SX.

SYNOPSIS

 integer function isamax(n,sx,incx)

   .. Scalar Arguments ..
   integer,intent(in) :: incx,n
   ..
   .. Array Arguments ..
   real,intent(in) :: sx(*)
   ..

DEFINITION

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

OPTIONS

N

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

SX

       SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )

INCX

       INCX is INTEGER
      storage spacing between elements of SX

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
real, intent(in) :: sx(*)
integer, intent(in) :: incx

Return Value integer


Contents

Source Code


Variables

Type Visibility Attributes Name Initial
integer, public :: i
integer, public :: ix
real, public :: smax

Source Code

integer function isamax(n,sx,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 ..
      real,intent(in) :: sx(*)
!     ..
!  =====================================================================
!     .. Local Scalars ..
      real smax
      integer i,ix
!     ..
!     .. Intrinsic Functions ..
      intrinsic abs
!     ..
      isamax = 0
      if (n.lt.1 .or. incx.le.0) return
      isamax = 1
      if (n.eq.1) return
      if (incx.eq.1) then
!
!        code for increment equal to 1
!
         smax = abs(sx(1))
         do i = 2,n
            if (abs(sx(i)).gt.smax) then
               isamax = i
               smax = abs(sx(i))
            endif
         enddo
      else
!
!        code for increment not equal to 1
!
         ix = 1
         smax = abs(sx(1))
         ix = ix + incx
         do i = 2,n
            if (abs(sx(ix)).gt.smax) then
               isamax = i
               smax = abs(sx(ix))
            endif
            ix = ix + incx
         enddo
      endif

end function isamax