Index of maximum element of vector

ISMAX/IDMAX/IIMAX

Name

ISMAX/IDMAX/IIMAX

 

 

Index of maximum element of vector

 

Purpose Given a real or integer vector x of length n, these subprograms determine the index of the maximum element of the vector. Specifically, the subprograms determine the smallest index i such that

xi = max ( x j : j = 1, 2, …, n)

The vector can be stored in a one-dimensional array or in either a row or a column of a two-dimensional array.

Usage

VECLIB:

 

 

INTEGER*4

i, ISMAX, n, incx

 

REAL*4

x(lenx)

 

i = ISMAX(n, x, incx)

 

INTEGER*4

i, IDMAX, n, incx

 

REAL*8

x(lenx)

 

i = IDMAX(n, x, incx)

 

INTEGER*4

i, IIMAX, n, incx, x(lenx)

 

i = IIMAX(n, x, incx)

 

VECLIB8:

 

 

INTEGER*8

i, ISMAX, n, incx

 

REAL*4

x(lenx)

 

i = ISMAX(n, x, incx)

 

INTEGER*8

i, IDMAX, n, incx

 

REAL*8

x(lenx)

 

i = IDMAX(n, x, incx)

 

INTEGER*8

i, IIMAX, n, incx, x(lenx)

 

i = IIMAX(n, x, incx)

Input

n

Number of elements of vector x to be used. If n ≤ 0, the

 

 

subprograms do not reference x.

 

x

Array of length lenx = (n−1)⋅incx+1 containing the

 

 

n-vector x.

 

incx

Increment for the array x. x is stored forward in array x

 

 

with increment incx; that is, xi is stored in

 

 

x((i−1)⋅incx+1).

Chapter 2 Basic Vector Operations 49