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


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