drqt02.c
Go to the documentation of this file.
00001 /* drqt02.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 doublereal c_b10 = 0.;
00028 static doublereal c_b15 = -1.;
00029 static doublereal c_b16 = 1.;
00030 
00031 /* Subroutine */ int drqt02_(integer *m, integer *n, integer *k, doublereal *
00032         a, doublereal *af, doublereal *q, doublereal *r__, integer *lda, 
00033         doublereal *tau, doublereal *work, integer *lwork, doublereal *rwork, 
00034         doublereal *result)
00035 {
00036     /* System generated locals */
00037     integer a_dim1, a_offset, af_dim1, af_offset, q_dim1, q_offset, r_dim1, 
00038             r_offset, i__1, i__2;
00039 
00040     /* Builtin functions */
00041     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00042 
00043     /* Local variables */
00044     doublereal eps;
00045     integer info;
00046     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00047             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00048             integer *, doublereal *, doublereal *, integer *);
00049     doublereal resid, anorm;
00050     extern /* Subroutine */ int dsyrk_(char *, char *, integer *, integer *, 
00051             doublereal *, doublereal *, integer *, doublereal *, doublereal *, 
00052              integer *);
00053     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00054             integer *, doublereal *, integer *, doublereal *);
00055     extern /* Subroutine */ int dlacpy_(char *, integer *, integer *, 
00056             doublereal *, integer *, doublereal *, integer *), 
00057             dlaset_(char *, integer *, integer *, doublereal *, doublereal *, 
00058             doublereal *, integer *);
00059     extern doublereal dlansy_(char *, char *, integer *, doublereal *, 
00060             integer *, doublereal *);
00061     extern /* Subroutine */ int dorgrq_(integer *, integer *, integer *, 
00062             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00063             integer *);
00064 
00065 
00066 /*  -- LAPACK test routine (version 3.1) -- */
00067 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00068 /*     November 2006 */
00069 
00070 /*     .. Scalar Arguments .. */
00071 /*     .. */
00072 /*     .. Array Arguments .. */
00073 /*     .. */
00074 
00075 /*  Purpose */
00076 /*  ======= */
00077 
00078 /*  DRQT02 tests DORGRQ, which generates an m-by-n matrix Q with */
00079 /*  orthonornmal rows that is defined as the product of k elementary */
00080 /*  reflectors. */
00081 
00082 /*  Given the RQ factorization of an m-by-n matrix A, DRQT02 generates */
00083 /*  the orthogonal matrix Q defined by the factorization of the last k */
00084 /*  rows of A; it compares R(m-k+1:m,n-m+1:n) with */
00085 /*  A(m-k+1:m,1:n)*Q(n-m+1:n,1:n)', and checks that the rows of Q are */
00086 /*  orthonormal. */
00087 
00088 /*  Arguments */
00089 /*  ========= */
00090 
00091 /*  M       (input) INTEGER */
00092 /*          The number of rows of the matrix Q to be generated.  M >= 0. */
00093 
00094 /*  N       (input) INTEGER */
00095 /*          The number of columns of the matrix Q to be generated. */
00096 /*          N >= M >= 0. */
00097 
00098 /*  K       (input) INTEGER */
00099 /*          The number of elementary reflectors whose product defines the */
00100 /*          matrix Q. M >= K >= 0. */
00101 
00102 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00103 /*          The m-by-n matrix A which was factorized by DRQT01. */
00104 
00105 /*  AF      (input) DOUBLE PRECISION array, dimension (LDA,N) */
00106 /*          Details of the RQ factorization of A, as returned by DGERQF. */
00107 /*          See DGERQF for further details. */
00108 
00109 /*  Q       (workspace) DOUBLE PRECISION array, dimension (LDA,N) */
00110 
00111 /*  R       (workspace) DOUBLE PRECISION array, dimension (LDA,M) */
00112 
00113 /*  LDA     (input) INTEGER */
00114 /*          The leading dimension of the arrays A, AF, Q and L. LDA >= N. */
00115 
00116 /*  TAU     (input) DOUBLE PRECISION array, dimension (M) */
00117 /*          The scalar factors of the elementary reflectors corresponding */
00118 /*          to the RQ factorization in AF. */
00119 
00120 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00121 
00122 /*  LWORK   (input) INTEGER */
00123 /*          The dimension of the array WORK. */
00124 
00125 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (M) */
00126 
00127 /*  RESULT  (output) DOUBLE PRECISION array, dimension (2) */
00128 /*          The test ratios: */
00129 /*          RESULT(1) = norm( R - A*Q' ) / ( N * norm(A) * EPS ) */
00130 /*          RESULT(2) = norm( I - Q*Q' ) / ( N * EPS ) */
00131 
00132 /*  ===================================================================== */
00133 
00134 /*     .. Parameters .. */
00135 /*     .. */
00136 /*     .. Local Scalars .. */
00137 /*     .. */
00138 /*     .. External Functions .. */
00139 /*     .. */
00140 /*     .. External Subroutines .. */
00141 /*     .. */
00142 /*     .. Intrinsic Functions .. */
00143 /*     .. */
00144 /*     .. Scalars in Common .. */
00145 /*     .. */
00146 /*     .. Common blocks .. */
00147 /*     .. */
00148 /*     .. Executable Statements .. */
00149 
00150 /*     Quick return if possible */
00151 
00152     /* Parameter adjustments */
00153     r_dim1 = *lda;
00154     r_offset = 1 + r_dim1;
00155     r__ -= r_offset;
00156     q_dim1 = *lda;
00157     q_offset = 1 + q_dim1;
00158     q -= q_offset;
00159     af_dim1 = *lda;
00160     af_offset = 1 + af_dim1;
00161     af -= af_offset;
00162     a_dim1 = *lda;
00163     a_offset = 1 + a_dim1;
00164     a -= a_offset;
00165     --tau;
00166     --work;
00167     --rwork;
00168     --result;
00169 
00170     /* Function Body */
00171     if (*m == 0 || *n == 0 || *k == 0) {
00172         result[1] = 0.;
00173         result[2] = 0.;
00174         return 0;
00175     }
00176 
00177     eps = dlamch_("Epsilon");
00178 
00179 /*     Copy the last k rows of the factorization to the array Q */
00180 
00181     dlaset_("Full", m, n, &c_b4, &c_b4, &q[q_offset], lda);
00182     if (*k < *n) {
00183         i__1 = *n - *k;
00184         dlacpy_("Full", k, &i__1, &af[*m - *k + 1 + af_dim1], lda, &q[*m - *k 
00185                 + 1 + q_dim1], lda);
00186     }
00187     if (*k > 1) {
00188         i__1 = *k - 1;
00189         i__2 = *k - 1;
00190         dlacpy_("Lower", &i__1, &i__2, &af[*m - *k + 2 + (*n - *k + 1) * 
00191                 af_dim1], lda, &q[*m - *k + 2 + (*n - *k + 1) * q_dim1], lda);
00192     }
00193 
00194 /*     Generate the last n rows of the matrix Q */
00195 
00196     s_copy(srnamc_1.srnamt, "DORGRQ", (ftnlen)32, (ftnlen)6);
00197     dorgrq_(m, n, k, &q[q_offset], lda, &tau[*m - *k + 1], &work[1], lwork, &
00198             info);
00199 
00200 /*     Copy R(m-k+1:m,n-m+1:n) */
00201 
00202     dlaset_("Full", k, m, &c_b10, &c_b10, &r__[*m - *k + 1 + (*n - *m + 1) * 
00203             r_dim1], lda);
00204     dlacpy_("Upper", k, k, &af[*m - *k + 1 + (*n - *k + 1) * af_dim1], lda, &
00205             r__[*m - *k + 1 + (*n - *k + 1) * r_dim1], lda);
00206 
00207 /*     Compute R(m-k+1:m,n-m+1:n) - A(m-k+1:m,1:n) * Q(n-m+1:n,1:n)' */
00208 
00209     dgemm_("No transpose", "Transpose", k, m, n, &c_b15, &a[*m - *k + 1 + 
00210             a_dim1], lda, &q[q_offset], lda, &c_b16, &r__[*m - *k + 1 + (*n - 
00211             *m + 1) * r_dim1], lda);
00212 
00213 /*     Compute norm( R - A*Q' ) / ( N * norm(A) * EPS ) . */
00214 
00215     anorm = dlange_("1", k, n, &a[*m - *k + 1 + a_dim1], lda, &rwork[1]);
00216     resid = dlange_("1", k, m, &r__[*m - *k + 1 + (*n - *m + 1) * r_dim1], 
00217             lda, &rwork[1]);
00218     if (anorm > 0.) {
00219         result[1] = resid / (doublereal) max(1,*n) / anorm / eps;
00220     } else {
00221         result[1] = 0.;
00222     }
00223 
00224 /*     Compute I - Q*Q' */
00225 
00226     dlaset_("Full", m, m, &c_b10, &c_b16, &r__[r_offset], lda);
00227     dsyrk_("Upper", "No transpose", m, n, &c_b15, &q[q_offset], lda, &c_b16, &
00228             r__[r_offset], lda);
00229 
00230 /*     Compute norm( I - Q*Q' ) / ( N * EPS ) . */
00231 
00232     resid = dlansy_("1", "Upper", m, &r__[r_offset], lda, &rwork[1]);
00233 
00234     result[2] = resid / (doublereal) max(1,*n) / eps;
00235 
00236     return 0;
00237 
00238 /*     End of DRQT02 */
00239 
00240 } /* drqt02_ */


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