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 complex c_b1 = {0.f,0.f};
00019
00020 int cpot03_(char *uplo, integer *n, complex *a, integer *lda,
00021 complex *ainv, integer *ldainv, complex *work, integer *ldwork, real
00022 *rwork, real *rcond, real *resid)
00023 {
00024
00025 integer a_dim1, a_offset, ainv_dim1, ainv_offset, work_dim1, work_offset,
00026 i__1, i__2, i__3;
00027 complex q__1;
00028
00029
00030 void r_cnjg(complex *, complex *);
00031
00032
00033 integer i__, j;
00034 real eps;
00035 extern int chemm_(char *, char *, integer *, integer *,
00036 complex *, complex *, integer *, complex *, integer *, complex *,
00037 complex *, integer *);
00038 extern logical lsame_(char *, char *);
00039 real anorm;
00040 extern doublereal clange_(char *, integer *, integer *, complex *,
00041 integer *, real *), clanhe_(char *, char *, integer *,
00042 complex *, integer *, real *), slamch_(char *);
00043 real ainvnm;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
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 a_dim1 = *lda;
00124 a_offset = 1 + a_dim1;
00125 a -= a_offset;
00126 ainv_dim1 = *ldainv;
00127 ainv_offset = 1 + ainv_dim1;
00128 ainv -= ainv_offset;
00129 work_dim1 = *ldwork;
00130 work_offset = 1 + work_dim1;
00131 work -= work_offset;
00132 --rwork;
00133
00134
00135 if (*n <= 0) {
00136 *rcond = 1.f;
00137 *resid = 0.f;
00138 return 0;
00139 }
00140
00141
00142
00143 eps = slamch_("Epsilon");
00144 anorm = clanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00145 ainvnm = clanhe_("1", uplo, n, &ainv[ainv_offset], ldainv, &rwork[1]);
00146 if (anorm <= 0.f || ainvnm <= 0.f) {
00147 *rcond = 0.f;
00148 *resid = 1.f / eps;
00149 return 0;
00150 }
00151 *rcond = 1.f / anorm / ainvnm;
00152
00153
00154
00155
00156 if (lsame_(uplo, "U")) {
00157 i__1 = *n;
00158 for (j = 1; j <= i__1; ++j) {
00159 i__2 = j - 1;
00160 for (i__ = 1; i__ <= i__2; ++i__) {
00161 i__3 = j + i__ * ainv_dim1;
00162 r_cnjg(&q__1, &ainv[i__ + j * ainv_dim1]);
00163 ainv[i__3].r = q__1.r, ainv[i__3].i = q__1.i;
00164
00165 }
00166
00167 }
00168 } else {
00169 i__1 = *n;
00170 for (j = 1; j <= i__1; ++j) {
00171 i__2 = *n;
00172 for (i__ = j + 1; i__ <= i__2; ++i__) {
00173 i__3 = j + i__ * ainv_dim1;
00174 r_cnjg(&q__1, &ainv[i__ + j * ainv_dim1]);
00175 ainv[i__3].r = q__1.r, ainv[i__3].i = q__1.i;
00176
00177 }
00178
00179 }
00180 }
00181 q__1.r = -1.f, q__1.i = -0.f;
00182 chemm_("Left", uplo, n, n, &q__1, &a[a_offset], lda, &ainv[ainv_offset],
00183 ldainv, &c_b1, &work[work_offset], ldwork);
00184
00185
00186
00187 i__1 = *n;
00188 for (i__ = 1; i__ <= i__1; ++i__) {
00189 i__2 = i__ + i__ * work_dim1;
00190 i__3 = i__ + i__ * work_dim1;
00191 q__1.r = work[i__3].r + 1.f, q__1.i = work[i__3].i + 0.f;
00192 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00193
00194 }
00195
00196
00197
00198 *resid = clange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00199
00200 *resid = *resid * *rcond / eps / (real) (*n);
00201
00202 return 0;
00203
00204
00205
00206 }