LAPACK  3.9.0
LAPACK: Linear Algebra PACKage
dnrm2.f
Go to the documentation of this file.
1 *> \brief \b DNRM2
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * DOUBLE PRECISION FUNCTION DNRM2(N,X,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,N
15 * ..
16 * .. Array Arguments ..
17 * DOUBLE PRECISION X(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> DNRM2 returns the euclidean norm of a vector via the function
27 *> name, so that
28 *>
29 *> DNRM2 := sqrt( x'*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 DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
44 *> \endverbatim
45 *>
46 *> \param[in] INCX
47 *> \verbatim
48 *> INCX is INTEGER
49 *> storage spacing between elements of DX
50 *> \endverbatim
51 *
52 * Authors:
53 * ========
54 *
55 *> \author Univ. of Tennessee
56 *> \author Univ. of California Berkeley
57 *> \author Univ. of Colorado Denver
58 *> \author NAG Ltd.
59 *
60 *> \date November 2017
61 *
62 *> \ingroup double_blas_level1
63 *
64 *> \par Further Details:
65 * =====================
66 *>
67 *> \verbatim
68 *>
69 *> -- This version written on 25-October-1982.
70 *> Modified on 14-October-1993 to inline the call to DLASSQ.
71 *> Sven Hammarling, Nag Ltd.
72 *> \endverbatim
73 *>
74 * =====================================================================
75  DOUBLE PRECISION FUNCTION dnrm2(N,X,INCX)
76 *
77 * -- Reference BLAS level1 routine (version 3.8.0) --
78 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
79 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
80 * November 2017
81 *
82 * .. Scalar Arguments ..
83  INTEGER incx,n
84 * ..
85 * .. Array Arguments ..
86  DOUBLE PRECISION x(*)
87 * ..
88 *
89 * =====================================================================
90 *
91 * .. Parameters ..
92  DOUBLE PRECISION one,zero
93  parameter(one=1.0d+0,zero=0.0d+0)
94 * ..
95 * .. Local Scalars ..
96  DOUBLE PRECISION absxi,norm,scale,ssq
97  INTEGER ix
98 * ..
99 * .. Intrinsic Functions ..
100  INTRINSIC abs,sqrt
101 * ..
102  IF (n.LT.1 .OR. incx.LT.1) THEN
103  norm = zero
104  ELSE IF (n.EQ.1) THEN
105  norm = abs(x(1))
106  ELSE
107  scale = zero
108  ssq = one
109 * The following loop is equivalent to this call to the LAPACK
110 * auxiliary routine:
111 * CALL DLASSQ( N, X, INCX, SCALE, SSQ )
112 *
113  DO 10 ix = 1,1 + (n-1)*incx,incx
114  IF (x(ix).NE.zero) THEN
115  absxi = abs(x(ix))
116  IF (scale.LT.absxi) THEN
117  ssq = one + ssq* (scale/absxi)**2
118  scale = absxi
119  ELSE
120  ssq = ssq + (absxi/scale)**2
121  END IF
122  END IF
123  10 CONTINUE
124  norm = scale*sqrt(ssq)
125  END IF
126 *
127  dnrm2 = norm
128  RETURN
129 *
130 * End of DNRM2.
131 *
132  END
dnrm2
double precision function dnrm2(N, X, INCX)
DNRM2
Definition: dnrm2.f:76