dgrqts.c
Go to the documentation of this file.
00001 /* dgrqts.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 doublereal c_b9 = -1e10;
00019 static doublereal c_b19 = 0.;
00020 static doublereal c_b30 = -1.;
00021 static doublereal c_b31 = 1.;
00022 
00023 /* Subroutine */ int dgrqts_(integer *m, integer *p, integer *n, doublereal *
00024         a, doublereal *af, doublereal *q, doublereal *r__, integer *lda, 
00025         doublereal *taua, doublereal *b, doublereal *bf, doublereal *z__, 
00026         doublereal *t, doublereal *bwk, integer *ldb, doublereal *taub, 
00027         doublereal *work, integer *lwork, doublereal *rwork, doublereal *
00028         result)
00029 {
00030     /* System generated locals */
00031     integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, bf_dim1, 
00032             bf_offset, bwk_dim1, bwk_offset, q_dim1, q_offset, r_dim1, 
00033             r_offset, t_dim1, t_offset, z_dim1, z_offset, i__1, i__2;
00034     doublereal d__1;
00035 
00036     /* Local variables */
00037     doublereal ulp;
00038     integer info;
00039     doublereal unfl;
00040     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00041             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00042             integer *, doublereal *, doublereal *, integer *);
00043     doublereal resid, anorm, bnorm;
00044     extern /* Subroutine */ int dsyrk_(char *, char *, integer *, integer *, 
00045             doublereal *, doublereal *, integer *, doublereal *, doublereal *, 
00046              integer *);
00047     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00048             integer *, doublereal *, integer *, doublereal *);
00049     extern /* Subroutine */ int dggrqf_(integer *, integer *, integer *, 
00050             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00051             doublereal *, doublereal *, integer *, integer *), dlacpy_(char *, 
00052              integer *, integer *, doublereal *, integer *, doublereal *, 
00053             integer *), dlaset_(char *, integer *, integer *, 
00054             doublereal *, doublereal *, doublereal *, integer *);
00055     extern doublereal dlansy_(char *, char *, integer *, doublereal *, 
00056             integer *, doublereal *);
00057     extern /* Subroutine */ int dorgqr_(integer *, integer *, integer *, 
00058             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00059             integer *), dorgrq_(integer *, integer *, integer *, doublereal *, 
00060              integer *, doublereal *, doublereal *, integer *, integer *);
00061 
00062 
00063 /*  -- LAPACK test routine (version 3.1) -- */
00064 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00065 /*     November 2006 */
00066 
00067 /*     .. Scalar Arguments .. */
00068 /*     .. */
00069 /*     .. Array Arguments .. */
00070 /*     .. */
00071 
00072 /*  Purpose */
00073 /*  ======= */
00074 
00075 /*  DGRQTS tests DGGRQF, which computes the GRQ factorization of an */
00076 /*  M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q. */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  M       (input) INTEGER */
00082 /*          The number of rows of the matrix A.  M >= 0. */
00083 
00084 /*  P       (input) INTEGER */
00085 /*          The number of rows of the matrix B.  P >= 0. */
00086 
00087 /*  N       (input) INTEGER */
00088 /*          The number of columns of the matrices A and B.  N >= 0. */
00089 
00090 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00091 /*          The M-by-N matrix A. */
00092 
00093 /*  AF      (output) DOUBLE PRECISION array, dimension (LDA,N) */
00094 /*          Details of the GRQ factorization of A and B, as returned */
00095 /*          by DGGRQF, see SGGRQF for further details. */
00096 
00097 /*  Q       (output) DOUBLE PRECISION array, dimension (LDA,N) */
00098 /*          The N-by-N orthogonal matrix Q. */
00099 
00100 /*  R       (workspace) DOUBLE PRECISION array, dimension (LDA,MAX(M,N)) */
00101 
00102 /*  LDA     (input) INTEGER */
00103 /*          The leading dimension of the arrays A, AF, R and Q. */
00104 /*          LDA >= max(M,N). */
00105 
00106 /*  TAUA    (output) DOUBLE PRECISION array, dimension (min(M,N)) */
00107 /*          The scalar factors of the elementary reflectors, as returned */
00108 /*          by DGGQRC. */
00109 
00110 /*  B       (input) DOUBLE PRECISION array, dimension (LDB,N) */
00111 /*          On entry, the P-by-N matrix A. */
00112 
00113 /*  BF      (output) DOUBLE PRECISION array, dimension (LDB,N) */
00114 /*          Details of the GQR factorization of A and B, as returned */
00115 /*          by DGGRQF, see SGGRQF for further details. */
00116 
00117 /*  Z       (output) DOUBLE PRECISION array, dimension (LDB,P) */
00118 /*          The P-by-P orthogonal matrix Z. */
00119 
00120 /*  T       (workspace) DOUBLE PRECISION array, dimension (LDB,max(P,N)) */
00121 
00122 /*  BWK     (workspace) DOUBLE PRECISION array, dimension (LDB,N) */
00123 
00124 /*  LDB     (input) INTEGER */
00125 /*          The leading dimension of the arrays B, BF, Z and T. */
00126 /*          LDB >= max(P,N). */
00127 
00128 /*  TAUB    (output) DOUBLE PRECISION array, dimension (min(P,N)) */
00129 /*          The scalar factors of the elementary reflectors, as returned */
00130 /*          by DGGRQF. */
00131 
00132 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00133 
00134 /*  LWORK   (input) INTEGER */
00135 /*          The dimension of the array WORK, LWORK >= max(M,P,N)**2. */
00136 
00137 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (M) */
00138 
00139 /*  RESULT  (output) DOUBLE PRECISION array, dimension (4) */
00140 /*          The test ratios: */
00141 /*            RESULT(1) = norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP) */
00142 /*            RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP) */
00143 /*            RESULT(3) = norm( I - Q'*Q ) / ( N*ULP ) */
00144 /*            RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) */
00145 
00146 /*  ===================================================================== */
00147 
00148 /*     .. Parameters .. */
00149 /*     .. */
00150 /*     .. Local Scalars .. */
00151 /*     .. */
00152 /*     .. External Functions .. */
00153 /*     .. */
00154 /*     .. External Subroutines .. */
00155 /*     .. */
00156 /*     .. Intrinsic Functions .. */
00157 /*     .. */
00158 /*     .. Executable Statements .. */
00159 
00160     /* Parameter adjustments */
00161     r_dim1 = *lda;
00162     r_offset = 1 + r_dim1;
00163     r__ -= r_offset;
00164     q_dim1 = *lda;
00165     q_offset = 1 + q_dim1;
00166     q -= q_offset;
00167     af_dim1 = *lda;
00168     af_offset = 1 + af_dim1;
00169     af -= af_offset;
00170     a_dim1 = *lda;
00171     a_offset = 1 + a_dim1;
00172     a -= a_offset;
00173     --taua;
00174     bwk_dim1 = *ldb;
00175     bwk_offset = 1 + bwk_dim1;
00176     bwk -= bwk_offset;
00177     t_dim1 = *ldb;
00178     t_offset = 1 + t_dim1;
00179     t -= t_offset;
00180     z_dim1 = *ldb;
00181     z_offset = 1 + z_dim1;
00182     z__ -= z_offset;
00183     bf_dim1 = *ldb;
00184     bf_offset = 1 + bf_dim1;
00185     bf -= bf_offset;
00186     b_dim1 = *ldb;
00187     b_offset = 1 + b_dim1;
00188     b -= b_offset;
00189     --taub;
00190     --work;
00191     --rwork;
00192     --result;
00193 
00194     /* Function Body */
00195     ulp = dlamch_("Precision");
00196     unfl = dlamch_("Safe minimum");
00197 
00198 /*     Copy the matrix A to the array AF. */
00199 
00200     dlacpy_("Full", m, n, &a[a_offset], lda, &af[af_offset], lda);
00201     dlacpy_("Full", p, n, &b[b_offset], ldb, &bf[bf_offset], ldb);
00202 
00203 /* Computing MAX */
00204     d__1 = dlange_("1", m, n, &a[a_offset], lda, &rwork[1]);
00205     anorm = max(d__1,unfl);
00206 /* Computing MAX */
00207     d__1 = dlange_("1", p, n, &b[b_offset], ldb, &rwork[1]);
00208     bnorm = max(d__1,unfl);
00209 
00210 /*     Factorize the matrices A and B in the arrays AF and BF. */
00211 
00212     dggrqf_(m, p, n, &af[af_offset], lda, &taua[1], &bf[bf_offset], ldb, &
00213             taub[1], &work[1], lwork, &info);
00214 
00215 /*     Generate the N-by-N matrix Q */
00216 
00217     dlaset_("Full", n, n, &c_b9, &c_b9, &q[q_offset], lda);
00218     if (*m <= *n) {
00219         if (*m > 0 && *m < *n) {
00220             i__1 = *n - *m;
00221             dlacpy_("Full", m, &i__1, &af[af_offset], lda, &q[*n - *m + 1 + 
00222                     q_dim1], lda);
00223         }
00224         if (*m > 1) {
00225             i__1 = *m - 1;
00226             i__2 = *m - 1;
00227             dlacpy_("Lower", &i__1, &i__2, &af[(*n - *m + 1) * af_dim1 + 2], 
00228                     lda, &q[*n - *m + 2 + (*n - *m + 1) * q_dim1], lda);
00229         }
00230     } else {
00231         if (*n > 1) {
00232             i__1 = *n - 1;
00233             i__2 = *n - 1;
00234             dlacpy_("Lower", &i__1, &i__2, &af[*m - *n + 2 + af_dim1], lda, &
00235                     q[q_dim1 + 2], lda);
00236         }
00237     }
00238     i__1 = min(*m,*n);
00239     dorgrq_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00240 
00241 /*     Generate the P-by-P matrix Z */
00242 
00243     dlaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb);
00244     if (*p > 1) {
00245         i__1 = *p - 1;
00246         dlacpy_("Lower", &i__1, n, &bf[bf_dim1 + 2], ldb, &z__[z_dim1 + 2], 
00247                 ldb);
00248     }
00249     i__1 = min(*p,*n);
00250     dorgqr_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00251             info);
00252 
00253 /*     Copy R */
00254 
00255     dlaset_("Full", m, n, &c_b19, &c_b19, &r__[r_offset], lda);
00256     if (*m <= *n) {
00257         dlacpy_("Upper", m, m, &af[(*n - *m + 1) * af_dim1 + 1], lda, &r__[(*
00258                 n - *m + 1) * r_dim1 + 1], lda);
00259     } else {
00260         i__1 = *m - *n;
00261         dlacpy_("Full", &i__1, n, &af[af_offset], lda, &r__[r_offset], lda);
00262         dlacpy_("Upper", n, n, &af[*m - *n + 1 + af_dim1], lda, &r__[*m - *n 
00263                 + 1 + r_dim1], lda);
00264     }
00265 
00266 /*     Copy T */
00267 
00268     dlaset_("Full", p, n, &c_b19, &c_b19, &t[t_offset], ldb);
00269     dlacpy_("Upper", p, n, &bf[bf_offset], ldb, &t[t_offset], ldb);
00270 
00271 /*     Compute R - A*Q' */
00272 
00273     dgemm_("No transpose", "Transpose", m, n, n, &c_b30, &a[a_offset], lda, &
00274             q[q_offset], lda, &c_b31, &r__[r_offset], lda);
00275 
00276 /*     Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) . */
00277 
00278     resid = dlange_("1", m, n, &r__[r_offset], lda, &rwork[1]);
00279     if (anorm > 0.) {
00280 /* Computing MAX */
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 /*     Compute T*Q - Z'*B */
00288 
00289     dgemm_("Transpose", "No transpose", p, n, p, &c_b31, &z__[z_offset], ldb, 
00290             &b[b_offset], ldb, &c_b19, &bwk[bwk_offset], ldb);
00291     dgemm_("No transpose", "No transpose", p, n, n, &c_b31, &t[t_offset], ldb, 
00292              &q[q_offset], lda, &c_b30, &bwk[bwk_offset], ldb);
00293 
00294 /*     Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */
00295 
00296     resid = dlange_("1", p, n, &bwk[bwk_offset], ldb, &rwork[1]);
00297     if (bnorm > 0.) {
00298 /* Computing MAX */
00299         i__1 = max(1,*p);
00300         result[2] = resid / (doublereal) max(i__1,*m) / bnorm / ulp;
00301     } else {
00302         result[2] = 0.;
00303     }
00304 
00305 /*     Compute I - Q*Q' */
00306 
00307     dlaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda);
00308     dsyrk_("Upper", "No Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, &
00309             r__[r_offset], lda);
00310 
00311 /*     Compute norm( I - Q'*Q ) / ( N * ULP ) . */
00312 
00313     resid = dlansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00314     result[3] = resid / (doublereal) max(1,*n) / ulp;
00315 
00316 /*     Compute I - Z'*Z */
00317 
00318     dlaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb);
00319     dsyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, &
00320             t[t_offset], ldb);
00321 
00322 /*     Compute norm( I - Z'*Z ) / ( P*ULP ) . */
00323 
00324     resid = dlansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00325     result[4] = resid / (doublereal) max(1,*p) / ulp;
00326 
00327     return 0;
00328 
00329 /*     End of DGRQTS */
00330 
00331 } /* dgrqts_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:45