00001 /* cptcon.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 cptcon_(integer *n, real *d__, complex *e, real *anorm, 00021 real *rcond, real *rwork, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer i__1; 00025 real r__1; 00026 00027 /* Builtin functions */ 00028 double c_abs(complex *); 00029 00030 /* Local variables */ 00031 integer i__, ix; 00032 extern /* Subroutine */ int xerbla_(char *, integer *); 00033 extern integer isamax_(integer *, real *, integer *); 00034 real ainvnm; 00035 00036 00037 /* -- LAPACK routine (version 3.2) -- */ 00038 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00039 /* November 2006 */ 00040 00041 /* .. Scalar Arguments .. */ 00042 /* .. */ 00043 /* .. Array Arguments .. */ 00044 /* .. */ 00045 00046 /* Purpose */ 00047 /* ======= */ 00048 00049 /* CPTCON computes the reciprocal of the condition number (in the */ 00050 /* 1-norm) of a complex Hermitian positive definite tridiagonal matrix */ 00051 /* using the factorization A = L*D*L**H or A = U**H*D*U computed by */ 00052 /* CPTTRF. */ 00053 00054 /* Norm(inv(A)) is computed by a direct method, and the reciprocal of */ 00055 /* the condition number is computed as */ 00056 /* RCOND = 1 / (ANORM * norm(inv(A))). */ 00057 00058 /* Arguments */ 00059 /* ========= */ 00060 00061 /* N (input) INTEGER */ 00062 /* The order of the matrix A. N >= 0. */ 00063 00064 /* D (input) REAL array, dimension (N) */ 00065 /* The n diagonal elements of the diagonal matrix D from the */ 00066 /* factorization of A, as computed by CPTTRF. */ 00067 00068 /* E (input) COMPLEX array, dimension (N-1) */ 00069 /* The (n-1) off-diagonal elements of the unit bidiagonal factor */ 00070 /* U or L from the factorization of A, as computed by CPTTRF. */ 00071 00072 /* ANORM (input) REAL */ 00073 /* The 1-norm of the original matrix A. */ 00074 00075 /* RCOND (output) REAL */ 00076 /* The reciprocal of the condition number of the matrix A, */ 00077 /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is the */ 00078 /* 1-norm of inv(A) computed in this routine. */ 00079 00080 /* RWORK (workspace) REAL array, dimension (N) */ 00081 00082 /* INFO (output) INTEGER */ 00083 /* = 0: successful exit */ 00084 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00085 00086 /* Further Details */ 00087 /* =============== */ 00088 00089 /* The method used is described in Nicholas J. Higham, "Efficient */ 00090 /* Algorithms for Computing the Condition Number of a Tridiagonal */ 00091 /* Matrix", SIAM J. Sci. Stat. Comput., Vol. 7, No. 1, January 1986. */ 00092 00093 /* ===================================================================== */ 00094 00095 /* .. Parameters .. */ 00096 /* .. */ 00097 /* .. Local Scalars .. */ 00098 /* .. */ 00099 /* .. External Functions .. */ 00100 /* .. */ 00101 /* .. External Subroutines .. */ 00102 /* .. */ 00103 /* .. Intrinsic Functions .. */ 00104 /* .. */ 00105 /* .. Executable Statements .. */ 00106 00107 /* Test the input arguments. */ 00108 00109 /* Parameter adjustments */ 00110 --rwork; 00111 --e; 00112 --d__; 00113 00114 /* Function Body */ 00115 *info = 0; 00116 if (*n < 0) { 00117 *info = -1; 00118 } else if (*anorm < 0.f) { 00119 *info = -4; 00120 } 00121 if (*info != 0) { 00122 i__1 = -(*info); 00123 xerbla_("CPTCON", &i__1); 00124 return 0; 00125 } 00126 00127 /* Quick return if possible */ 00128 00129 *rcond = 0.f; 00130 if (*n == 0) { 00131 *rcond = 1.f; 00132 return 0; 00133 } else if (*anorm == 0.f) { 00134 return 0; 00135 } 00136 00137 /* Check that D(1:N) is positive. */ 00138 00139 i__1 = *n; 00140 for (i__ = 1; i__ <= i__1; ++i__) { 00141 if (d__[i__] <= 0.f) { 00142 return 0; 00143 } 00144 /* L10: */ 00145 } 00146 00147 /* Solve M(A) * x = e, where M(A) = (m(i,j)) is given by */ 00148 00149 /* m(i,j) = abs(A(i,j)), i = j, */ 00150 /* m(i,j) = -abs(A(i,j)), i .ne. j, */ 00151 00152 /* and e = [ 1, 1, ..., 1 ]'. Note M(A) = M(L)*D*M(L)'. */ 00153 00154 /* Solve M(L) * x = e. */ 00155 00156 rwork[1] = 1.f; 00157 i__1 = *n; 00158 for (i__ = 2; i__ <= i__1; ++i__) { 00159 rwork[i__] = rwork[i__ - 1] * c_abs(&e[i__ - 1]) + 1.f; 00160 /* L20: */ 00161 } 00162 00163 /* Solve D * M(L)' * x = b. */ 00164 00165 rwork[*n] /= d__[*n]; 00166 for (i__ = *n - 1; i__ >= 1; --i__) { 00167 rwork[i__] = rwork[i__] / d__[i__] + rwork[i__ + 1] * c_abs(&e[i__]); 00168 /* L30: */ 00169 } 00170 00171 /* Compute AINVNM = max(x(i)), 1<=i<=n. */ 00172 00173 ix = isamax_(n, &rwork[1], &c__1); 00174 ainvnm = (r__1 = rwork[ix], dabs(r__1)); 00175 00176 /* Compute the reciprocal condition number. */ 00177 00178 if (ainvnm != 0.f) { 00179 *rcond = 1.f / ainvnm / *anorm; 00180 } 00181 00182 return 0; 00183 00184 /* End of CPTCON */ 00185 00186 } /* cptcon_ */