Debian Codegraph @

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

raw
1 /* ./src_f77/dznrm2.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 dznrm2_(integer *n, doublecomplex *x, integer *incx)
9 {
10 /* System generated locals */
11 integer i__1, i__2, i__3;
12 doublereal ret_val, d__1;
13
14 /* Builtin functions */
15 double d_imag(doublecomplex *), sqrt(doublereal);
16
17 /* Local variables */
18 static integer ix;
19 static doublereal ssq, temp, norm, scale;
20
21 /* .. Scalar Arguments .. */
22 /* .. Array Arguments .. */
23 /* .. */
24
25 /* DZNRM2 returns the euclidean norm of a vector via the function */
26 /* name, so that */
27
28 /* DZNRM2 := sqrt( conjg( x' )*x ) */
29
30
31
32 /* -- This version written on 25-October-1982. */
33 /* Modified on 14-October-1993 to inline the call to ZLASSQ. */
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 {
49 scale = 0.;
50 ssq = 1.;
51 /* The following loop is equivalent to this call to the LAPACK */
52 /* auxiliary routine: */
53 /* CALL ZLASSQ( N, X, INCX, SCALE, SSQ ) */
54
55 i__1 = (*n - 1) * *incx + 1;
56 i__2 = *incx;
57 for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
58 i__3 = ix;
59 if (x[i__3].r != 0.) {
60 i__3 = ix;
61 temp = (d__1 = x[i__3].r, abs(d__1));
62 if (scale < temp) {
63 /* Computing 2nd power */
64 d__1 = scale / temp;
65 ssq = ssq * (d__1 * d__1) + 1.;
66 scale = temp;
67 } else {
68 /* Computing 2nd power */
69 d__1 = temp / scale;
70 ssq += d__1 * d__1;
71 }
72 }
73 if (d_imag(&x[ix]) != 0.) {
74 temp = (d__1 = d_imag(&x[ix]), abs(d__1));
75 if (scale < temp) {
76 /* Computing 2nd power */
77 d__1 = scale / temp;
78 ssq = ssq * (d__1 * d__1) + 1.;
79 scale = temp;
80 } else {
81 /* Computing 2nd power */
82 d__1 = temp / scale;
83 ssq += d__1 * d__1;
84 }
85 }
86 /* L10: */
87 }
88 norm = scale * sqrt(ssq);
89 }
90
91 ret_val = norm;
92 return ret_val;
93
94 /* End of DZNRM2. */
95
96 } /* dznrm2_ */
97