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


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