sgrqts.c
Go to the documentation of this file.
00001 /* sgrqts.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
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 /* Subroutine */ int sgrqts_(integer *m, integer *p, integer *n, 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     /* System generated locals */
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     /* Local variables */
00035     real ulp;
00036     integer info;
00037     real unfl, resid;
00038     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00039             integer *, real *, real *, integer *, real *, integer *, real *, 
00040             real *, integer *);
00041     real anorm, bnorm;
00042     extern /* Subroutine */ 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 /* Subroutine */ int sggrqf_(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 /* Subroutine */ 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 /*  -- LAPACK test routine (version 3.1) -- */
00060 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00061 /*     November 2006 */
00062 
00063 /*     .. Scalar Arguments .. */
00064 /*     .. */
00065 /*     .. Array Arguments .. */
00066 /*     .. */
00067 
00068 /*  Purpose */
00069 /*  ======= */
00070 
00071 /*  SGRQTS tests SGGRQF, which computes the GRQ factorization of an */
00072 /*  M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q. */
00073 
00074 /*  Arguments */
00075 /*  ========= */
00076 
00077 /*  M       (input) INTEGER */
00078 /*          The number of rows of the matrix A.  M >= 0. */
00079 
00080 /*  P       (input) INTEGER */
00081 /*          The number of rows of the matrix B.  P >= 0. */
00082 
00083 /*  N       (input) INTEGER */
00084 /*          The number of columns of the matrices A and B.  N >= 0. */
00085 
00086 /*  A       (input) REAL array, dimension (LDA,N) */
00087 /*          The M-by-N matrix A. */
00088 
00089 /*  AF      (output) REAL array, dimension (LDA,N) */
00090 /*          Details of the GRQ factorization of A and B, as returned */
00091 /*          by SGGRQF, see SGGRQF for further details. */
00092 
00093 /*  Q       (output) REAL array, dimension (LDA,N) */
00094 /*          The N-by-N orthogonal matrix Q. */
00095 
00096 /*  R       (workspace) REAL array, dimension (LDA,MAX(M,N)) */
00097 
00098 /*  LDA     (input) INTEGER */
00099 /*          The leading dimension of the arrays A, AF, R and Q. */
00100 /*          LDA >= max(M,N). */
00101 
00102 /*  TAUA    (output) REAL array, dimension (min(M,N)) */
00103 /*          The scalar factors of the elementary reflectors, as returned */
00104 /*          by SGGQRC. */
00105 
00106 /*  B       (input) REAL array, dimension (LDB,N) */
00107 /*          On entry, the P-by-N matrix A. */
00108 
00109 /*  BF      (output) REAL array, dimension (LDB,N) */
00110 /*          Details of the GQR factorization of A and B, as returned */
00111 /*          by SGGRQF, see SGGRQF for further details. */
00112 
00113 /*  Z       (output) REAL array, dimension (LDB,P) */
00114 /*          The P-by-P orthogonal matrix Z. */
00115 
00116 /*  T       (workspace) REAL array, dimension (LDB,max(P,N)) */
00117 
00118 /*  BWK     (workspace) REAL array, dimension (LDB,N) */
00119 
00120 /*  LDB     (input) INTEGER */
00121 /*          The leading dimension of the arrays B, BF, Z and T. */
00122 /*          LDB >= max(P,N). */
00123 
00124 /*  TAUB    (output) REAL array, dimension (min(P,N)) */
00125 /*          The scalar factors of the elementary reflectors, as returned */
00126 /*          by SGGRQF. */
00127 
00128 /*  WORK    (workspace) REAL array, dimension (LWORK) */
00129 
00130 /*  LWORK   (input) INTEGER */
00131 /*          The dimension of the array WORK, LWORK >= max(M,P,N)**2. */
00132 
00133 /*  RWORK   (workspace) REAL array, dimension (M) */
00134 
00135 /*  RESULT  (output) REAL array, dimension (4) */
00136 /*          The test ratios: */
00137 /*            RESULT(1) = norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP) */
00138 /*            RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP) */
00139 /*            RESULT(3) = norm( I - Q'*Q ) / ( N*ULP ) */
00140 /*            RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) */
00141 
00142 /*  ===================================================================== */
00143 
00144 /*     .. Parameters .. */
00145 /*     .. */
00146 /*     .. Local Scalars .. */
00147 /*     .. */
00148 /*     .. External Functions .. */
00149 /*     .. */
00150 /*     .. External Subroutines .. */
00151 /*     .. */
00152 /*     .. Intrinsic Functions .. */
00153 /*     .. */
00154 /*     .. Executable Statements .. */
00155 
00156     /* Parameter adjustments */
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     /* Function Body */
00191     ulp = slamch_("Precision");
00192     unfl = slamch_("Safe minimum");
00193 
00194 /*     Copy the matrix A to the array AF. */
00195 
00196     slacpy_("Full", m, n, &a[a_offset], lda, &af[af_offset], lda);
00197     slacpy_("Full", p, n, &b[b_offset], ldb, &bf[bf_offset], ldb);
00198 
00199 /* Computing MAX */
00200     r__1 = slange_("1", m, n, &a[a_offset], lda, &rwork[1]);
00201     anorm = dmax(r__1,unfl);
00202 /* Computing MAX */
00203     r__1 = slange_("1", p, n, &b[b_offset], ldb, &rwork[1]);
00204     bnorm = dmax(r__1,unfl);
00205 
00206 /*     Factorize the matrices A and B in the arrays AF and BF. */
00207 
00208     sggrqf_(m, p, n, &af[af_offset], lda, &taua[1], &bf[bf_offset], ldb, &
00209             taub[1], &work[1], lwork, &info);
00210 
00211 /*     Generate the N-by-N matrix Q */
00212 
00213     slaset_("Full", n, n, &c_b9, &c_b9, &q[q_offset], lda);
00214     if (*m <= *n) {
00215         if (*m > 0 && *m < *n) {
00216             i__1 = *n - *m;
00217             slacpy_("Full", m, &i__1, &af[af_offset], lda, &q[*n - *m + 1 + 
00218                     q_dim1], lda);
00219         }
00220         if (*m > 1) {
00221             i__1 = *m - 1;
00222             i__2 = *m - 1;
00223             slacpy_("Lower", &i__1, &i__2, &af[(*n - *m + 1) * af_dim1 + 2], 
00224                     lda, &q[*n - *m + 2 + (*n - *m + 1) * q_dim1], lda);
00225         }
00226     } else {
00227         if (*n > 1) {
00228             i__1 = *n - 1;
00229             i__2 = *n - 1;
00230             slacpy_("Lower", &i__1, &i__2, &af[*m - *n + 2 + af_dim1], lda, &
00231                     q[q_dim1 + 2], lda);
00232         }
00233     }
00234     i__1 = min(*m,*n);
00235     sorgrq_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00236 
00237 /*     Generate the P-by-P matrix Z */
00238 
00239     slaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb);
00240     if (*p > 1) {
00241         i__1 = *p - 1;
00242         slacpy_("Lower", &i__1, n, &bf[bf_dim1 + 2], ldb, &z__[z_dim1 + 2], 
00243                 ldb);
00244     }
00245     i__1 = min(*p,*n);
00246     sorgqr_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00247             info);
00248 
00249 /*     Copy R */
00250 
00251     slaset_("Full", m, n, &c_b19, &c_b19, &r__[r_offset], lda);
00252     if (*m <= *n) {
00253         slacpy_("Upper", m, m, &af[(*n - *m + 1) * af_dim1 + 1], lda, &r__[(*
00254                 n - *m + 1) * r_dim1 + 1], lda);
00255     } else {
00256         i__1 = *m - *n;
00257         slacpy_("Full", &i__1, n, &af[af_offset], lda, &r__[r_offset], lda);
00258         slacpy_("Upper", n, n, &af[*m - *n + 1 + af_dim1], lda, &r__[*m - *n 
00259                 + 1 + r_dim1], lda);
00260     }
00261 
00262 /*     Copy T */
00263 
00264     slaset_("Full", p, n, &c_b19, &c_b19, &t[t_offset], ldb);
00265     slacpy_("Upper", p, n, &bf[bf_offset], ldb, &t[t_offset], ldb);
00266 
00267 /*     Compute R - A*Q' */
00268 
00269     sgemm_("No transpose", "Transpose", m, n, n, &c_b30, &a[a_offset], lda, &
00270             q[q_offset], lda, &c_b31, &r__[r_offset], lda);
00271 
00272 /*     Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) . */
00273 
00274     resid = slange_("1", m, n, &r__[r_offset], lda, &rwork[1]);
00275     if (anorm > 0.f) {
00276 /* Computing MAX */
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 /*     Compute T*Q - Z'*B */
00284 
00285     sgemm_("Transpose", "No transpose", p, n, p, &c_b31, &z__[z_offset], ldb, 
00286             &b[b_offset], ldb, &c_b19, &bwk[bwk_offset], ldb);
00287     sgemm_("No transpose", "No transpose", p, n, n, &c_b31, &t[t_offset], ldb, 
00288              &q[q_offset], lda, &c_b30, &bwk[bwk_offset], ldb);
00289 
00290 /*     Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */
00291 
00292     resid = slange_("1", p, n, &bwk[bwk_offset], ldb, &rwork[1]);
00293     if (bnorm > 0.f) {
00294 /* Computing MAX */
00295         i__1 = max(1,*p);
00296         result[2] = resid / (real) max(i__1,*m) / bnorm / ulp;
00297     } else {
00298         result[2] = 0.f;
00299     }
00300 
00301 /*     Compute I - Q*Q' */
00302 
00303     slaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda);
00304     ssyrk_("Upper", "No Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, &
00305             r__[r_offset], lda);
00306 
00307 /*     Compute norm( I - Q'*Q ) / ( N * ULP ) . */
00308 
00309     resid = slansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00310     result[3] = resid / (real) max(1,*n) / ulp;
00311 
00312 /*     Compute I - Z'*Z */
00313 
00314     slaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb);
00315     ssyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, &
00316             t[t_offset], ldb);
00317 
00318 /*     Compute norm( I - Z'*Z ) / ( P*ULP ) . */
00319 
00320     resid = slansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00321     result[4] = resid / (real) max(1,*p) / ulp;
00322 
00323     return 0;
00324 
00325 /*     End of SGRQTS */
00326 
00327 } /* sgrqts_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:09