00001 /* cgtcon.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 /* Subroutine */ int cgtcon_(char *norm, integer *n, complex *dl, complex * 00021 d__, complex *du, complex *du2, integer *ipiv, real *anorm, real * 00022 rcond, complex *work, integer *info) 00023 { 00024 /* System generated locals */ 00025 integer i__1, i__2; 00026 00027 /* Local variables */ 00028 integer i__, kase, kase1; 00029 extern logical lsame_(char *, char *); 00030 integer isave[3]; 00031 extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real 00032 *, integer *, integer *), xerbla_(char *, integer *); 00033 real ainvnm; 00034 logical onenrm; 00035 extern /* Subroutine */ int cgttrs_(char *, integer *, integer *, complex 00036 *, complex *, complex *, complex *, integer *, complex *, integer 00037 *, integer *); 00038 00039 00040 /* -- LAPACK routine (version 3.2) -- */ 00041 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00042 /* November 2006 */ 00043 00044 /* Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH. */ 00045 00046 /* .. Scalar Arguments .. */ 00047 /* .. */ 00048 /* .. Array Arguments .. */ 00049 /* .. */ 00050 00051 /* Purpose */ 00052 /* ======= */ 00053 00054 /* CGTCON estimates the reciprocal of the condition number of a complex */ 00055 /* tridiagonal matrix A using the LU factorization as computed by */ 00056 /* CGTTRF. */ 00057 00058 /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ 00059 /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */ 00060 00061 /* Arguments */ 00062 /* ========= */ 00063 00064 /* NORM (input) CHARACTER*1 */ 00065 /* Specifies whether the 1-norm condition number or the */ 00066 /* infinity-norm condition number is required: */ 00067 /* = '1' or 'O': 1-norm; */ 00068 /* = 'I': Infinity-norm. */ 00069 00070 /* N (input) INTEGER */ 00071 /* The order of the matrix A. N >= 0. */ 00072 00073 /* DL (input) COMPLEX array, dimension (N-1) */ 00074 /* The (n-1) multipliers that define the matrix L from the */ 00075 /* LU factorization of A as computed by CGTTRF. */ 00076 00077 /* D (input) COMPLEX array, dimension (N) */ 00078 /* The n diagonal elements of the upper triangular matrix U from */ 00079 /* the LU factorization of A. */ 00080 00081 /* DU (input) COMPLEX array, dimension (N-1) */ 00082 /* The (n-1) elements of the first superdiagonal of U. */ 00083 00084 /* DU2 (input) COMPLEX array, dimension (N-2) */ 00085 /* The (n-2) elements of the second superdiagonal of U. */ 00086 00087 /* IPIV (input) INTEGER array, dimension (N) */ 00088 /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ 00089 /* interchanged with row IPIV(i). IPIV(i) will always be either */ 00090 /* i or i+1; IPIV(i) = i indicates a row interchange was not */ 00091 /* required. */ 00092 00093 /* ANORM (input) REAL */ 00094 /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ 00095 /* If NORM = 'I', the infinity-norm of the original matrix A. */ 00096 00097 /* RCOND (output) REAL */ 00098 /* The reciprocal of the condition number of the matrix A, */ 00099 /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */ 00100 /* estimate of the 1-norm of inv(A) computed in this routine. */ 00101 00102 /* WORK (workspace) COMPLEX array, dimension (2*N) */ 00103 00104 /* INFO (output) INTEGER */ 00105 /* = 0: successful exit */ 00106 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00107 00108 /* ===================================================================== */ 00109 00110 /* .. Parameters .. */ 00111 /* .. */ 00112 /* .. Local Scalars .. */ 00113 /* .. */ 00114 /* .. Local Arrays .. */ 00115 /* .. */ 00116 /* .. External Functions .. */ 00117 /* .. */ 00118 /* .. External Subroutines .. */ 00119 /* .. */ 00120 /* .. Intrinsic Functions .. */ 00121 /* .. */ 00122 /* .. Executable Statements .. */ 00123 00124 /* Test the input arguments. */ 00125 00126 /* Parameter adjustments */ 00127 --work; 00128 --ipiv; 00129 --du2; 00130 --du; 00131 --d__; 00132 --dl; 00133 00134 /* Function Body */ 00135 *info = 0; 00136 onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); 00137 if (! onenrm && ! lsame_(norm, "I")) { 00138 *info = -1; 00139 } else if (*n < 0) { 00140 *info = -2; 00141 } else if (*anorm < 0.f) { 00142 *info = -8; 00143 } 00144 if (*info != 0) { 00145 i__1 = -(*info); 00146 xerbla_("CGTCON", &i__1); 00147 return 0; 00148 } 00149 00150 /* Quick return if possible */ 00151 00152 *rcond = 0.f; 00153 if (*n == 0) { 00154 *rcond = 1.f; 00155 return 0; 00156 } else if (*anorm == 0.f) { 00157 return 0; 00158 } 00159 00160 /* Check that D(1:N) is non-zero. */ 00161 00162 i__1 = *n; 00163 for (i__ = 1; i__ <= i__1; ++i__) { 00164 i__2 = i__; 00165 if (d__[i__2].r == 0.f && d__[i__2].i == 0.f) { 00166 return 0; 00167 } 00168 /* L10: */ 00169 } 00170 00171 ainvnm = 0.f; 00172 if (onenrm) { 00173 kase1 = 1; 00174 } else { 00175 kase1 = 2; 00176 } 00177 kase = 0; 00178 L20: 00179 clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); 00180 if (kase != 0) { 00181 if (kase == kase1) { 00182 00183 /* Multiply by inv(U)*inv(L). */ 00184 00185 cgttrs_("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1] 00186 , &ipiv[1], &work[1], n, info); 00187 } else { 00188 00189 /* Multiply by inv(L')*inv(U'). */ 00190 00191 cgttrs_("Conjugate transpose", n, &c__1, &dl[1], &d__[1], &du[1], 00192 &du2[1], &ipiv[1], &work[1], n, info); 00193 } 00194 goto L20; 00195 } 00196 00197 /* Compute the estimate of the reciprocal condition number. */ 00198 00199 if (ainvnm != 0.f) { 00200 *rcond = 1.f / ainvnm / *anorm; 00201 } 00202 00203 return 0; 00204 00205 /* End of CGTCON */ 00206 00207 } /* cgtcon_ */