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 zgqrts_(integer *n, integer *m, integer *p,
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 zggqrf_(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", n, m, &a[a_offset], lda, &af[af_offset], lda);
00203 zlacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00204
00205
00206 d__1 = zlange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00207 anorm = max(d__1,unfl);
00208
00209 d__1 = zlange_("1", n, p, &b[b_offset], ldb, &rwork[1]);
00210 bnorm = max(d__1,unfl);
00211
00212
00213
00214 zggqrf_(n, m, p, &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 i__1 = *n - 1;
00221 zlacpy_("Lower", &i__1, m, &af[af_dim1 + 2], lda, &q[q_dim1 + 2], lda);
00222 i__1 = min(*n,*m);
00223 zungqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00224
00225
00226
00227 zlaset_("Full", p, p, &c_b3, &c_b3, &z__[z_offset], ldb);
00228 if (*n <= *p) {
00229 if (*n > 0 && *n < *p) {
00230 i__1 = *p - *n;
00231 zlacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z__[*p - *n + 1 +
00232 z_dim1], ldb);
00233 }
00234 if (*n > 1) {
00235 i__1 = *n - 1;
00236 i__2 = *n - 1;
00237 zlacpy_("Lower", &i__1, &i__2, &bf[(*p - *n + 1) * bf_dim1 + 2],
00238 ldb, &z__[*p - *n + 2 + (*p - *n + 1) * z_dim1], ldb);
00239 }
00240 } else {
00241 if (*p > 1) {
00242 i__1 = *p - 1;
00243 i__2 = *p - 1;
00244 zlacpy_("Lower", &i__1, &i__2, &bf[*n - *p + 2 + bf_dim1], ldb, &
00245 z__[z_dim1 + 2], ldb);
00246 }
00247 }
00248 i__1 = min(*n,*p);
00249 zungrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00250 info);
00251
00252
00253
00254 zlaset_("Full", n, m, &c_b1, &c_b1, &r__[r_offset], lda);
00255 zlacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda);
00256
00257
00258
00259 zlaset_("Full", n, p, &c_b1, &c_b1, &t[t_offset], ldb);
00260 if (*n <= *p) {
00261 zlacpy_("Upper", n, n, &bf[(*p - *n + 1) * bf_dim1 + 1], ldb, &t[(*p
00262 - *n + 1) * t_dim1 + 1], ldb);
00263 } else {
00264 i__1 = *n - *p;
00265 zlacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb);
00266 zlacpy_("Upper", p, p, &bf[*n - *p + 1 + bf_dim1], ldb, &t[*n - *p +
00267 1 + t_dim1], ldb);
00268 }
00269
00270
00271
00272 z__1.r = -1., z__1.i = -0.;
00273 zgemm_("Conjugate transpose", "No transpose", n, m, n, &z__1, &q[q_offset]
00274 , lda, &a[a_offset], lda, &c_b2, &r__[r_offset], lda);
00275
00276
00277
00278 resid = zlange_("1", n, m, &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 zgemm_("No Transpose", "No transpose", n, p, p, &c_b2, &t[t_offset], ldb,
00290 &z__[z_offset], ldb, &c_b1, &bwk[bwk_offset], ldb);
00291 z__1.r = -1., z__1.i = -0.;
00292 zgemm_("Conjugate transpose", "No transpose", n, p, n, &z__1, &q[q_offset]
00293 , lda, &b[b_offset], ldb, &c_b2, &bwk[bwk_offset], ldb);
00294
00295
00296
00297 resid = zlange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]);
00298 if (bnorm > 0.) {
00299
00300 i__1 = max(1,*p);
00301 result[2] = resid / (doublereal) max(i__1,*n) / bnorm / ulp;
00302 } else {
00303 result[2] = 0.;
00304 }
00305
00306
00307
00308 zlaset_("Full", n, n, &c_b1, &c_b2, &r__[r_offset], lda);
00309 zherk_("Upper", "Conjugate transpose", n, n, &c_b34, &q[q_offset], lda, &
00310 c_b35, &r__[r_offset], lda);
00311
00312
00313
00314 resid = zlanhe_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00315 result[3] = resid / (doublereal) max(1,*n) / ulp;
00316
00317
00318
00319 zlaset_("Full", p, p, &c_b1, &c_b2, &t[t_offset], ldb);
00320 zherk_("Upper", "Conjugate transpose", p, p, &c_b34, &z__[z_offset], ldb,
00321 &c_b35, &t[t_offset], ldb);
00322
00323
00324
00325 resid = zlanhe_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00326 result[4] = resid / (doublereal) max(1,*p) / ulp;
00327
00328 return 0;
00329
00330
00331
00332 }