00001 /* clanht.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 clanht_(char *norm, integer *n, real *d__, complex *e) 00021 { 00022 /* System generated locals */ 00023 integer i__1; 00024 real ret_val, r__1, r__2, r__3; 00025 00026 /* Builtin functions */ 00027 double c_abs(complex *), sqrt(doublereal); 00028 00029 /* Local variables */ 00030 integer i__; 00031 real sum, scale; 00032 extern logical lsame_(char *, char *); 00033 real anorm; 00034 extern /* Subroutine */ int classq_(integer *, complex *, integer *, real 00035 *, real *), slassq_(integer *, real *, integer *, real *, real *); 00036 00037 00038 /* -- LAPACK auxiliary routine (version 3.2) -- */ 00039 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00040 /* November 2006 */ 00041 00042 /* .. Scalar Arguments .. */ 00043 /* .. */ 00044 /* .. Array Arguments .. */ 00045 /* .. */ 00046 00047 /* Purpose */ 00048 /* ======= */ 00049 00050 /* CLANHT returns the value of the one norm, or the Frobenius norm, or */ 00051 /* the infinity norm, or the element of largest absolute value of a */ 00052 /* complex Hermitian tridiagonal matrix A. */ 00053 00054 /* Description */ 00055 /* =========== */ 00056 00057 /* CLANHT returns the value */ 00058 00059 /* CLANHT = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ 00060 /* ( */ 00061 /* ( norm1(A), NORM = '1', 'O' or 'o' */ 00062 /* ( */ 00063 /* ( normI(A), NORM = 'I' or 'i' */ 00064 /* ( */ 00065 /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ 00066 00067 /* where norm1 denotes the one norm of a matrix (maximum column sum), */ 00068 /* normI denotes the infinity norm of a matrix (maximum row sum) and */ 00069 /* normF denotes the Frobenius norm of a matrix (square root of sum of */ 00070 /* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ 00071 00072 /* Arguments */ 00073 /* ========= */ 00074 00075 /* NORM (input) CHARACTER*1 */ 00076 /* Specifies the value to be returned in CLANHT as described */ 00077 /* above. */ 00078 00079 /* N (input) INTEGER */ 00080 /* The order of the matrix A. N >= 0. When N = 0, CLANHT is */ 00081 /* set to zero. */ 00082 00083 /* D (input) REAL array, dimension (N) */ 00084 /* The diagonal elements of A. */ 00085 00086 /* E (input) COMPLEX array, dimension (N-1) */ 00087 /* The (n-1) sub-diagonal or super-diagonal elements of A. */ 00088 00089 /* ===================================================================== */ 00090 00091 /* .. Parameters .. */ 00092 /* .. */ 00093 /* .. Local Scalars .. */ 00094 /* .. */ 00095 /* .. External Functions .. */ 00096 /* .. */ 00097 /* .. External Subroutines .. */ 00098 /* .. */ 00099 /* .. Intrinsic Functions .. */ 00100 /* .. */ 00101 /* .. Executable Statements .. */ 00102 00103 /* Parameter adjustments */ 00104 --e; 00105 --d__; 00106 00107 /* Function Body */ 00108 if (*n <= 0) { 00109 anorm = 0.f; 00110 } else if (lsame_(norm, "M")) { 00111 00112 /* Find max(abs(A(i,j))). */ 00113 00114 anorm = (r__1 = d__[*n], dabs(r__1)); 00115 i__1 = *n - 1; 00116 for (i__ = 1; i__ <= i__1; ++i__) { 00117 /* Computing MAX */ 00118 r__2 = anorm, r__3 = (r__1 = d__[i__], dabs(r__1)); 00119 anorm = dmax(r__2,r__3); 00120 /* Computing MAX */ 00121 r__1 = anorm, r__2 = c_abs(&e[i__]); 00122 anorm = dmax(r__1,r__2); 00123 /* L10: */ 00124 } 00125 } else if (lsame_(norm, "O") || *(unsigned char *) 00126 norm == '1' || lsame_(norm, "I")) { 00127 00128 /* Find norm1(A). */ 00129 00130 if (*n == 1) { 00131 anorm = dabs(d__[1]); 00132 } else { 00133 /* Computing MAX */ 00134 r__2 = dabs(d__[1]) + c_abs(&e[1]), r__3 = c_abs(&e[*n - 1]) + ( 00135 r__1 = d__[*n], dabs(r__1)); 00136 anorm = dmax(r__2,r__3); 00137 i__1 = *n - 1; 00138 for (i__ = 2; i__ <= i__1; ++i__) { 00139 /* Computing MAX */ 00140 r__2 = anorm, r__3 = (r__1 = d__[i__], dabs(r__1)) + c_abs(&e[ 00141 i__]) + c_abs(&e[i__ - 1]); 00142 anorm = dmax(r__2,r__3); 00143 /* L20: */ 00144 } 00145 } 00146 } else if (lsame_(norm, "F") || lsame_(norm, "E")) { 00147 00148 /* Find normF(A). */ 00149 00150 scale = 0.f; 00151 sum = 1.f; 00152 if (*n > 1) { 00153 i__1 = *n - 1; 00154 classq_(&i__1, &e[1], &c__1, &scale, &sum); 00155 sum *= 2; 00156 } 00157 slassq_(n, &d__[1], &c__1, &scale, &sum); 00158 anorm = scale * sqrt(sum); 00159 } 00160 00161 ret_val = anorm; 00162 return ret_val; 00163 00164 /* End of CLANHT */ 00165 00166 } /* clanht_ */