clqt03.c
Go to the documentation of this file.
00001 /* clqt03.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 /* Common Block Declarations */
00017 
00018 struct {
00019     char srnamt[32];
00020 } srnamc_;
00021 
00022 #define srnamc_1 srnamc_
00023 
00024 /* Table of constant values */
00025 
00026 static complex c_b1 = {-1e10f,-1e10f};
00027 static integer c__2 = 2;
00028 static complex c_b20 = {-1.f,0.f};
00029 static complex c_b21 = {1.f,0.f};
00030 
00031 /* Subroutine */ int clqt03_(integer *m, integer *n, integer *k, complex *af, 
00032         complex *c__, complex *cc, complex *q, integer *lda, complex *tau, 
00033         complex *work, integer *lwork, real *rwork, real *result)
00034 {
00035     /* Initialized data */
00036 
00037     static integer iseed[4] = { 1988,1989,1990,1991 };
00038 
00039     /* System generated locals */
00040     integer af_dim1, af_offset, c_dim1, c_offset, cc_dim1, cc_offset, q_dim1, 
00041             q_offset, i__1;
00042 
00043     /* Builtin functions */
00044     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00045 
00046     /* Local variables */
00047     integer j, mc, nc;
00048     real eps;
00049     char side[1];
00050     integer info;
00051     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00052             integer *, complex *, complex *, integer *, complex *, integer *, 
00053             complex *, complex *, integer *);
00054     integer iside;
00055     extern logical lsame_(char *, char *);
00056     real resid, cnorm;
00057     char trans[1];
00058     extern doublereal clange_(char *, integer *, integer *, complex *, 
00059             integer *, real *), slamch_(char *);
00060     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00061             *, integer *, complex *, integer *), claset_(char *, 
00062             integer *, integer *, complex *, complex *, complex *, integer *), clarnv_(integer *, integer *, integer *, complex *), 
00063             cunglq_(integer *, integer *, integer *, complex *, integer *, 
00064             complex *, complex *, integer *, integer *), cunmlq_(char *, char 
00065             *, integer *, integer *, integer *, complex *, integer *, complex 
00066             *, complex *, integer *, complex *, integer *, integer *);
00067     integer itrans;
00068 
00069 
00070 /*  -- LAPACK test routine (version 3.1) -- */
00071 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00072 /*     November 2006 */
00073 
00074 /*     .. Scalar Arguments .. */
00075 /*     .. */
00076 /*     .. Array Arguments .. */
00077 /*     .. */
00078 
00079 /*  Purpose */
00080 /*  ======= */
00081 
00082 /*  CLQT03 tests CUNMLQ, which computes Q*C, Q'*C, C*Q or C*Q'. */
00083 
00084 /*  CLQT03 compares the results of a call to CUNMLQ with the results of */
00085 /*  forming Q explicitly by a call to CUNGLQ and then performing matrix */
00086 /*  multiplication by a call to CGEMM. */
00087 
00088 /*  Arguments */
00089 /*  ========= */
00090 
00091 /*  M       (input) INTEGER */
00092 /*          The number of rows or columns of the matrix C; C is n-by-m if */
00093 /*          Q is applied from the left, or m-by-n if Q is applied from */
00094 /*          the right.  M >= 0. */
00095 
00096 /*  N       (input) INTEGER */
00097 /*          The order of the orthogonal matrix Q.  N >= 0. */
00098 
00099 /*  K       (input) INTEGER */
00100 /*          The number of elementary reflectors whose product defines the */
00101 /*          orthogonal matrix Q.  N >= K >= 0. */
00102 
00103 /*  AF      (input) COMPLEX array, dimension (LDA,N) */
00104 /*          Details of the LQ factorization of an m-by-n matrix, as */
00105 /*          returned by CGELQF. See CGELQF for further details. */
00106 
00107 /*  C       (workspace) COMPLEX array, dimension (LDA,N) */
00108 
00109 /*  CC      (workspace) COMPLEX array, dimension (LDA,N) */
00110 
00111 /*  Q       (workspace) COMPLEX array, dimension (LDA,N) */
00112 
00113 /*  LDA     (input) INTEGER */
00114 /*          The leading dimension of the arrays AF, C, CC, and Q. */
00115 
00116 /*  TAU     (input) COMPLEX array, dimension (min(M,N)) */
00117 /*          The scalar factors of the elementary reflectors corresponding */
00118 /*          to the LQ factorization in AF. */
00119 
00120 /*  WORK    (workspace) COMPLEX array, dimension (LWORK) */
00121 
00122 /*  LWORK   (input) INTEGER */
00123 /*          The length of WORK.  LWORK must be at least M, and should be */
00124 /*          M*NB, where NB is the blocksize for this environment. */
00125 
00126 /*  RWORK   (workspace) REAL array, dimension (M) */
00127 
00128 /*  RESULT  (output) REAL array, dimension (4) */
00129 /*          The test ratios compare two techniques for multiplying a */
00130 /*          random matrix C by an n-by-n orthogonal matrix Q. */
00131 /*          RESULT(1) = norm( Q*C - Q*C )  / ( N * norm(C) * EPS ) */
00132 /*          RESULT(2) = norm( C*Q - C*Q )  / ( N * norm(C) * EPS ) */
00133 /*          RESULT(3) = norm( Q'*C - Q'*C )/ ( N * norm(C) * EPS ) */
00134 /*          RESULT(4) = norm( C*Q' - C*Q' )/ ( N * norm(C) * EPS ) */
00135 
00136 /*  ===================================================================== */
00137 
00138 /*     .. Parameters .. */
00139 /*     .. */
00140 /*     .. Local Scalars .. */
00141 /*     .. */
00142 /*     .. External Functions .. */
00143 /*     .. */
00144 /*     .. External Subroutines .. */
00145 /*     .. */
00146 /*     .. Local Arrays .. */
00147 /*     .. */
00148 /*     .. Intrinsic Functions .. */
00149 /*     .. */
00150 /*     .. Scalars in Common .. */
00151 /*     .. */
00152 /*     .. Common blocks .. */
00153 /*     .. */
00154 /*     .. Data statements .. */
00155     /* Parameter adjustments */
00156     q_dim1 = *lda;
00157     q_offset = 1 + q_dim1;
00158     q -= q_offset;
00159     cc_dim1 = *lda;
00160     cc_offset = 1 + cc_dim1;
00161     cc -= cc_offset;
00162     c_dim1 = *lda;
00163     c_offset = 1 + c_dim1;
00164     c__ -= c_offset;
00165     af_dim1 = *lda;
00166     af_offset = 1 + af_dim1;
00167     af -= af_offset;
00168     --tau;
00169     --work;
00170     --rwork;
00171     --result;
00172 
00173     /* Function Body */
00174 /*     .. */
00175 /*     .. Executable Statements .. */
00176 
00177     eps = slamch_("Epsilon");
00178 
00179 /*     Copy the first k rows of the factorization to the array Q */
00180 
00181     claset_("Full", n, n, &c_b1, &c_b1, &q[q_offset], lda);
00182     i__1 = *n - 1;
00183     clacpy_("Upper", k, &i__1, &af[(af_dim1 << 1) + 1], lda, &q[(q_dim1 << 1) 
00184             + 1], lda);
00185 
00186 /*     Generate the n-by-n matrix Q */
00187 
00188     s_copy(srnamc_1.srnamt, "CUNGLQ", (ftnlen)32, (ftnlen)6);
00189     cunglq_(n, n, k, &q[q_offset], lda, &tau[1], &work[1], lwork, &info);
00190 
00191     for (iside = 1; iside <= 2; ++iside) {
00192         if (iside == 1) {
00193             *(unsigned char *)side = 'L';
00194             mc = *n;
00195             nc = *m;
00196         } else {
00197             *(unsigned char *)side = 'R';
00198             mc = *m;
00199             nc = *n;
00200         }
00201 
00202 /*        Generate MC by NC matrix C */
00203 
00204         i__1 = nc;
00205         for (j = 1; j <= i__1; ++j) {
00206             clarnv_(&c__2, iseed, &mc, &c__[j * c_dim1 + 1]);
00207 /* L10: */
00208         }
00209         cnorm = clange_("1", &mc, &nc, &c__[c_offset], lda, &rwork[1]);
00210         if (cnorm == 0.f) {
00211             cnorm = 1.f;
00212         }
00213 
00214         for (itrans = 1; itrans <= 2; ++itrans) {
00215             if (itrans == 1) {
00216                 *(unsigned char *)trans = 'N';
00217             } else {
00218                 *(unsigned char *)trans = 'C';
00219             }
00220 
00221 /*           Copy C */
00222 
00223             clacpy_("Full", &mc, &nc, &c__[c_offset], lda, &cc[cc_offset], 
00224                     lda);
00225 
00226 /*           Apply Q or Q' to C */
00227 
00228             s_copy(srnamc_1.srnamt, "CUNMLQ", (ftnlen)32, (ftnlen)6);
00229             cunmlq_(side, trans, &mc, &nc, k, &af[af_offset], lda, &tau[1], &
00230                     cc[cc_offset], lda, &work[1], lwork, &info);
00231 
00232 /*           Form explicit product and subtract */
00233 
00234             if (lsame_(side, "L")) {
00235                 cgemm_(trans, "No transpose", &mc, &nc, &mc, &c_b20, &q[
00236                         q_offset], lda, &c__[c_offset], lda, &c_b21, &cc[
00237                         cc_offset], lda);
00238             } else {
00239                 cgemm_("No transpose", trans, &mc, &nc, &nc, &c_b20, &c__[
00240                         c_offset], lda, &q[q_offset], lda, &c_b21, &cc[
00241                         cc_offset], lda);
00242             }
00243 
00244 /*           Compute error in the difference */
00245 
00246             resid = clange_("1", &mc, &nc, &cc[cc_offset], lda, &rwork[1]);
00247             result[(iside - 1 << 1) + itrans] = resid / ((real) max(1,*n) * 
00248                     cnorm * eps);
00249 
00250 /* L20: */
00251         }
00252 /* L30: */
00253     }
00254 
00255     return 0;
00256 
00257 /*     End of CLQT03 */
00258 
00259 } /* clqt03_ */


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