scnrm2.c
Go to the documentation of this file.
00001 /* scnrm2.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 doublereal scnrm2_(integer *n, complex *x, integer *incx)
00017 {
00018     /* System generated locals */
00019     integer i__1, i__2, i__3;
00020     real ret_val, r__1;
00021 
00022     /* Builtin functions */
00023     double r_imag(complex *), sqrt(doublereal);
00024 
00025     /* Local variables */
00026     integer ix;
00027     real ssq, temp, norm, scale;
00028 
00029 /*     .. Scalar Arguments .. */
00030 /*     .. */
00031 /*     .. Array Arguments .. */
00032 /*     .. */
00033 
00034 /*  Purpose */
00035 /*  ======= */
00036 
00037 /*  SCNRM2 returns the euclidean norm of a vector via the function */
00038 /*  name, so that */
00039 
00040 /*     SCNRM2 := sqrt( conjg( x' )*x ) */
00041 
00042 
00043 
00044 /*  -- This version written on 25-October-1982. */
00045 /*     Modified on 14-October-1993 to inline the call to CLASSQ. */
00046 /*     Sven Hammarling, Nag Ltd. */
00047 
00048 
00049 /*     .. Parameters .. */
00050 /*     .. */
00051 /*     .. Local Scalars .. */
00052 /*     .. */
00053 /*     .. Intrinsic Functions .. */
00054 /*     .. */
00055     /* Parameter adjustments */
00056     --x;
00057 
00058     /* Function Body */
00059     if (*n < 1 || *incx < 1) {
00060         norm = 0.f;
00061     } else {
00062         scale = 0.f;
00063         ssq = 1.f;
00064 /*        The following loop is equivalent to this call to the LAPACK */
00065 /*        auxiliary routine: */
00066 /*        CALL CLASSQ( N, X, INCX, SCALE, SSQ ) */
00067 
00068         i__1 = (*n - 1) * *incx + 1;
00069         i__2 = *incx;
00070         for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
00071             i__3 = ix;
00072             if (x[i__3].r != 0.f) {
00073                 i__3 = ix;
00074                 temp = (r__1 = x[i__3].r, dabs(r__1));
00075                 if (scale < temp) {
00076 /* Computing 2nd power */
00077                     r__1 = scale / temp;
00078                     ssq = ssq * (r__1 * r__1) + 1.f;
00079                     scale = temp;
00080                 } else {
00081 /* Computing 2nd power */
00082                     r__1 = temp / scale;
00083                     ssq += r__1 * r__1;
00084                 }
00085             }
00086             if (r_imag(&x[ix]) != 0.f) {
00087                 temp = (r__1 = r_imag(&x[ix]), dabs(r__1));
00088                 if (scale < temp) {
00089 /* Computing 2nd power */
00090                     r__1 = scale / temp;
00091                     ssq = ssq * (r__1 * r__1) + 1.f;
00092                     scale = temp;
00093                 } else {
00094 /* Computing 2nd power */
00095                     r__1 = temp / scale;
00096                     ssq += r__1 * r__1;
00097                 }
00098             }
00099 /* L10: */
00100         }
00101         norm = scale * sqrt(ssq);
00102     }
00103 
00104     ret_val = norm;
00105     return ret_val;
00106 
00107 /*     End of SCNRM2. */
00108 
00109 } /* scnrm2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:59