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