|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* -- translated by f2c (version 19940927).
|
|
kusano |
7d535a |
You must link the resulting object file with the libraries:
|
|
kusano |
7d535a |
-lf2c -lm (in that order)
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#include "f2c.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
doublereal dznrm2_(integer *n, doublecomplex *x, integer *incx)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* System generated locals */
|
|
kusano |
7d535a |
integer i__1, i__2, i__3;
|
|
kusano |
7d535a |
doublereal ret_val, d__1;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Builtin functions */
|
|
kusano |
7d535a |
double d_imag(doublecomplex *), sqrt(doublereal);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Local variables */
|
|
kusano |
7d535a |
static doublereal temp, norm, scale;
|
|
kusano |
7d535a |
static integer ix;
|
|
kusano |
7d535a |
static doublereal ssq;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* DZNRM2 returns the euclidean norm of a vector via the function
|
|
kusano |
7d535a |
name, so that
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
DZNRM2 := sqrt( conjg( x' )*x )
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
-- This version written on 25-October-1982.
|
|
kusano |
7d535a |
Modified on 14-October-1993 to inline the call to ZLASSQ.
|
|
kusano |
7d535a |
Sven Hammarling, Nag Ltd.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Parameter adjustments
|
|
kusano |
7d535a |
Function Body */
|
|
kusano |
7d535a |
#define X(I) x[(I)-1]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if (*n < 1 || *incx < 1) {
|
|
kusano |
7d535a |
norm = 0.;
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
scale = 0.;
|
|
kusano |
7d535a |
ssq = 1.;
|
|
kusano |
7d535a |
/* The following loop is equivalent to this call to the LAPACK
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
auxiliary routine:
|
|
kusano |
7d535a |
CALL ZLASSQ( N, X, INCX, SCALE, SSQ ) */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
i__1 = (*n - 1) * *incx + 1;
|
|
kusano |
7d535a |
i__2 = *incx;
|
|
kusano |
7d535a |
for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {
|
|
kusano |
7d535a |
i__3 = ix;
|
|
kusano |
7d535a |
if (X(ix).r != 0.) {
|
|
kusano |
7d535a |
i__3 = ix;
|
|
kusano |
7d535a |
temp = (d__1 = X(ix).r, abs(d__1));
|
|
kusano |
7d535a |
if (scale < temp) {
|
|
kusano |
7d535a |
/* Computing 2nd power */
|
|
kusano |
7d535a |
d__1 = scale / temp;
|
|
kusano |
7d535a |
ssq = ssq * (d__1 * d__1) + 1.;
|
|
kusano |
7d535a |
scale = temp;
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
/* Computing 2nd power */
|
|
kusano |
7d535a |
d__1 = temp / scale;
|
|
kusano |
7d535a |
ssq += d__1 * d__1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if (d_imag(&X(ix)) != 0.) {
|
|
kusano |
7d535a |
temp = (d__1 = d_imag(&X(ix)), abs(d__1));
|
|
kusano |
7d535a |
if (scale < temp) {
|
|
kusano |
7d535a |
/* Computing 2nd power */
|
|
kusano |
7d535a |
d__1 = scale / temp;
|
|
kusano |
7d535a |
ssq = ssq * (d__1 * d__1) + 1.;
|
|
kusano |
7d535a |
scale = temp;
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
/* Computing 2nd power */
|
|
kusano |
7d535a |
d__1 = temp / scale;
|
|
kusano |
7d535a |
ssq += d__1 * d__1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
/* L10: */
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
norm = scale * sqrt(ssq);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
ret_val = norm;
|
|
kusano |
7d535a |
return ret_val;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* End of DZNRM2. */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
} /* dznrm2_ */
|
|
kusano |
7d535a |
|