00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 struct {
00019 char srnamt[32];
00020 } srnamc_;
00021
00022 #define srnamc_1 srnamc_
00023
00024
00025
00026 static real c_b4 = -1e10f;
00027 static integer c__2 = 2;
00028 static real c_b22 = -1.f;
00029 static real c_b23 = 1.f;
00030
00031 int srqt03_(integer *m, integer *n, integer *k, real *af,
00032 real *c__, real *cc, real *q, integer *lda, real *tau, real *work,
00033 integer *lwork, real *rwork, real *result)
00034 {
00035
00036
00037 static integer iseed[4] = { 1988,1989,1990,1991 };
00038
00039
00040 integer af_dim1, af_offset, c_dim1, c_offset, cc_dim1, cc_offset, q_dim1,
00041 q_offset, i__1, i__2;
00042
00043
00044 int s_copy(char *, char *, ftnlen, ftnlen);
00045
00046
00047 integer j, mc, nc;
00048 real eps;
00049 char side[1];
00050 integer info, iside;
00051 extern logical lsame_(char *, char *);
00052 real resid;
00053 extern int sgemm_(char *, char *, integer *, integer *,
00054 integer *, real *, real *, integer *, real *, integer *, real *,
00055 real *, integer *);
00056 integer minmn;
00057 real cnorm;
00058 char trans[1];
00059 extern doublereal slamch_(char *), slange_(char *, integer *,
00060 integer *, real *, integer *, real *);
00061 extern int slacpy_(char *, integer *, integer *, real *,
00062 integer *, real *, integer *), slaset_(char *, integer *,
00063 integer *, real *, real *, real *, integer *);
00064 integer itrans;
00065 extern int slarnv_(integer *, integer *, integer *, real
00066 *), sorgrq_(integer *, integer *, integer *, real *, integer *,
00067 real *, real *, integer *, integer *), sormrq_(char *, char *,
00068 integer *, integer *, integer *, real *, integer *, real *, real *
00069 , integer *, real *, integer *, integer *);
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
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 q_dim1 = *lda;
00159 q_offset = 1 + q_dim1;
00160 q -= q_offset;
00161 cc_dim1 = *lda;
00162 cc_offset = 1 + cc_dim1;
00163 cc -= cc_offset;
00164 c_dim1 = *lda;
00165 c_offset = 1 + c_dim1;
00166 c__ -= c_offset;
00167 af_dim1 = *lda;
00168 af_offset = 1 + af_dim1;
00169 af -= af_offset;
00170 --tau;
00171 --work;
00172 --rwork;
00173 --result;
00174
00175
00176
00177
00178
00179 eps = slamch_("Epsilon");
00180 minmn = min(*m,*n);
00181
00182
00183
00184 if (minmn == 0) {
00185 result[1] = 0.f;
00186 result[2] = 0.f;
00187 result[3] = 0.f;
00188 result[4] = 0.f;
00189 return 0;
00190 }
00191
00192
00193
00194 slaset_("Full", n, n, &c_b4, &c_b4, &q[q_offset], lda);
00195 if (*k > 0 && *n > *k) {
00196 i__1 = *n - *k;
00197 slacpy_("Full", k, &i__1, &af[*m - *k + 1 + af_dim1], lda, &q[*n - *k
00198 + 1 + q_dim1], lda);
00199 }
00200 if (*k > 1) {
00201 i__1 = *k - 1;
00202 i__2 = *k - 1;
00203 slacpy_("Lower", &i__1, &i__2, &af[*m - *k + 2 + (*n - *k + 1) *
00204 af_dim1], lda, &q[*n - *k + 2 + (*n - *k + 1) * q_dim1], lda);
00205 }
00206
00207
00208
00209 s_copy(srnamc_1.srnamt, "SORGRQ", (ftnlen)32, (ftnlen)6);
00210 sorgrq_(n, n, k, &q[q_offset], lda, &tau[minmn - *k + 1], &work[1], lwork,
00211 &info);
00212
00213 for (iside = 1; iside <= 2; ++iside) {
00214 if (iside == 1) {
00215 *(unsigned char *)side = 'L';
00216 mc = *n;
00217 nc = *m;
00218 } else {
00219 *(unsigned char *)side = 'R';
00220 mc = *m;
00221 nc = *n;
00222 }
00223
00224
00225
00226 i__1 = nc;
00227 for (j = 1; j <= i__1; ++j) {
00228 slarnv_(&c__2, iseed, &mc, &c__[j * c_dim1 + 1]);
00229
00230 }
00231 cnorm = slange_("1", &mc, &nc, &c__[c_offset], lda, &rwork[1]);
00232 if (cnorm == 0.f) {
00233 cnorm = 1.f;
00234 }
00235
00236 for (itrans = 1; itrans <= 2; ++itrans) {
00237 if (itrans == 1) {
00238 *(unsigned char *)trans = 'N';
00239 } else {
00240 *(unsigned char *)trans = 'T';
00241 }
00242
00243
00244
00245 slacpy_("Full", &mc, &nc, &c__[c_offset], lda, &cc[cc_offset],
00246 lda);
00247
00248
00249
00250 s_copy(srnamc_1.srnamt, "SORMRQ", (ftnlen)32, (ftnlen)6);
00251 if (*k > 0) {
00252 sormrq_(side, trans, &mc, &nc, k, &af[*m - *k + 1 + af_dim1],
00253 lda, &tau[minmn - *k + 1], &cc[cc_offset], lda, &work[
00254 1], lwork, &info);
00255 }
00256
00257
00258
00259 if (lsame_(side, "L")) {
00260 sgemm_(trans, "No transpose", &mc, &nc, &mc, &c_b22, &q[
00261 q_offset], lda, &c__[c_offset], lda, &c_b23, &cc[
00262 cc_offset], lda);
00263 } else {
00264 sgemm_("No transpose", trans, &mc, &nc, &nc, &c_b22, &c__[
00265 c_offset], lda, &q[q_offset], lda, &c_b23, &cc[
00266 cc_offset], lda);
00267 }
00268
00269
00270
00271 resid = slange_("1", &mc, &nc, &cc[cc_offset], lda, &rwork[1]);
00272 result[(iside - 1 << 1) + itrans] = resid / ((real) max(1,*n) *
00273 cnorm * eps);
00274
00275
00276 }
00277
00278 }
00279
00280 return 0;
00281
00282
00283
00284 }