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