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