LAPACK  3.9.0 LAPACK: Linear Algebra PACKage
icmax1.f
Go to the documentation of this file.
1 *> \brief \b ICMAX1 finds the index of the first vector element of maximum absolute value.
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/icmax1.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/icmax1.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/icmax1.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * INTEGER FUNCTION ICMAX1( N, CX, INCX )
22 *
23 * .. Scalar Arguments ..
24 * INTEGER INCX, N
25 * ..
26 * .. Array Arguments ..
27 * COMPLEX CX( * )
28 * ..
29 *
30 *
31 *> \par Purpose:
32 * =============
33 *>
34 *> \verbatim
35 *>
36 *> ICMAX1 finds the index of the first vector element of maximum absolute value.
37 *>
38 *> Based on ICAMAX from Level 1 BLAS.
39 *> The change is to use the 'genuine' absolute value.
40 *> \endverbatim
41 *
42 * Arguments:
43 * ==========
44 *
45 *> \param[in] N
46 *> \verbatim
47 *> N is INTEGER
48 *> The number of elements in the vector CX.
49 *> \endverbatim
50 *>
51 *> \param[in] CX
52 *> \verbatim
53 *> CX is COMPLEX array, dimension (N)
54 *> The vector CX. The ICMAX1 function returns the index of its first
55 *> element of maximum absolute value.
56 *> \endverbatim
57 *>
58 *> \param[in] INCX
59 *> \verbatim
60 *> INCX is INTEGER
61 *> The spacing between successive values of CX. INCX >= 1.
62 *> \endverbatim
63 *
64 * Authors:
65 * ========
66 *
67 *> \author Univ. of Tennessee
68 *> \author Univ. of California Berkeley
69 *> \author Univ. of Colorado Denver
70 *> \author NAG Ltd.
71 *
72 *> \date February 2014
73 *
74 *> \ingroup complexOTHERauxiliary
75 *
76 *> \par Contributors:
77 * ==================
78 *>
79 *> Nick Higham for use with CLACON.
80 *
81 * =====================================================================
82  INTEGER FUNCTION icmax1( N, CX, INCX )
83 *
84 * -- LAPACK auxiliary routine (version 3.7.0) --
85 * -- LAPACK is a software package provided by Univ. of Tennessee, --
86 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
87 * February 2014
88 *
89 * .. Scalar Arguments ..
90  INTEGER incx, n
91 * ..
92 * .. Array Arguments ..
93  COMPLEX cx(*)
94 * ..
95 *
96 * =====================================================================
97 *
98 * .. Local Scalars ..
99  REAL smax
100  INTEGER i, ix
101 * ..
102 * .. Intrinsic Functions ..
103  INTRINSIC abs
104 * ..
105 * .. Executable Statements ..
106 *
107  icmax1 = 0
108  IF (n.LT.1 .OR. incx.LE.0) RETURN
109  icmax1 = 1
110  IF (n.EQ.1) RETURN
111  IF (incx.EQ.1) THEN
112 *
113 * code for increment equal to 1
114 *
115  smax = abs(cx(1))
116  DO i = 2,n
117  IF (abs(cx(i)).GT.smax) THEN
118  icmax1 = i
119  smax = abs(cx(i))
120  END IF
121  END DO
122  ELSE
123 *
124 * code for increment not equal to 1
125 *
126  ix = 1
127  smax = abs(cx(1))
128  ix = ix + incx
129  DO i = 2,n
130  IF (abs(cx(ix)).GT.smax) THEN
131  icmax1 = i
132  smax = abs(cx(ix))
133  END IF
134  ix = ix + incx
135  END DO
136  END IF
137  RETURN
138 *
139 * End of ICMAX1
140 *
141  END
icmax1
integer function icmax1(N, CX, INCX)
ICMAX1 finds the index of the first vector element of maximum absolute value.
Definition: icmax1.f:83