00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019
00020 int ctrcon_(char *norm, char *uplo, char *diag, integer *n,
00021 complex *a, integer *lda, real *rcond, complex *work, real *rwork,
00022 integer *info)
00023 {
00024
00025 integer a_dim1, a_offset, i__1;
00026 real r__1, r__2;
00027
00028
00029 double r_imag(complex *);
00030
00031
00032 integer ix, kase, kase1;
00033 real scale;
00034 extern logical lsame_(char *, char *);
00035 integer isave[3];
00036 real anorm;
00037 logical upper;
00038 extern int clacn2_(integer *, complex *, complex *, real
00039 *, integer *, integer *);
00040 real xnorm;
00041 extern integer icamax_(integer *, complex *, integer *);
00042 extern doublereal slamch_(char *);
00043 extern int xerbla_(char *, integer *);
00044 extern doublereal clantr_(char *, char *, char *, integer *, integer *,
00045 complex *, integer *, real *);
00046 real ainvnm;
00047 extern int clatrs_(char *, char *, char *, char *,
00048 integer *, complex *, integer *, complex *, real *, real *,
00049 integer *), csrscl_(integer *,
00050 real *, complex *, integer *);
00051 logical onenrm;
00052 char normin[1];
00053 real smlnum;
00054 logical nounit;
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 a_dim1 = *lda;
00148 a_offset = 1 + a_dim1;
00149 a -= a_offset;
00150 --work;
00151 --rwork;
00152
00153
00154 *info = 0;
00155 upper = lsame_(uplo, "U");
00156 onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00157 nounit = lsame_(diag, "N");
00158
00159 if (! onenrm && ! lsame_(norm, "I")) {
00160 *info = -1;
00161 } else if (! upper && ! lsame_(uplo, "L")) {
00162 *info = -2;
00163 } else if (! nounit && ! lsame_(diag, "U")) {
00164 *info = -3;
00165 } else if (*n < 0) {
00166 *info = -4;
00167 } else if (*lda < max(1,*n)) {
00168 *info = -6;
00169 }
00170 if (*info != 0) {
00171 i__1 = -(*info);
00172 xerbla_("CTRCON", &i__1);
00173 return 0;
00174 }
00175
00176
00177
00178 if (*n == 0) {
00179 *rcond = 1.f;
00180 return 0;
00181 }
00182
00183 *rcond = 0.f;
00184 smlnum = slamch_("Safe minimum") * (real) max(1,*n);
00185
00186
00187
00188 anorm = clantr_(norm, uplo, diag, n, n, &a[a_offset], lda, &rwork[1]);
00189
00190
00191
00192 if (anorm > 0.f) {
00193
00194
00195
00196 ainvnm = 0.f;
00197 *(unsigned char *)normin = 'N';
00198 if (onenrm) {
00199 kase1 = 1;
00200 } else {
00201 kase1 = 2;
00202 }
00203 kase = 0;
00204 L10:
00205 clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00206 if (kase != 0) {
00207 if (kase == kase1) {
00208
00209
00210
00211 clatrs_(uplo, "No transpose", diag, normin, n, &a[a_offset],
00212 lda, &work[1], &scale, &rwork[1], info);
00213 } else {
00214
00215
00216
00217 clatrs_(uplo, "Conjugate transpose", diag, normin, n, &a[
00218 a_offset], lda, &work[1], &scale, &rwork[1], info);
00219 }
00220 *(unsigned char *)normin = 'Y';
00221
00222
00223
00224 if (scale != 1.f) {
00225 ix = icamax_(n, &work[1], &c__1);
00226 i__1 = ix;
00227 xnorm = (r__1 = work[i__1].r, dabs(r__1)) + (r__2 = r_imag(&
00228 work[ix]), dabs(r__2));
00229 if (scale < xnorm * smlnum || scale == 0.f) {
00230 goto L20;
00231 }
00232 csrscl_(n, &scale, &work[1], &c__1);
00233 }
00234 goto L10;
00235 }
00236
00237
00238
00239 if (ainvnm != 0.f) {
00240 *rcond = 1.f / anorm / ainvnm;
00241 }
00242 }
00243
00244 L20:
00245 return 0;
00246
00247
00248
00249 }