00001 /* zlassq.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 /* Subroutine */ int zlassq_(integer *n, doublecomplex *x, integer *incx, 00017 doublereal *scale, doublereal *sumsq) 00018 { 00019 /* System generated locals */ 00020 integer i__1, i__2, i__3; 00021 doublereal d__1; 00022 00023 /* Builtin functions */ 00024 double d_imag(doublecomplex *); 00025 00026 /* Local variables */ 00027 integer ix; 00028 doublereal temp1; 00029 00030 00031 /* -- LAPACK auxiliary routine (version 3.2) -- */ 00032 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00033 /* November 2006 */ 00034 00035 /* .. Scalar Arguments .. */ 00036 /* .. */ 00037 /* .. Array Arguments .. */ 00038 /* .. */ 00039 00040 /* Purpose */ 00041 /* ======= */ 00042 00043 /* ZLASSQ returns the values scl and ssq such that */ 00044 00045 /* ( scl**2 )*ssq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, */ 00046 00047 /* where x( i ) = abs( X( 1 + ( i - 1 )*INCX ) ). The value of sumsq is */ 00048 /* assumed to be at least unity and the value of ssq will then satisfy */ 00049 00050 /* 1.0 .le. ssq .le. ( sumsq + 2*n ). */ 00051 00052 /* scale is assumed to be non-negative and scl returns the value */ 00053 00054 /* scl = max( scale, abs( real( x( i ) ) ), abs( aimag( x( i ) ) ) ), */ 00055 /* i */ 00056 00057 /* scale and sumsq must be supplied in SCALE and SUMSQ respectively. */ 00058 /* SCALE and SUMSQ are overwritten by scl and ssq respectively. */ 00059 00060 /* The routine makes only one pass through the vector X. */ 00061 00062 /* Arguments */ 00063 /* ========= */ 00064 00065 /* N (input) INTEGER */ 00066 /* The number of elements to be used from the vector X. */ 00067 00068 /* X (input) COMPLEX*16 array, dimension (N) */ 00069 /* The vector x as described above. */ 00070 /* x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. */ 00071 00072 /* INCX (input) INTEGER */ 00073 /* The increment between successive values of the vector X. */ 00074 /* INCX > 0. */ 00075 00076 /* SCALE (input/output) DOUBLE PRECISION */ 00077 /* On entry, the value scale in the equation above. */ 00078 /* On exit, SCALE is overwritten with the value scl . */ 00079 00080 /* SUMSQ (input/output) DOUBLE PRECISION */ 00081 /* On entry, the value sumsq in the equation above. */ 00082 /* On exit, SUMSQ is overwritten with the value ssq . */ 00083 00084 /* ===================================================================== */ 00085 00086 /* .. Parameters .. */ 00087 /* .. */ 00088 /* .. Local Scalars .. */ 00089 /* .. */ 00090 /* .. Intrinsic Functions .. */ 00091 /* .. */ 00092 /* .. Executable Statements .. */ 00093 00094 /* Parameter adjustments */ 00095 --x; 00096 00097 /* Function Body */ 00098 if (*n > 0) { 00099 i__1 = (*n - 1) * *incx + 1; 00100 i__2 = *incx; 00101 for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) { 00102 i__3 = ix; 00103 if (x[i__3].r != 0.) { 00104 i__3 = ix; 00105 temp1 = (d__1 = x[i__3].r, abs(d__1)); 00106 if (*scale < temp1) { 00107 /* Computing 2nd power */ 00108 d__1 = *scale / temp1; 00109 *sumsq = *sumsq * (d__1 * d__1) + 1; 00110 *scale = temp1; 00111 } else { 00112 /* Computing 2nd power */ 00113 d__1 = temp1 / *scale; 00114 *sumsq += d__1 * d__1; 00115 } 00116 } 00117 if (d_imag(&x[ix]) != 0.) { 00118 temp1 = (d__1 = d_imag(&x[ix]), abs(d__1)); 00119 if (*scale < temp1) { 00120 /* Computing 2nd power */ 00121 d__1 = *scale / temp1; 00122 *sumsq = *sumsq * (d__1 * d__1) + 1; 00123 *scale = temp1; 00124 } else { 00125 /* Computing 2nd power */ 00126 d__1 = temp1 / *scale; 00127 *sumsq += d__1 * d__1; 00128 } 00129 } 00130 /* L10: */ 00131 } 00132 } 00133 00134 return 0; 00135 00136 /* End of ZLASSQ */ 00137 00138 } /* zlassq_ */