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


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