I{S,D,C,Z}AMAX (n, x, incx)
imax: integer*4 The index of the element of the vector x that is the largest in absolute value of all elements of the vector. If n<=0, imax returns the value 0.
n integer*4 On entry, the number of elements in the vector x. On exit, n is unchanged. x real*4 | real*8 | complex*8 | complex*16 On entry, a one-dimensional array X of length at least (1+(n-1)*|incx|), containing the elements of the vector x. On exit, x is unchanged. incx integer*4 On entry, the increment for the array X. If incx >= 0, vector x is stored forward in the array, so that x(i) is stored in location X(1+(i-1)*incx). If incx < 0, vector x is stored backward in the array, so that x(i) is stored in location X(1+(n-i)*|incx|). On exit, incx is unchanged.
These functions determine the first integer i among the elements of the vector x such that: |x(i)| = MAX{|x(j)|, j = 1,2, ...,n} You can use these functions to obtain the pivots in Gaussian elimination. For complex vectors, each element of the vector is a complex number. In these subprograms, the absolute value of a complex number is defined as the absolute value of the real part plus the absolute value of the imaginary part: |x(j)| = |a(j)| + |b(j)| = |real| + |imaginary| If incx < 0, the result depends on how the program is processed. See the coding information in this document for a discussion of the possible results. If incx = 0, the computation is a time-consuming way of setting imax = 1.
INTEGER*4 IMAX, N, INCX REAL*4 X(40) INCX = 2 N = 20 IMAX = ISAMAX(N,X,INCX) This FORTRAN code shows how to compute the index of a real vector element with maximum absolute value.