dgqrts.c
Go to the documentation of this file.
00001 /* dgqrts.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 dgqrts_(integer *n, integer *m, integer *p, 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 dggqrf_(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 /*  DGQRTS tests DGGQRF, which computes the GQR factorization of an */
00076 /*  N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z. */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  N       (input) INTEGER */
00082 /*          The number of rows of the matrices A and B.  N >= 0. */
00083 
00084 /*  M       (input) INTEGER */
00085 /*          The number of columns of the matrix A.  M >= 0. */
00086 
00087 /*  P       (input) INTEGER */
00088 /*          The number of columns of the matrix B.  P >= 0. */
00089 
00090 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,M) */
00091 /*          The N-by-M matrix A. */
00092 
00093 /*  AF      (output) DOUBLE PRECISION array, dimension (LDA,N) */
00094 /*          Details of the GQR factorization of A and B, as returned */
00095 /*          by DGGQRF, see SGGQRF for further details. */
00096 
00097 /*  Q       (output) DOUBLE PRECISION array, dimension (LDA,N) */
00098 /*          The M-by-M 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 DGGQRF. */
00109 
00110 /*  B       (input) DOUBLE PRECISION array, dimension (LDB,P) */
00111 /*          On entry, the N-by-P 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 DGGQRF, see SGGQRF 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(N,M,P)**2. */
00136 
00137 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(N,M,P)) */
00138 
00139 /*  RESULT  (output) DOUBLE PRECISION array, dimension (4) */
00140 /*          The test ratios: */
00141 /*            RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP) */
00142 /*            RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP) */
00143 /*            RESULT(3) = norm( I - Q'*Q ) / ( M*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", n, m, &a[a_offset], lda, &af[af_offset], lda);
00201     dlacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00202 
00203 /* Computing MAX */
00204     d__1 = dlange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00205     anorm = max(d__1,unfl);
00206 /* Computing MAX */
00207     d__1 = dlange_("1", n, p, &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     dggqrf_(n, m, p, &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     i__1 = *n - 1;
00219     dlacpy_("Lower", &i__1, m, &af[af_dim1 + 2], lda, &q[q_dim1 + 2], lda);
00220     i__1 = min(*n,*m);
00221     dorgqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00222 
00223 /*     Generate the P-by-P matrix Z */
00224 
00225     dlaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb);
00226     if (*n <= *p) {
00227         if (*n > 0 && *n < *p) {
00228             i__1 = *p - *n;
00229             dlacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z__[*p - *n + 1 + 
00230                     z_dim1], ldb);
00231         }
00232         if (*n > 1) {
00233             i__1 = *n - 1;
00234             i__2 = *n - 1;
00235             dlacpy_("Lower", &i__1, &i__2, &bf[(*p - *n + 1) * bf_dim1 + 2], 
00236                     ldb, &z__[*p - *n + 2 + (*p - *n + 1) * z_dim1], ldb);
00237         }
00238     } else {
00239         if (*p > 1) {
00240             i__1 = *p - 1;
00241             i__2 = *p - 1;
00242             dlacpy_("Lower", &i__1, &i__2, &bf[*n - *p + 2 + bf_dim1], ldb, &
00243                     z__[z_dim1 + 2], ldb);
00244         }
00245     }
00246     i__1 = min(*n,*p);
00247     dorgrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00248             info);
00249 
00250 /*     Copy R */
00251 
00252     dlaset_("Full", n, m, &c_b19, &c_b19, &r__[r_offset], lda);
00253     dlacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda);
00254 
00255 /*     Copy T */
00256 
00257     dlaset_("Full", n, p, &c_b19, &c_b19, &t[t_offset], ldb);
00258     if (*n <= *p) {
00259         dlacpy_("Upper", n, n, &bf[(*p - *n + 1) * bf_dim1 + 1], ldb, &t[(*p 
00260                 - *n + 1) * t_dim1 + 1], ldb);
00261     } else {
00262         i__1 = *n - *p;
00263         dlacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb);
00264         dlacpy_("Upper", p, p, &bf[*n - *p + 1 + bf_dim1], ldb, &t[*n - *p + 
00265                 1 + t_dim1], ldb);
00266     }
00267 
00268 /*     Compute R - Q'*A */
00269 
00270     dgemm_("Transpose", "No transpose", n, m, n, &c_b30, &q[q_offset], lda, &
00271             a[a_offset], lda, &c_b31, &r__[r_offset], lda);
00272 
00273 /*     Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) . */
00274 
00275     resid = dlange_("1", n, m, &r__[r_offset], lda, &rwork[1]);
00276     if (anorm > 0.) {
00277 /* Computing MAX */
00278         i__1 = max(1,*m);
00279         result[1] = resid / (doublereal) max(i__1,*n) / anorm / ulp;
00280     } else {
00281         result[1] = 0.;
00282     }
00283 
00284 /*     Compute T*Z - Q'*B */
00285 
00286     dgemm_("No Transpose", "No transpose", n, p, p, &c_b31, &t[t_offset], ldb, 
00287              &z__[z_offset], ldb, &c_b19, &bwk[bwk_offset], ldb);
00288     dgemm_("Transpose", "No transpose", n, p, n, &c_b30, &q[q_offset], lda, &
00289             b[b_offset], ldb, &c_b31, &bwk[bwk_offset], ldb);
00290 
00291 /*     Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */
00292 
00293     resid = dlange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]);
00294     if (bnorm > 0.) {
00295 /* Computing MAX */
00296         i__1 = max(1,*p);
00297         result[2] = resid / (doublereal) max(i__1,*n) / bnorm / ulp;
00298     } else {
00299         result[2] = 0.;
00300     }
00301 
00302 /*     Compute I - Q'*Q */
00303 
00304     dlaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda);
00305     dsyrk_("Upper", "Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, &
00306             r__[r_offset], lda);
00307 
00308 /*     Compute norm( I - Q'*Q ) / ( N * ULP ) . */
00309 
00310     resid = dlansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00311     result[3] = resid / (doublereal) max(1,*n) / ulp;
00312 
00313 /*     Compute I - Z'*Z */
00314 
00315     dlaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb);
00316     dsyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, &
00317             t[t_offset], ldb);
00318 
00319 /*     Compute norm( I - Z'*Z ) / ( P*ULP ) . */
00320 
00321     resid = dlansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00322     result[4] = resid / (doublereal) max(1,*p) / ulp;
00323 
00324     return 0;
00325 
00326 /*     End of DGQRTS */
00327 
00328 } /* dgqrts_ */


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