LAPACK  3.9.0
LAPACK: Linear Algebra PACKage
isamax.f
Go to the documentation of this file.
1 *> \brief \b ISAMAX
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * INTEGER FUNCTION ISAMAX(N,SX,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,N
15 * ..
16 * .. Array Arguments ..
17 * REAL SX(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> ISAMAX finds the index of the first element having maximum absolute value.
27 *> \endverbatim
28 *
29 * Arguments:
30 * ==========
31 *
32 *> \param[in] N
33 *> \verbatim
34 *> N is INTEGER
35 *> number of elements in input vector(s)
36 *> \endverbatim
37 *>
38 *> \param[in] SX
39 *> \verbatim
40 *> SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
41 *> \endverbatim
42 *>
43 *> \param[in] INCX
44 *> \verbatim
45 *> INCX is INTEGER
46 *> storage spacing between elements of SX
47 *> \endverbatim
48 *
49 * Authors:
50 * ========
51 *
52 *> \author Univ. of Tennessee
53 *> \author Univ. of California Berkeley
54 *> \author Univ. of Colorado Denver
55 *> \author NAG Ltd.
56 *
57 *> \date November 2017
58 *
59 *> \ingroup aux_blas
60 *
61 *> \par Further Details:
62 * =====================
63 *>
64 *> \verbatim
65 *>
66 *> jack dongarra, linpack, 3/11/78.
67 *> modified 3/93 to return if incx .le. 0.
68 *> modified 12/3/93, array(1) declarations changed to array(*)
69 *> \endverbatim
70 *>
71 * =====================================================================
72  INTEGER FUNCTION isamax(N,SX,INCX)
73 *
74 * -- Reference BLAS level1 routine (version 3.8.0) --
75 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
76 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
77 * November 2017
78 *
79 * .. Scalar Arguments ..
80  INTEGER incx,n
81 * ..
82 * .. Array Arguments ..
83  REAL sx(*)
84 * ..
85 *
86 * =====================================================================
87 *
88 * .. Local Scalars ..
89  REAL smax
90  INTEGER i,ix
91 * ..
92 * .. Intrinsic Functions ..
93  INTRINSIC abs
94 * ..
95  isamax = 0
96  IF (n.LT.1 .OR. incx.LE.0) RETURN
97  isamax = 1
98  IF (n.EQ.1) RETURN
99  IF (incx.EQ.1) THEN
100 *
101 * code for increment equal to 1
102 *
103  smax = abs(sx(1))
104  DO i = 2,n
105  IF (abs(sx(i)).GT.smax) THEN
106  isamax = i
107  smax = abs(sx(i))
108  END IF
109  END DO
110  ELSE
111 *
112 * code for increment not equal to 1
113 *
114  ix = 1
115  smax = abs(sx(1))
116  ix = ix + incx
117  DO i = 2,n
118  IF (abs(sx(ix)).GT.smax) THEN
119  isamax = i
120  smax = abs(sx(ix))
121  END IF
122  ix = ix + incx
123  END DO
124  END IF
125  RETURN
126  END
isamax
integer function isamax(N, SX, INCX)
ISAMAX
Definition: isamax.f:73