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