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 real c_b9 = -1e10f;
00019 static real c_b19 = 0.f;
00020 static real c_b30 = -1.f;
00021 static real c_b31 = 1.f;
00022
00023 int sgrqts_(integer *m, integer *p, integer *n, real *a,
00024 real *af, real *q, real *r__, integer *lda, real *taua, real *b, real
00025 *bf, real *z__, real *t, real *bwk, integer *ldb, real *taub, real *
00026 work, integer *lwork, real *rwork, real *result)
00027 {
00028
00029 integer a_dim1, a_offset, af_dim1, af_offset, r_dim1, r_offset, q_dim1,
00030 q_offset, b_dim1, b_offset, bf_dim1, bf_offset, t_dim1, t_offset,
00031 z_dim1, z_offset, bwk_dim1, bwk_offset, i__1, i__2;
00032 real r__1;
00033
00034
00035 real ulp;
00036 integer info;
00037 real unfl, resid;
00038 extern int sgemm_(char *, char *, integer *, integer *,
00039 integer *, real *, real *, integer *, real *, integer *, real *,
00040 real *, integer *);
00041 real anorm, bnorm;
00042 extern int ssyrk_(char *, char *, integer *, integer *,
00043 real *, real *, integer *, real *, real *, integer *);
00044 extern doublereal slamch_(char *), slange_(char *, integer *,
00045 integer *, real *, integer *, real *);
00046 extern int sggrqf_(integer *, integer *, integer *, real
00047 *, integer *, real *, real *, integer *, real *, real *, integer *
00048 , integer *), slacpy_(char *, integer *, integer *, real *,
00049 integer *, real *, integer *), slaset_(char *, integer *,
00050 integer *, real *, real *, real *, integer *);
00051 extern doublereal slansy_(char *, char *, integer *, real *, integer *,
00052 real *);
00053 extern int sorgqr_(integer *, integer *, integer *, real
00054 *, integer *, real *, real *, integer *, integer *), sorgrq_(
00055 integer *, integer *, integer *, real *, integer *, real *, real *
00056 , integer *, integer *);
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
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 r_dim1 = *lda;
00158 r_offset = 1 + r_dim1;
00159 r__ -= r_offset;
00160 q_dim1 = *lda;
00161 q_offset = 1 + q_dim1;
00162 q -= q_offset;
00163 af_dim1 = *lda;
00164 af_offset = 1 + af_dim1;
00165 af -= af_offset;
00166 a_dim1 = *lda;
00167 a_offset = 1 + a_dim1;
00168 a -= a_offset;
00169 --taua;
00170 bwk_dim1 = *ldb;
00171 bwk_offset = 1 + bwk_dim1;
00172 bwk -= bwk_offset;
00173 t_dim1 = *ldb;
00174 t_offset = 1 + t_dim1;
00175 t -= t_offset;
00176 z_dim1 = *ldb;
00177 z_offset = 1 + z_dim1;
00178 z__ -= z_offset;
00179 bf_dim1 = *ldb;
00180 bf_offset = 1 + bf_dim1;
00181 bf -= bf_offset;
00182 b_dim1 = *ldb;
00183 b_offset = 1 + b_dim1;
00184 b -= b_offset;
00185 --taub;
00186 --work;
00187 --rwork;
00188 --result;
00189
00190
00191 ulp = slamch_("Precision");
00192 unfl = slamch_("Safe minimum");
00193
00194
00195
00196 slacpy_("Full", m, n, &a[a_offset], lda, &af[af_offset], lda);
00197 slacpy_("Full", p, n, &b[b_offset], ldb, &bf[bf_offset], ldb);
00198
00199
00200 r__1 = slange_("1", m, n, &a[a_offset], lda, &rwork[1]);
00201 anorm = dmax(r__1,unfl);
00202
00203 r__1 = slange_("1", p, n, &b[b_offset], ldb, &rwork[1]);
00204 bnorm = dmax(r__1,unfl);
00205
00206
00207
00208 sggrqf_(m, p, n, &af[af_offset], lda, &taua[1], &bf[bf_offset], ldb, &
00209 taub[1], &work[1], lwork, &info);
00210
00211
00212
00213 slaset_("Full", n, n, &c_b9, &c_b9, &q[q_offset], lda);
00214 if (*m <= *n) {
00215 if (*m > 0 && *m < *n) {
00216 i__1 = *n - *m;
00217 slacpy_("Full", m, &i__1, &af[af_offset], lda, &q[*n - *m + 1 +
00218 q_dim1], lda);
00219 }
00220 if (*m > 1) {
00221 i__1 = *m - 1;
00222 i__2 = *m - 1;
00223 slacpy_("Lower", &i__1, &i__2, &af[(*n - *m + 1) * af_dim1 + 2],
00224 lda, &q[*n - *m + 2 + (*n - *m + 1) * q_dim1], lda);
00225 }
00226 } else {
00227 if (*n > 1) {
00228 i__1 = *n - 1;
00229 i__2 = *n - 1;
00230 slacpy_("Lower", &i__1, &i__2, &af[*m - *n + 2 + af_dim1], lda, &
00231 q[q_dim1 + 2], lda);
00232 }
00233 }
00234 i__1 = min(*m,*n);
00235 sorgrq_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00236
00237
00238
00239 slaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb);
00240 if (*p > 1) {
00241 i__1 = *p - 1;
00242 slacpy_("Lower", &i__1, n, &bf[bf_dim1 + 2], ldb, &z__[z_dim1 + 2],
00243 ldb);
00244 }
00245 i__1 = min(*p,*n);
00246 sorgqr_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00247 info);
00248
00249
00250
00251 slaset_("Full", m, n, &c_b19, &c_b19, &r__[r_offset], lda);
00252 if (*m <= *n) {
00253 slacpy_("Upper", m, m, &af[(*n - *m + 1) * af_dim1 + 1], lda, &r__[(*
00254 n - *m + 1) * r_dim1 + 1], lda);
00255 } else {
00256 i__1 = *m - *n;
00257 slacpy_("Full", &i__1, n, &af[af_offset], lda, &r__[r_offset], lda);
00258 slacpy_("Upper", n, n, &af[*m - *n + 1 + af_dim1], lda, &r__[*m - *n
00259 + 1 + r_dim1], lda);
00260 }
00261
00262
00263
00264 slaset_("Full", p, n, &c_b19, &c_b19, &t[t_offset], ldb);
00265 slacpy_("Upper", p, n, &bf[bf_offset], ldb, &t[t_offset], ldb);
00266
00267
00268
00269 sgemm_("No transpose", "Transpose", m, n, n, &c_b30, &a[a_offset], lda, &
00270 q[q_offset], lda, &c_b31, &r__[r_offset], lda);
00271
00272
00273
00274 resid = slange_("1", m, n, &r__[r_offset], lda, &rwork[1]);
00275 if (anorm > 0.f) {
00276
00277 i__1 = max(1,*m);
00278 result[1] = resid / (real) max(i__1,*n) / anorm / ulp;
00279 } else {
00280 result[1] = 0.f;
00281 }
00282
00283
00284
00285 sgemm_("Transpose", "No transpose", p, n, p, &c_b31, &z__[z_offset], ldb,
00286 &b[b_offset], ldb, &c_b19, &bwk[bwk_offset], ldb);
00287 sgemm_("No transpose", "No transpose", p, n, n, &c_b31, &t[t_offset], ldb,
00288 &q[q_offset], lda, &c_b30, &bwk[bwk_offset], ldb);
00289
00290
00291
00292 resid = slange_("1", p, n, &bwk[bwk_offset], ldb, &rwork[1]);
00293 if (bnorm > 0.f) {
00294
00295 i__1 = max(1,*p);
00296 result[2] = resid / (real) max(i__1,*m) / bnorm / ulp;
00297 } else {
00298 result[2] = 0.f;
00299 }
00300
00301
00302
00303 slaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda);
00304 ssyrk_("Upper", "No Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, &
00305 r__[r_offset], lda);
00306
00307
00308
00309 resid = slansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00310 result[3] = resid / (real) max(1,*n) / ulp;
00311
00312
00313
00314 slaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb);
00315 ssyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, &
00316 t[t_offset], ldb);
00317
00318
00319
00320 resid = slansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00321 result[4] = resid / (real) max(1,*p) / ulp;
00322
00323 return 0;
00324
00325
00326
00327 }