LAPACK  3.7.1
LAPACK: Linear Algebra PACKage
scnrm2.f
Go to the documentation of this file.
1 *> \brief \b SCNRM2
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * REAL FUNCTION SCNRM2(N,X,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,N
15 * ..
16 * .. Array Arguments ..
17 * COMPLEX X(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> SCNRM2 returns the euclidean norm of a vector via the function
27 *> name, so that
28 *>
29 *> SCNRM2 := sqrt( x**H*x )
30 *> \endverbatim
31 *
32 * Arguments:
33 * ==========
34 *
35 *> \param[in] N
36 *> \verbatim
37 *> N is INTEGER
38 *> number of elements in input vector(s)
39 *> \endverbatim
40 *>
41 *> \param[in] X
42 *> \verbatim
43 *> X is COMPLEX array, dimension (N)
44 *> complex vector with N elements
45 *> \endverbatim
46 *>
47 *> \param[in] INCX
48 *> \verbatim
49 *> INCX is INTEGER
50 *> storage spacing between elements of X
51 *> \endverbatim
52 *
53 * Authors:
54 * ========
55 *
56 *> \author Univ. of Tennessee
57 *> \author Univ. of California Berkeley
58 *> \author Univ. of Colorado Denver
59 *> \author NAG Ltd.
60 *
61 *> \date December 2016
62 *
63 *> \ingroup single_blas_level1
64 *
65 *> \par Further Details:
66 * =====================
67 *>
68 *> \verbatim
69 *>
70 *> -- This version written on 25-October-1982.
71 *> Modified on 14-October-1993 to inline the call to CLASSQ.
72 *> Sven Hammarling, Nag Ltd.
73 *> \endverbatim
74 *>
75 * =====================================================================
76  REAL FUNCTION scnrm2(N,X,INCX)
77 *
78 * -- Reference BLAS level1 routine (version 3.7.0) --
79 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
80 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
81 * December 2016
82 *
83 * .. Scalar Arguments ..
84  INTEGER INCX,N
85 * ..
86 * .. Array Arguments ..
87  COMPLEX X(*)
88 * ..
89 *
90 * =====================================================================
91 *
92 * .. Parameters ..
93  REAL ONE,ZERO
94  parameter(one=1.0e+0,zero=0.0e+0)
95 * ..
96 * .. Local Scalars ..
97  REAL NORM,SCALE,SSQ,TEMP
98  INTEGER IX
99 * ..
100 * .. Intrinsic Functions ..
101  INTRINSIC abs,aimag,REAL,SQRT
102 * ..
103  IF (n.LT.1 .OR. incx.LT.1) THEN
104  norm = zero
105  ELSE
106  scale = zero
107  ssq = one
108 * The following loop is equivalent to this call to the LAPACK
109 * auxiliary routine:
110 * CALL CLASSQ( N, X, INCX, SCALE, SSQ )
111 *
112  DO 10 ix = 1,1 + (n-1)*incx,incx
113  IF (REAL(x(ix)).NE.ZERO) then
114  temp = abs(REAL(x(ix)))
115  IF (scale.LT.temp) THEN
116  ssq = one + ssq* (scale/temp)**2
117  scale = temp
118  ELSE
119  ssq = ssq + (temp/scale)**2
120  END IF
121  END IF
122  IF (aimag(x(ix)).NE.zero) THEN
123  temp = abs(aimag(x(ix)))
124  IF (scale.LT.temp) THEN
125  ssq = one + ssq* (scale/temp)**2
126  scale = temp
127  ELSE
128  ssq = ssq + (temp/scale)**2
129  END IF
130  END IF
131  10 CONTINUE
132  norm = scale*sqrt(ssq)
133  END IF
134 *
135  scnrm2 = norm
136  RETURN
137 *
138 * End of SCNRM2.
139 *
140  END
real function scnrm2(N, X, INCX)
SCNRM2
Definition: scnrm2.f:77