Previous Next Contents Generated Index Doc Set Home



Index of Element with Maximum Absolute Value

IDAMAX and ISAMAX return the smallest index i where

which is the l-norm of a vector x.

IZAMAX and ICAMAX return the smallest index i where

Note that this does not return an index i such that

which is the l-norm for a complex vector.

Note also that the FORTRAN interfaces return an index based at one while the C interfaces return an index based at zero. This is in keeping with the convention of each language in which the first element of a FORTRAN array is usually 1 and the first element of a C array is 0.

Calling Sequence

I = IDAMAX (N, DX, INCX)
I = ISAMAX (N, SX, INCX)
I = IZAMAX (N, ZX, INCX)
I = ICAMAX (N, CX, INCX)



int idamax (int n, double *dx, int incx)
int isamax (int n, float *sx, int incx)
int izamax (int n, doublecomplex *zx, int incx)
int icamax (int n, complex *cx, int incx)

Arguments

N

Number of elements in the vector. N 0.

xX

Input vector X; the size of array X must be at least max(1,N*|INCX|).

INCX

Specifies the storage spacing between successive elements of the vector X. A value of one indicates that the elements of the vector are consecutive in memory. INCX > 0.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X then the elements of the vector will be a row of X.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X plus one then the elements of the vector will be a diagonal of X.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER    N
      PARAMETER (N = 5)
C
      COMPLEX    X(N)
      INTEGER    I, ILARGE, INCX
C
      INTEGER    ICAMAX
      EXTERNAL   ICAMAX
C
C     Initialize the array X to store the vector x shown below.
C
C          5-4i
C         -3-2i
C     x =  5-4i
C          6+0i
C          0+8i
C
      DATA X / (5.0,-4.0), (-3.0,-2.0), (5.0,-4.0), (6.0,0.0),
     $         (0.0,8.0) /
C
      INCX = 1
      ILARGE = ICAMAX (N, X, INCX)
      PRINT 1000
      PRINT 1010, (X(I), I = 1, N)
      PRINT 1020, ILARGE
C
 1000 FORMAT (1X, 'x:')
 1010 FORMAT (3X, '(', F4.1, ',', F4.1, ')')
 1020 FORMAT (/1X, 'Largest element in the vector x is item ', I1)
C
      END
 

Sample Output

 
 x:
   ( 5.0,-4.0)
   (-3.0,-2.0)
   ( 5.0,-4.0)
   ( 6.0, 0.0)
   ( 0.0, 8.0)



 Largest element in the vector x is item 1






Previous Next Contents Generated Index Doc Set Home