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