Debian Codegraph @

debian/external_deps/fetk/punc/src/blas/dnrm2.c

raw
1 /* ./src_f77/dnrm2.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 doublereal dnrm2_(integer *n, doublereal *x, integer *incx)
9 {
10 /* System generated locals */
11 integer i__1, i__2;
12 doublereal ret_val, d__1;
13
14 /* Builtin functions */
15 double sqrt(doublereal);
16
17 /* Local variables */
18 static integer ix;
19 static doublereal ssq, norm, scale, absxi;
20
21 /* .. Scalar Arguments .. */
22 /* .. Array Arguments .. */
23 /* .. */
24
25 /* DNRM2 returns the euclidean norm of a vector via the function */
26 /* name, so that */
27
28 /* DNRM2 := sqrt( x'*x ) */
29
30
31
32 /* -- This version written on 25-October-1982. */
33 /* Modified on 14-October-1993 to inline the call to DLASSQ. */
34 /* Sven Hammarling, Nag Ltd. */
35
36
37 /* .. Parameters .. */
38 /* .. Local Scalars .. */
39 /* .. Intrinsic Functions .. */
40 /* .. */
41 /* .. Executable Statements .. */
42 /* Parameter adjustments */
43 --x;
44
45 /* Function Body */
46 if (*n < 1 || *incx < 1) {
47 norm = 0.;
48 } else if (*n == 1) {
49 norm = abs(x[1]);
50 } else {
51 scale = 0.;
52 ssq = 1.;
53 /* The following loop is equivalent to this call to the LAPACK */
54 /* auxiliary routine: */
55 /* CALL DLASSQ( N, X, INCX, SCALE, SSQ ) */
56
57 i__1 = (*n - 1) * *incx + 1;
58 i__2 = *incx;
59 for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
60 if (x[ix] != 0.) {
61 absxi = (d__1 = x[ix], abs(d__1));
62 if (scale < absxi) {
63 /* Computing 2nd power */
64 d__1 = scale / absxi;
65 ssq = ssq * (d__1 * d__1) + 1.;
66 scale = absxi;
67 } else {
68 /* Computing 2nd power */
69 d__1 = absxi / scale;
70 ssq += d__1 * d__1;
71 }
72 }
73 /* L10: */
74 }
75 norm = scale * sqrt(ssq);
76 }
77
78 ret_val = norm;
79 return ret_val;
80
81 /* End of DNRM2. */
82
83 } /* dnrm2_ */
84