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


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