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