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