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