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