2 INTEGER FUNCTION IDAMAX
(N
, DX
, INCX
)
3 C***BEGIN PROLOGUE IDAMAX
4 C***PURPOSE Find the smallest index of that component of a vector
5 C having the maximum magnitude.
7 C***TYPE DOUBLE PRECISION (ISAMAX-S, IDAMAX-D, ICAMAX-C)
8 C***KEYWORDS BLAS, LINEAR ALGEBRA, MAXIMUM COMPONENT, VECTOR
9 C***AUTHOR Lawson, C. L., (JPL)
10 C Hanson, R. J., (SNLA)
11 C Kincaid, D. R., (U. of Texas)
16 C Description of Parameters
19 C N number of elements in input vector(s)
20 C DX double precision vector with N elements
21 C INCX storage spacing between elements of DX
24 C IDAMAX smallest index (zero if N .LE. 0)
26 C Find smallest index of maximum magnitude of double precision DX.
27 C IDAMAX = first I, I = 1 to N, to maximize ABS(DX(IX+(I-1)*INCX)),
28 C where IX = 1 if INCX .GE. 0, else IX = 1+(1-N)*INCX.
30 C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
31 C Krogh, Basic linear algebra subprograms for Fortran
32 C usage, Algorithm No. 539, Transactions on Mathematical
33 C Software 5, 3 (September 1979), pp. 308-323.
34 C***ROUTINES CALLED (NONE)
35 C***REVISION HISTORY (YYMMDD)
37 C 890531 Changed all specific intrinsics to generic. (WRB)
38 C 890531 REVISION DATE from Version 3.2
39 C 891214 Prologue converted to Version 4.0 format. (BAB)
40 C 900821 Modified to correct problem with a negative increment.
42 C 920501 Reformatted the REFERENCES section. (WRB)
43 C***END PROLOGUE IDAMAX
44 DOUBLE PRECISION DX
(*), DMAX
, XMAG
45 INTEGER I
, INCX
, IX
, N
46 C***FIRST EXECUTABLE STATEMENT IDAMAX
52 IF (INCX
.EQ
. 1) GOTO 20
54 C Code for increments not equal to 1.
57 IF (INCX
.LT
. 0) IX
= (-N
+1)*INCX
+ 1
62 IF (XMAG
.GT
. DMAX
) THEN
70 C Code for increments equal to 1.
75 IF (XMAG
.GT
. DMAX
) THEN