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


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