00001 /* chpcon.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 chpcon_(char *uplo, integer *n, complex *ap, integer * 00021 ipiv, real *anorm, real *rcond, complex *work, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer i__1, i__2; 00025 00026 /* Local variables */ 00027 integer i__, ip, kase; 00028 extern logical lsame_(char *, char *); 00029 integer isave[3]; 00030 logical upper; 00031 extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real 00032 *, integer *, integer *), xerbla_(char *, integer *); 00033 real ainvnm; 00034 extern /* Subroutine */ int chptrs_(char *, integer *, integer *, complex 00035 *, integer *, complex *, integer *, integer *); 00036 00037 00038 /* -- LAPACK routine (version 3.2) -- */ 00039 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00040 /* November 2006 */ 00041 00042 /* Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH. */ 00043 00044 /* .. Scalar Arguments .. */ 00045 /* .. */ 00046 /* .. Array Arguments .. */ 00047 /* .. */ 00048 00049 /* Purpose */ 00050 /* ======= */ 00051 00052 /* CHPCON estimates the reciprocal of the condition number of a complex */ 00053 /* Hermitian packed matrix A using the factorization A = U*D*U**H or */ 00054 /* A = L*D*L**H computed by CHPTRF. */ 00055 00056 /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ 00057 /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */ 00058 00059 /* Arguments */ 00060 /* ========= */ 00061 00062 /* UPLO (input) CHARACTER*1 */ 00063 /* Specifies whether the details of the factorization are stored */ 00064 /* as an upper or lower triangular matrix. */ 00065 /* = 'U': Upper triangular, form is A = U*D*U**H; */ 00066 /* = 'L': Lower triangular, form is A = L*D*L**H. */ 00067 00068 /* N (input) INTEGER */ 00069 /* The order of the matrix A. N >= 0. */ 00070 00071 /* AP (input) COMPLEX array, dimension (N*(N+1)/2) */ 00072 /* The block diagonal matrix D and the multipliers used to */ 00073 /* obtain the factor U or L as computed by CHPTRF, stored as a */ 00074 /* packed triangular matrix. */ 00075 00076 /* IPIV (input) INTEGER array, dimension (N) */ 00077 /* Details of the interchanges and the block structure of D */ 00078 /* as determined by CHPTRF. */ 00079 00080 /* ANORM (input) REAL */ 00081 /* The 1-norm of the original matrix A. */ 00082 00083 /* RCOND (output) REAL */ 00084 /* The reciprocal of the condition number of the matrix A, */ 00085 /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */ 00086 /* estimate of the 1-norm of inv(A) computed in this routine. */ 00087 00088 /* WORK (workspace) COMPLEX array, dimension (2*N) */ 00089 00090 /* INFO (output) INTEGER */ 00091 /* = 0: successful exit */ 00092 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00093 00094 /* ===================================================================== */ 00095 00096 /* .. Parameters .. */ 00097 /* .. */ 00098 /* .. Local Scalars .. */ 00099 /* .. */ 00100 /* .. Local Arrays .. */ 00101 /* .. */ 00102 /* .. External Functions .. */ 00103 /* .. */ 00104 /* .. External Subroutines .. */ 00105 /* .. */ 00106 /* .. Executable Statements .. */ 00107 00108 /* Test the input parameters. */ 00109 00110 /* Parameter adjustments */ 00111 --work; 00112 --ipiv; 00113 --ap; 00114 00115 /* Function Body */ 00116 *info = 0; 00117 upper = lsame_(uplo, "U"); 00118 if (! upper && ! lsame_(uplo, "L")) { 00119 *info = -1; 00120 } else if (*n < 0) { 00121 *info = -2; 00122 } else if (*anorm < 0.f) { 00123 *info = -5; 00124 } 00125 if (*info != 0) { 00126 i__1 = -(*info); 00127 xerbla_("CHPCON", &i__1); 00128 return 0; 00129 } 00130 00131 /* Quick return if possible */ 00132 00133 *rcond = 0.f; 00134 if (*n == 0) { 00135 *rcond = 1.f; 00136 return 0; 00137 } else if (*anorm <= 0.f) { 00138 return 0; 00139 } 00140 00141 /* Check that the diagonal matrix D is nonsingular. */ 00142 00143 if (upper) { 00144 00145 /* Upper triangular storage: examine D from bottom to top */ 00146 00147 ip = *n * (*n + 1) / 2; 00148 for (i__ = *n; i__ >= 1; --i__) { 00149 i__1 = ip; 00150 if (ipiv[i__] > 0 && (ap[i__1].r == 0.f && ap[i__1].i == 0.f)) { 00151 return 0; 00152 } 00153 ip -= i__; 00154 /* L10: */ 00155 } 00156 } else { 00157 00158 /* Lower triangular storage: examine D from top to bottom. */ 00159 00160 ip = 1; 00161 i__1 = *n; 00162 for (i__ = 1; i__ <= i__1; ++i__) { 00163 i__2 = ip; 00164 if (ipiv[i__] > 0 && (ap[i__2].r == 0.f && ap[i__2].i == 0.f)) { 00165 return 0; 00166 } 00167 ip = ip + *n - i__ + 1; 00168 /* L20: */ 00169 } 00170 } 00171 00172 /* Estimate the 1-norm of the inverse. */ 00173 00174 kase = 0; 00175 L30: 00176 clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); 00177 if (kase != 0) { 00178 00179 /* Multiply by inv(L*D*L') or inv(U*D*U'). */ 00180 00181 chptrs_(uplo, n, &c__1, &ap[1], &ipiv[1], &work[1], n, info); 00182 goto L30; 00183 } 00184 00185 /* Compute the estimate of the reciprocal condition number. */ 00186 00187 if (ainvnm != 0.f) { 00188 *rcond = 1.f / ainvnm / *anorm; 00189 } 00190 00191 return 0; 00192 00193 /* End of CHPCON */ 00194 00195 } /* chpcon_ */