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