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 static doublereal c_b14 = 1.;
00020
00021 int dpot01_(char *uplo, integer *n, doublereal *a, integer *
00022 lda, doublereal *afac, integer *ldafac, doublereal *rwork, doublereal
00023 *resid)
00024 {
00025
00026 integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2;
00027
00028
00029 integer i__, j, k;
00030 doublereal t, eps;
00031 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00032 integer *);
00033 extern int dsyr_(char *, integer *, doublereal *,
00034 doublereal *, integer *, doublereal *, integer *), dscal_(
00035 integer *, doublereal *, doublereal *, integer *);
00036 extern logical lsame_(char *, char *);
00037 doublereal anorm;
00038 extern int dtrmv_(char *, char *, char *, integer *,
00039 doublereal *, integer *, doublereal *, integer *);
00040 extern doublereal dlamch_(char *), dlansy_(char *, char *,
00041 integer *, doublereal *, 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 a_dim1 = *lda;
00113 a_offset = 1 + a_dim1;
00114 a -= a_offset;
00115 afac_dim1 = *ldafac;
00116 afac_offset = 1 + afac_dim1;
00117 afac -= afac_offset;
00118 --rwork;
00119
00120
00121 if (*n <= 0) {
00122 *resid = 0.;
00123 return 0;
00124 }
00125
00126
00127
00128 eps = dlamch_("Epsilon");
00129 anorm = dlansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00130 if (anorm <= 0.) {
00131 *resid = 1. / eps;
00132 return 0;
00133 }
00134
00135
00136
00137 if (lsame_(uplo, "U")) {
00138 for (k = *n; k >= 1; --k) {
00139
00140
00141
00142 t = ddot_(&k, &afac[k * afac_dim1 + 1], &c__1, &afac[k *
00143 afac_dim1 + 1], &c__1);
00144 afac[k + k * afac_dim1] = t;
00145
00146
00147
00148 i__1 = k - 1;
00149 dtrmv_("Upper", "Transpose", "Non-unit", &i__1, &afac[afac_offset]
00150 , ldafac, &afac[k * afac_dim1 + 1], &c__1);
00151
00152
00153 }
00154
00155
00156
00157 } else {
00158 for (k = *n; k >= 1; --k) {
00159
00160
00161
00162
00163 if (k + 1 <= *n) {
00164 i__1 = *n - k;
00165 dsyr_("Lower", &i__1, &c_b14, &afac[k + 1 + k * afac_dim1], &
00166 c__1, &afac[k + 1 + (k + 1) * afac_dim1], ldafac);
00167 }
00168
00169
00170
00171 t = afac[k + k * afac_dim1];
00172 i__1 = *n - k + 1;
00173 dscal_(&i__1, &t, &afac[k + k * afac_dim1], &c__1);
00174
00175
00176 }
00177 }
00178
00179
00180
00181 if (lsame_(uplo, "U")) {
00182 i__1 = *n;
00183 for (j = 1; j <= i__1; ++j) {
00184 i__2 = j;
00185 for (i__ = 1; i__ <= i__2; ++i__) {
00186 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00187
00188 }
00189
00190 }
00191 } else {
00192 i__1 = *n;
00193 for (j = 1; j <= i__1; ++j) {
00194 i__2 = *n;
00195 for (i__ = j; i__ <= i__2; ++i__) {
00196 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00197
00198 }
00199
00200 }
00201 }
00202
00203
00204
00205 *resid = dlansy_("1", uplo, n, &afac[afac_offset], ldafac, &rwork[1]);
00206
00207 *resid = *resid / (doublereal) (*n) / anorm / eps;
00208
00209 return 0;
00210
00211
00212
00213 }