KTH framework for Nek5000 toolboxes; testing version  0.0.1
dnrm2.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION dnrm2 ( N, X, INCX )
2 * .. Scalar Arguments ..
3  INTEGER incx, n
4 * .. Array Arguments ..
5  DOUBLE PRECISION x( * )
6 * ..
7 *
8 * DNRM2 returns the euclidean norm of a vector via the function
9 * name, so that
10 *
11 * DNRM2 := sqrt( x'*x )
12 *
13 *
14 *
15 * -- This version written on 25-October-1982.
16 * Modified on 14-October-1993 to inline the call to DLASSQ.
17 * Sven Hammarling, Nag Ltd.
18 *
19 *
20 * .. Parameters ..
21  DOUBLE PRECISION one , zero
22  parameter( one = 1.0d+0, zero = 0.0d+0 )
23 * .. Local Scalars ..
24  INTEGER ix
25  DOUBLE PRECISION absxi, norm, scale, ssq
26 * .. Intrinsic Functions ..
27  INTRINSIC abs, sqrt
28 * ..
29 * .. Executable Statements ..
30  IF( n.LT.1 .OR. incx.LT.1 )THEN
31  norm = zero
32  ELSE IF( n.EQ.1 )THEN
33  norm = abs( x( 1 ) )
34  ELSE
35  scale = zero
36  ssq = one
37 * The following loop is equivalent to this call to the LAPACK
38 * auxiliary routine:
39 * CALL DLASSQ( N, X, INCX, SCALE, SSQ )
40 *
41  DO 10, ix = 1, 1 + ( n - 1 )*incx, incx
42  IF( x( ix ).NE.zero )THEN
43  absxi = abs( x( ix ) )
44  IF( scale.LT.absxi )THEN
45  ssq = one + ssq*( scale/absxi )**2
46  scale = absxi
47  ELSE
48  ssq = ssq + ( absxi/scale )**2
49  END IF
50  END IF
51  10 CONTINUE
52  norm = scale * sqrt( ssq )
53  END IF
54 *
55  dnrm2 = norm
56  RETURN
57 *
58 * End of DNRM2.
59 *
60  END
subroutine scale(xyzl, nl)
Definition: connect2.f:602
double precision function dnrm2(N, X, INCX)
Definition: dnrm2.f:2