2
INTEGER FUNCTION ISAMAX (N, SX, INCX)
3
C***BEGIN PROLOGUE ISAMAX
4
C***PURPOSE Find the smallest index of that component of a vector
5
C having the maximum magnitude.
6
C***LIBRARY SLATEC (BLAS)
8
C***TYPE SINGLE PRECISION (ISAMAX-S, IDAMAX-D, ICAMAX-C)
9
C***KEYWORDS BLAS, LINEAR ALGEBRA, MAXIMUM COMPONENT, VECTOR
10
C***AUTHOR Lawson, C. L., (JPL)
11
C Hanson, R. J., (SNLA)
12
C Kincaid, D. R., (U. of Texas)
17
C Description of Parameters
20
C N number of elements in input vector(s)
21
C SX single precision vector with N elements
22
C INCX storage spacing between elements of SX
25
C ISAMAX smallest index (zero if N .LE. 0)
27
C Find smallest index of maximum magnitude of single precision SX.
28
C ISAMAX = first I, I = 1 to N, to maximize ABS(SX(IX+(I-1)*INCX)),
29
C where IX = 1 if INCX .GE. 0, else IX = 1+(1-N)*INCX.
31
C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
32
C Krogh, Basic linear algebra subprograms for Fortran
33
C usage, Algorithm No. 539, Transactions on Mathematical
34
C Software 5, 3 (September 1979), pp. 308-323.
35
C***ROUTINES CALLED (NONE)
36
C***REVISION HISTORY (YYMMDD)
38
C 861211 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 920618 Slight restructuring of code. (RWC, WRB)
44
C***END PROLOGUE ISAMAX
45
REAL SX(*), SMAX, XMAG
46
INTEGER I, INCX, IX, N
47
C***FIRST EXECUTABLE STATEMENT ISAMAX
53
IF (INCX .EQ. 1) GOTO 20
55
C Code for increment not equal to 1.
58
IF (INCX .LT. 0) IX = (-N+1)*INCX + 1
63
IF (XMAG .GT. SMAX) THEN
71
C Code for increments equal to 1.
76
IF (XMAG .GT. SMAX) THEN