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 dgqrts_(integer *n, integer *m, integer *p, 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 dggqrf_(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", n, m, &a[a_offset], lda, &af[af_offset], lda);
00201 dlacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00202
00203
00204 d__1 = dlange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00205 anorm = max(d__1,unfl);
00206
00207 d__1 = dlange_("1", n, p, &b[b_offset], ldb, &rwork[1]);
00208 bnorm = max(d__1,unfl);
00209
00210
00211
00212 dggqrf_(n, m, p, &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 i__1 = *n - 1;
00219 dlacpy_("Lower", &i__1, m, &af[af_dim1 + 2], lda, &q[q_dim1 + 2], lda);
00220 i__1 = min(*n,*m);
00221 dorgqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00222
00223
00224
00225 dlaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb);
00226 if (*n <= *p) {
00227 if (*n > 0 && *n < *p) {
00228 i__1 = *p - *n;
00229 dlacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z__[*p - *n + 1 +
00230 z_dim1], ldb);
00231 }
00232 if (*n > 1) {
00233 i__1 = *n - 1;
00234 i__2 = *n - 1;
00235 dlacpy_("Lower", &i__1, &i__2, &bf[(*p - *n + 1) * bf_dim1 + 2],
00236 ldb, &z__[*p - *n + 2 + (*p - *n + 1) * z_dim1], ldb);
00237 }
00238 } else {
00239 if (*p > 1) {
00240 i__1 = *p - 1;
00241 i__2 = *p - 1;
00242 dlacpy_("Lower", &i__1, &i__2, &bf[*n - *p + 2 + bf_dim1], ldb, &
00243 z__[z_dim1 + 2], ldb);
00244 }
00245 }
00246 i__1 = min(*n,*p);
00247 dorgrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00248 info);
00249
00250
00251
00252 dlaset_("Full", n, m, &c_b19, &c_b19, &r__[r_offset], lda);
00253 dlacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda);
00254
00255
00256
00257 dlaset_("Full", n, p, &c_b19, &c_b19, &t[t_offset], ldb);
00258 if (*n <= *p) {
00259 dlacpy_("Upper", n, n, &bf[(*p - *n + 1) * bf_dim1 + 1], ldb, &t[(*p
00260 - *n + 1) * t_dim1 + 1], ldb);
00261 } else {
00262 i__1 = *n - *p;
00263 dlacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb);
00264 dlacpy_("Upper", p, p, &bf[*n - *p + 1 + bf_dim1], ldb, &t[*n - *p +
00265 1 + t_dim1], ldb);
00266 }
00267
00268
00269
00270 dgemm_("Transpose", "No transpose", n, m, n, &c_b30, &q[q_offset], lda, &
00271 a[a_offset], lda, &c_b31, &r__[r_offset], lda);
00272
00273
00274
00275 resid = dlange_("1", n, m, &r__[r_offset], lda, &rwork[1]);
00276 if (anorm > 0.) {
00277
00278 i__1 = max(1,*m);
00279 result[1] = resid / (doublereal) max(i__1,*n) / anorm / ulp;
00280 } else {
00281 result[1] = 0.;
00282 }
00283
00284
00285
00286 dgemm_("No Transpose", "No transpose", n, p, p, &c_b31, &t[t_offset], ldb,
00287 &z__[z_offset], ldb, &c_b19, &bwk[bwk_offset], ldb);
00288 dgemm_("Transpose", "No transpose", n, p, n, &c_b30, &q[q_offset], lda, &
00289 b[b_offset], ldb, &c_b31, &bwk[bwk_offset], ldb);
00290
00291
00292
00293 resid = dlange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]);
00294 if (bnorm > 0.) {
00295
00296 i__1 = max(1,*p);
00297 result[2] = resid / (doublereal) max(i__1,*n) / bnorm / ulp;
00298 } else {
00299 result[2] = 0.;
00300 }
00301
00302
00303
00304 dlaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda);
00305 dsyrk_("Upper", "Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, &
00306 r__[r_offset], lda);
00307
00308
00309
00310 resid = dlansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00311 result[3] = resid / (doublereal) max(1,*n) / ulp;
00312
00313
00314
00315 dlaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb);
00316 dsyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, &
00317 t[t_offset], ldb);
00318
00319
00320
00321 resid = dlansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00322 result[4] = resid / (doublereal) max(1,*p) / ulp;
00323
00324 return 0;
00325
00326
00327
00328 }