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