LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cqrt02.f
Go to the documentation of this file.
00001 *> \brief \b CQRT02
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE CQRT02( M, N, K, A, AF, Q, R, LDA, TAU, WORK, LWORK,
00012 *                          RWORK, RESULT )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       INTEGER            K, LDA, LWORK, M, N
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       REAL               RESULT( * ), RWORK( * )
00019 *       COMPLEX            A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00020 *      $                   R( LDA, * ), TAU( * ), WORK( LWORK )
00021 *       ..
00022 *  
00023 *
00024 *> \par Purpose:
00025 *  =============
00026 *>
00027 *> \verbatim
00028 *>
00029 *> CQRT02 tests CUNGQR, which generates an m-by-n matrix Q with
00030 *> orthonornmal columns that is defined as the product of k elementary
00031 *> reflectors.
00032 *>
00033 *> Given the QR factorization of an m-by-n matrix A, CQRT02 generates
00034 *> the orthogonal matrix Q defined by the factorization of the first k
00035 *> columns of A; it compares R(1:n,1:k) with Q(1:m,1:n)'*A(1:m,1:k),
00036 *> and checks that the columns of Q are orthonormal.
00037 *> \endverbatim
00038 *
00039 *  Arguments:
00040 *  ==========
00041 *
00042 *> \param[in] M
00043 *> \verbatim
00044 *>          M is INTEGER
00045 *>          The number of rows of the matrix Q to be generated.  M >= 0.
00046 *> \endverbatim
00047 *>
00048 *> \param[in] N
00049 *> \verbatim
00050 *>          N is INTEGER
00051 *>          The number of columns of the matrix Q to be generated.
00052 *>          M >= N >= 0.
00053 *> \endverbatim
00054 *>
00055 *> \param[in] K
00056 *> \verbatim
00057 *>          K is INTEGER
00058 *>          The number of elementary reflectors whose product defines the
00059 *>          matrix Q. N >= K >= 0.
00060 *> \endverbatim
00061 *>
00062 *> \param[in] A
00063 *> \verbatim
00064 *>          A is COMPLEX array, dimension (LDA,N)
00065 *>          The m-by-n matrix A which was factorized by CQRT01.
00066 *> \endverbatim
00067 *>
00068 *> \param[in] AF
00069 *> \verbatim
00070 *>          AF is COMPLEX array, dimension (LDA,N)
00071 *>          Details of the QR factorization of A, as returned by CGEQRF.
00072 *>          See CGEQRF for further details.
00073 *> \endverbatim
00074 *>
00075 *> \param[out] Q
00076 *> \verbatim
00077 *>          Q is COMPLEX array, dimension (LDA,N)
00078 *> \endverbatim
00079 *>
00080 *> \param[out] R
00081 *> \verbatim
00082 *>          R is COMPLEX array, dimension (LDA,N)
00083 *> \endverbatim
00084 *>
00085 *> \param[in] LDA
00086 *> \verbatim
00087 *>          LDA is INTEGER
00088 *>          The leading dimension of the arrays A, AF, Q and R. LDA >= M.
00089 *> \endverbatim
00090 *>
00091 *> \param[in] TAU
00092 *> \verbatim
00093 *>          TAU is COMPLEX array, dimension (N)
00094 *>          The scalar factors of the elementary reflectors corresponding
00095 *>          to the QR factorization in AF.
00096 *> \endverbatim
00097 *>
00098 *> \param[out] WORK
00099 *> \verbatim
00100 *>          WORK is COMPLEX array, dimension (LWORK)
00101 *> \endverbatim
00102 *>
00103 *> \param[in] LWORK
00104 *> \verbatim
00105 *>          LWORK is INTEGER
00106 *>          The dimension of the array WORK.
00107 *> \endverbatim
00108 *>
00109 *> \param[out] RWORK
00110 *> \verbatim
00111 *>          RWORK is REAL array, dimension (M)
00112 *> \endverbatim
00113 *>
00114 *> \param[out] RESULT
00115 *> \verbatim
00116 *>          RESULT is REAL array, dimension (2)
00117 *>          The test ratios:
00118 *>          RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
00119 *>          RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
00120 *> \endverbatim
00121 *
00122 *  Authors:
00123 *  ========
00124 *
00125 *> \author Univ. of Tennessee 
00126 *> \author Univ. of California Berkeley 
00127 *> \author Univ. of Colorado Denver 
00128 *> \author NAG Ltd. 
00129 *
00130 *> \date November 2011
00131 *
00132 *> \ingroup complex_lin
00133 *
00134 *  =====================================================================
00135       SUBROUTINE CQRT02( M, N, K, A, AF, Q, R, LDA, TAU, WORK, LWORK,
00136      $                   RWORK, RESULT )
00137 *
00138 *  -- LAPACK test routine (version 3.4.0) --
00139 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00140 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00141 *     November 2011
00142 *
00143 *     .. Scalar Arguments ..
00144       INTEGER            K, LDA, LWORK, M, N
00145 *     ..
00146 *     .. Array Arguments ..
00147       REAL               RESULT( * ), RWORK( * )
00148       COMPLEX            A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00149      $                   R( LDA, * ), TAU( * ), WORK( LWORK )
00150 *     ..
00151 *
00152 *  =====================================================================
00153 *
00154 *     .. Parameters ..
00155       REAL               ZERO, ONE
00156       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00157       COMPLEX            ROGUE
00158       PARAMETER          ( ROGUE = ( -1.0E+10, -1.0E+10 ) )
00159 *     ..
00160 *     .. Local Scalars ..
00161       INTEGER            INFO
00162       REAL               ANORM, EPS, RESID
00163 *     ..
00164 *     .. External Functions ..
00165       REAL               CLANGE, CLANSY, SLAMCH
00166       EXTERNAL           CLANGE, CLANSY, SLAMCH
00167 *     ..
00168 *     .. External Subroutines ..
00169       EXTERNAL           CGEMM, CHERK, CLACPY, CLASET, CUNGQR
00170 *     ..
00171 *     .. Intrinsic Functions ..
00172       INTRINSIC          CMPLX, MAX, REAL
00173 *     ..
00174 *     .. Scalars in Common ..
00175       CHARACTER*32       SRNAMT
00176 *     ..
00177 *     .. Common blocks ..
00178       COMMON             / SRNAMC / SRNAMT
00179 *     ..
00180 *     .. Executable Statements ..
00181 *
00182       EPS = SLAMCH( 'Epsilon' )
00183 *
00184 *     Copy the first k columns of the factorization to the array Q
00185 *
00186       CALL CLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
00187       CALL CLACPY( 'Lower', M-1, K, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
00188 *
00189 *     Generate the first n columns of the matrix Q
00190 *
00191       SRNAMT = 'CUNGQR'
00192       CALL CUNGQR( M, N, K, Q, LDA, TAU, WORK, LWORK, INFO )
00193 *
00194 *     Copy R(1:n,1:k)
00195 *
00196       CALL CLASET( 'Full', N, K, CMPLX( ZERO ), CMPLX( ZERO ), R, LDA )
00197       CALL CLACPY( 'Upper', N, K, AF, LDA, R, LDA )
00198 *
00199 *     Compute R(1:n,1:k) - Q(1:m,1:n)' * A(1:m,1:k)
00200 *
00201       CALL CGEMM( 'Conjugate transpose', 'No transpose', N, K, M,
00202      $            CMPLX( -ONE ), Q, LDA, A, LDA, CMPLX( ONE ), R, LDA )
00203 *
00204 *     Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
00205 *
00206       ANORM = CLANGE( '1', M, K, A, LDA, RWORK )
00207       RESID = CLANGE( '1', N, K, R, LDA, RWORK )
00208       IF( ANORM.GT.ZERO ) THEN
00209          RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS
00210       ELSE
00211          RESULT( 1 ) = ZERO
00212       END IF
00213 *
00214 *     Compute I - Q'*Q
00215 *
00216       CALL CLASET( 'Full', N, N, CMPLX( ZERO ), CMPLX( ONE ), R, LDA )
00217       CALL CHERK( 'Upper', 'Conjugate transpose', N, M, -ONE, Q, LDA,
00218      $            ONE, R, LDA )
00219 *
00220 *     Compute norm( I - Q'*Q ) / ( M * EPS ) .
00221 *
00222       RESID = CLANSY( '1', 'Upper', N, R, LDA, RWORK )
00223 *
00224       RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS
00225 *
00226       RETURN
00227 *
00228 *     End of CQRT02
00229 *
00230       END
 All Files Functions