00001 /* clange.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 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 00020 doublereal clange_(char *norm, integer *m, integer *n, complex *a, integer * 00021 lda, real *work) 00022 { 00023 /* System generated locals */ 00024 integer a_dim1, a_offset, i__1, i__2; 00025 real ret_val, r__1, r__2; 00026 00027 /* Builtin functions */ 00028 double c_abs(complex *), sqrt(doublereal); 00029 00030 /* Local variables */ 00031 integer i__, j; 00032 real sum, scale; 00033 extern logical lsame_(char *, char *); 00034 real value; 00035 extern /* Subroutine */ int classq_(integer *, complex *, integer *, real 00036 *, real *); 00037 00038 00039 /* -- LAPACK auxiliary routine (version 3.2) -- */ 00040 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00041 /* November 2006 */ 00042 00043 /* .. Scalar Arguments .. */ 00044 /* .. */ 00045 /* .. Array Arguments .. */ 00046 /* .. */ 00047 00048 /* Purpose */ 00049 /* ======= */ 00050 00051 /* CLANGE returns the value of the one norm, or the Frobenius norm, or */ 00052 /* the infinity norm, or the element of largest absolute value of a */ 00053 /* complex matrix A. */ 00054 00055 /* Description */ 00056 /* =========== */ 00057 00058 /* CLANGE returns the value */ 00059 00060 /* CLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ 00061 /* ( */ 00062 /* ( norm1(A), NORM = '1', 'O' or 'o' */ 00063 /* ( */ 00064 /* ( normI(A), NORM = 'I' or 'i' */ 00065 /* ( */ 00066 /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ 00067 00068 /* where norm1 denotes the one norm of a matrix (maximum column sum), */ 00069 /* normI denotes the infinity norm of a matrix (maximum row sum) and */ 00070 /* normF denotes the Frobenius norm of a matrix (square root of sum of */ 00071 /* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ 00072 00073 /* Arguments */ 00074 /* ========= */ 00075 00076 /* NORM (input) CHARACTER*1 */ 00077 /* Specifies the value to be returned in CLANGE as described */ 00078 /* above. */ 00079 00080 /* M (input) INTEGER */ 00081 /* The number of rows of the matrix A. M >= 0. When M = 0, */ 00082 /* CLANGE is set to zero. */ 00083 00084 /* N (input) INTEGER */ 00085 /* The number of columns of the matrix A. N >= 0. When N = 0, */ 00086 /* CLANGE is set to zero. */ 00087 00088 /* A (input) COMPLEX array, dimension (LDA,N) */ 00089 /* The m by n matrix A. */ 00090 00091 /* LDA (input) INTEGER */ 00092 /* The leading dimension of the array A. LDA >= max(M,1). */ 00093 00094 /* WORK (workspace) REAL array, dimension (MAX(1,LWORK)), */ 00095 /* where LWORK >= M when NORM = 'I'; otherwise, WORK is not */ 00096 /* referenced. */ 00097 00098 /* ===================================================================== */ 00099 00100 /* .. Parameters .. */ 00101 /* .. */ 00102 /* .. Local Scalars .. */ 00103 /* .. */ 00104 /* .. External Functions .. */ 00105 /* .. */ 00106 /* .. External Subroutines .. */ 00107 /* .. */ 00108 /* .. Intrinsic Functions .. */ 00109 /* .. */ 00110 /* .. Executable Statements .. */ 00111 00112 /* Parameter adjustments */ 00113 a_dim1 = *lda; 00114 a_offset = 1 + a_dim1; 00115 a -= a_offset; 00116 --work; 00117 00118 /* Function Body */ 00119 if (min(*m,*n) == 0) { 00120 value = 0.f; 00121 } else if (lsame_(norm, "M")) { 00122 00123 /* Find max(abs(A(i,j))). */ 00124 00125 value = 0.f; 00126 i__1 = *n; 00127 for (j = 1; j <= i__1; ++j) { 00128 i__2 = *m; 00129 for (i__ = 1; i__ <= i__2; ++i__) { 00130 /* Computing MAX */ 00131 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]); 00132 value = dmax(r__1,r__2); 00133 /* L10: */ 00134 } 00135 /* L20: */ 00136 } 00137 } else if (lsame_(norm, "O") || *(unsigned char *) 00138 norm == '1') { 00139 00140 /* Find norm1(A). */ 00141 00142 value = 0.f; 00143 i__1 = *n; 00144 for (j = 1; j <= i__1; ++j) { 00145 sum = 0.f; 00146 i__2 = *m; 00147 for (i__ = 1; i__ <= i__2; ++i__) { 00148 sum += c_abs(&a[i__ + j * a_dim1]); 00149 /* L30: */ 00150 } 00151 value = dmax(value,sum); 00152 /* L40: */ 00153 } 00154 } else if (lsame_(norm, "I")) { 00155 00156 /* Find normI(A). */ 00157 00158 i__1 = *m; 00159 for (i__ = 1; i__ <= i__1; ++i__) { 00160 work[i__] = 0.f; 00161 /* L50: */ 00162 } 00163 i__1 = *n; 00164 for (j = 1; j <= i__1; ++j) { 00165 i__2 = *m; 00166 for (i__ = 1; i__ <= i__2; ++i__) { 00167 work[i__] += c_abs(&a[i__ + j * a_dim1]); 00168 /* L60: */ 00169 } 00170 /* L70: */ 00171 } 00172 value = 0.f; 00173 i__1 = *m; 00174 for (i__ = 1; i__ <= i__1; ++i__) { 00175 /* Computing MAX */ 00176 r__1 = value, r__2 = work[i__]; 00177 value = dmax(r__1,r__2); 00178 /* L80: */ 00179 } 00180 } else if (lsame_(norm, "F") || lsame_(norm, "E")) { 00181 00182 /* Find normF(A). */ 00183 00184 scale = 0.f; 00185 sum = 1.f; 00186 i__1 = *n; 00187 for (j = 1; j <= i__1; ++j) { 00188 classq_(m, &a[j * a_dim1 + 1], &c__1, &scale, &sum); 00189 /* L90: */ 00190 } 00191 value = scale * sqrt(sum); 00192 } 00193 00194 ret_val = value; 00195 return ret_val; 00196 00197 /* End of CLANGE */ 00198 00199 } /* clange_ */