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 doublereal c_b11 = -1.;
00019 static doublereal c_b12 = 0.;
00020
00021 int dpot03_(char *uplo, integer *n, doublereal *a, integer *
00022 lda, doublereal *ainv, integer *ldainv, doublereal *work, integer *
00023 ldwork, doublereal *rwork, doublereal *rcond, doublereal *resid)
00024 {
00025
00026 integer a_dim1, a_offset, ainv_dim1, ainv_offset, work_dim1, work_offset,
00027 i__1, i__2;
00028
00029
00030 integer i__, j;
00031 doublereal eps;
00032 extern logical lsame_(char *, char *);
00033 doublereal anorm;
00034 extern int dsymm_(char *, char *, integer *, integer *,
00035 doublereal *, doublereal *, integer *, doublereal *, integer *,
00036 doublereal *, doublereal *, integer *);
00037 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00038 integer *, doublereal *, integer *, doublereal *);
00039 doublereal ainvnm;
00040 extern doublereal dlansy_(char *, char *, integer *, doublereal *,
00041 integer *, doublereal *);
00042
00043
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 a_dim1 = *lda;
00122 a_offset = 1 + a_dim1;
00123 a -= a_offset;
00124 ainv_dim1 = *ldainv;
00125 ainv_offset = 1 + ainv_dim1;
00126 ainv -= ainv_offset;
00127 work_dim1 = *ldwork;
00128 work_offset = 1 + work_dim1;
00129 work -= work_offset;
00130 --rwork;
00131
00132
00133 if (*n <= 0) {
00134 *rcond = 1.;
00135 *resid = 0.;
00136 return 0;
00137 }
00138
00139
00140
00141 eps = dlamch_("Epsilon");
00142 anorm = dlansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00143 ainvnm = dlansy_("1", uplo, n, &ainv[ainv_offset], ldainv, &rwork[1]);
00144 if (anorm <= 0. || ainvnm <= 0.) {
00145 *rcond = 0.;
00146 *resid = 1. / eps;
00147 return 0;
00148 }
00149 *rcond = 1. / anorm / ainvnm;
00150
00151
00152
00153
00154 if (lsame_(uplo, "U")) {
00155 i__1 = *n;
00156 for (j = 1; j <= i__1; ++j) {
00157 i__2 = j - 1;
00158 for (i__ = 1; i__ <= i__2; ++i__) {
00159 ainv[j + i__ * ainv_dim1] = ainv[i__ + j * ainv_dim1];
00160
00161 }
00162
00163 }
00164 } else {
00165 i__1 = *n;
00166 for (j = 1; j <= i__1; ++j) {
00167 i__2 = *n;
00168 for (i__ = j + 1; i__ <= i__2; ++i__) {
00169 ainv[j + i__ * ainv_dim1] = ainv[i__ + j * ainv_dim1];
00170
00171 }
00172
00173 }
00174 }
00175 dsymm_("Left", uplo, n, n, &c_b11, &a[a_offset], lda, &ainv[ainv_offset],
00176 ldainv, &c_b12, &work[work_offset], ldwork);
00177
00178
00179
00180 i__1 = *n;
00181 for (i__ = 1; i__ <= i__1; ++i__) {
00182 work[i__ + i__ * work_dim1] += 1.;
00183
00184 }
00185
00186
00187
00188 *resid = dlange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00189
00190 *resid = *resid * *rcond / eps / (doublereal) (*n);
00191
00192 return 0;
00193
00194
00195
00196 }