zgqrts.c
Go to the documentation of this file.
00001 /* zgqrts.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 zgqrts_(integer *n, integer *m, integer *p, 
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 zggqrf_(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 /*  ZGQRTS tests ZGGQRF, which computes the GQR factorization of an */
00078 /*  N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z. */
00079 
00080 /*  Arguments */
00081 /*  ========= */
00082 
00083 /*  N       (input) INTEGER */
00084 /*          The number of rows of the matrices A and B.  N >= 0. */
00085 
00086 /*  M       (input) INTEGER */
00087 /*          The number of columns of the matrix A.  M >= 0. */
00088 
00089 /*  P       (input) INTEGER */
00090 /*          The number of columns of the matrix B.  P >= 0. */
00091 
00092 /*  A       (input) COMPLEX*16 array, dimension (LDA,M) */
00093 /*          The N-by-M matrix A. */
00094 
00095 /*  AF      (output) COMPLEX*16 array, dimension (LDA,N) */
00096 /*          Details of the GQR factorization of A and B, as returned */
00097 /*          by ZGGQRF, see CGGQRF for further details. */
00098 
00099 /*  Q       (output) COMPLEX*16 array, dimension (LDA,N) */
00100 /*          The M-by-M 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 ZGGQRF. */
00111 
00112 /*  B       (input) COMPLEX*16 array, dimension (LDB,P) */
00113 /*          On entry, the N-by-P 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 ZGGQRF, see CGGQRF for further details. */
00118 
00119 /*  Z       (output) COMPLEX*16 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(N,M,P)**2. */
00138 
00139 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(N,M,P)) */
00140 
00141 /*  RESULT  (output) DOUBLE PRECISION array, dimension (4) */
00142 /*          The test ratios: */
00143 /*            RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP) */
00144 /*            RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP) */
00145 /*            RESULT(3) = norm( I - Q'*Q ) / ( M*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", n, m, &a[a_offset], lda, &af[af_offset], lda);
00203     zlacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00204 
00205 /* Computing MAX */
00206     d__1 = zlange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00207     anorm = max(d__1,unfl);
00208 /* Computing MAX */
00209     d__1 = zlange_("1", n, p, &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     zggqrf_(n, m, p, &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     i__1 = *n - 1;
00221     zlacpy_("Lower", &i__1, m, &af[af_dim1 + 2], lda, &q[q_dim1 + 2], lda);
00222     i__1 = min(*n,*m);
00223     zungqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info);
00224 
00225 /*     Generate the P-by-P matrix Z */
00226 
00227     zlaset_("Full", p, p, &c_b3, &c_b3, &z__[z_offset], ldb);
00228     if (*n <= *p) {
00229         if (*n > 0 && *n < *p) {
00230             i__1 = *p - *n;
00231             zlacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z__[*p - *n + 1 + 
00232                     z_dim1], ldb);
00233         }
00234         if (*n > 1) {
00235             i__1 = *n - 1;
00236             i__2 = *n - 1;
00237             zlacpy_("Lower", &i__1, &i__2, &bf[(*p - *n + 1) * bf_dim1 + 2], 
00238                     ldb, &z__[*p - *n + 2 + (*p - *n + 1) * z_dim1], ldb);
00239         }
00240     } else {
00241         if (*p > 1) {
00242             i__1 = *p - 1;
00243             i__2 = *p - 1;
00244             zlacpy_("Lower", &i__1, &i__2, &bf[*n - *p + 2 + bf_dim1], ldb, &
00245                     z__[z_dim1 + 2], ldb);
00246         }
00247     }
00248     i__1 = min(*n,*p);
00249     zungrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, &
00250             info);
00251 
00252 /*     Copy R */
00253 
00254     zlaset_("Full", n, m, &c_b1, &c_b1, &r__[r_offset], lda);
00255     zlacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda);
00256 
00257 /*     Copy T */
00258 
00259     zlaset_("Full", n, p, &c_b1, &c_b1, &t[t_offset], ldb);
00260     if (*n <= *p) {
00261         zlacpy_("Upper", n, n, &bf[(*p - *n + 1) * bf_dim1 + 1], ldb, &t[(*p 
00262                 - *n + 1) * t_dim1 + 1], ldb);
00263     } else {
00264         i__1 = *n - *p;
00265         zlacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb);
00266         zlacpy_("Upper", p, p, &bf[*n - *p + 1 + bf_dim1], ldb, &t[*n - *p + 
00267                 1 + t_dim1], ldb);
00268     }
00269 
00270 /*     Compute R - Q'*A */
00271 
00272     z__1.r = -1., z__1.i = -0.;
00273     zgemm_("Conjugate transpose", "No transpose", n, m, n, &z__1, &q[q_offset]
00274 , lda, &a[a_offset], lda, &c_b2, &r__[r_offset], lda);
00275 
00276 /*     Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) . */
00277 
00278     resid = zlange_("1", n, m, &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*Z - Q'*B */
00288 
00289     zgemm_("No Transpose", "No transpose", n, p, p, &c_b2, &t[t_offset], ldb, 
00290             &z__[z_offset], ldb, &c_b1, &bwk[bwk_offset], ldb);
00291     z__1.r = -1., z__1.i = -0.;
00292     zgemm_("Conjugate transpose", "No transpose", n, p, n, &z__1, &q[q_offset]
00293 , lda, &b[b_offset], ldb, &c_b2, &bwk[bwk_offset], ldb);
00294 
00295 /*     Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */
00296 
00297     resid = zlange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]);
00298     if (bnorm > 0.) {
00299 /* Computing MAX */
00300         i__1 = max(1,*p);
00301         result[2] = resid / (doublereal) max(i__1,*n) / bnorm / ulp;
00302     } else {
00303         result[2] = 0.;
00304     }
00305 
00306 /*     Compute I - Q'*Q */
00307 
00308     zlaset_("Full", n, n, &c_b1, &c_b2, &r__[r_offset], lda);
00309     zherk_("Upper", "Conjugate transpose", n, n, &c_b34, &q[q_offset], lda, &
00310             c_b35, &r__[r_offset], lda);
00311 
00312 /*     Compute norm( I - Q'*Q ) / ( N * ULP ) . */
00313 
00314     resid = zlanhe_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]);
00315     result[3] = resid / (doublereal) max(1,*n) / ulp;
00316 
00317 /*     Compute I - Z'*Z */
00318 
00319     zlaset_("Full", p, p, &c_b1, &c_b2, &t[t_offset], ldb);
00320     zherk_("Upper", "Conjugate transpose", p, p, &c_b34, &z__[z_offset], ldb, 
00321             &c_b35, &t[t_offset], ldb);
00322 
00323 /*     Compute norm( I - Z'*Z ) / ( P*ULP ) . */
00324 
00325     resid = zlanhe_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]);
00326     result[4] = resid / (doublereal) max(1,*p) / ulp;
00327 
00328     return 0;
00329 
00330 /*     End of ZGQRTS */
00331 
00332 } /* zgqrts_ */


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