LAPACK 3.3.0

zrqt02.f

Go to the documentation of this file.
00001       SUBROUTINE ZRQT02( M, N, K, A, AF, Q, R, LDA, TAU, WORK, LWORK,
00002      $                   RWORK, RESULT )
00003 *
00004 *  -- LAPACK test routine (version 3.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            K, LDA, LWORK, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   RESULT( * ), RWORK( * )
00013       COMPLEX*16         A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00014      $                   R( LDA, * ), TAU( * ), WORK( LWORK )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  ZRQT02 tests ZUNGRQ, which generates an m-by-n matrix Q with
00021 *  orthonornmal rows that is defined as the product of k elementary
00022 *  reflectors.
00023 *
00024 *  Given the RQ factorization of an m-by-n matrix A, ZRQT02 generates
00025 *  the orthogonal matrix Q defined by the factorization of the last k
00026 *  rows of A; it compares R(m-k+1:m,n-m+1:n) with
00027 *  A(m-k+1:m,1:n)*Q(n-m+1:n,1:n)', and checks that the rows of Q are
00028 *  orthonormal.
00029 *
00030 *  Arguments
00031 *  =========
00032 *
00033 *  M       (input) INTEGER
00034 *          The number of rows of the matrix Q to be generated.  M >= 0.
00035 *
00036 *  N       (input) INTEGER
00037 *          The number of columns of the matrix Q to be generated.
00038 *          N >= M >= 0.
00039 *
00040 *  K       (input) INTEGER
00041 *          The number of elementary reflectors whose product defines the
00042 *          matrix Q. M >= K >= 0.
00043 *
00044 *  A       (input) COMPLEX*16 array, dimension (LDA,N)
00045 *          The m-by-n matrix A which was factorized by ZRQT01.
00046 *
00047 *  AF      (input) COMPLEX*16 array, dimension (LDA,N)
00048 *          Details of the RQ factorization of A, as returned by ZGERQF.
00049 *          See ZGERQF for further details.
00050 *
00051 *  Q       (workspace) COMPLEX*16 array, dimension (LDA,N)
00052 *
00053 *  R       (workspace) COMPLEX*16 array, dimension (LDA,M)
00054 *
00055 *  LDA     (input) INTEGER
00056 *          The leading dimension of the arrays A, AF, Q and L. LDA >= N.
00057 *
00058 *  TAU     (input) COMPLEX*16 array, dimension (M)
00059 *          The scalar factors of the elementary reflectors corresponding
00060 *          to the RQ factorization in AF.
00061 *
00062 *  WORK    (workspace) COMPLEX*16 array, dimension (LWORK)
00063 *
00064 *  LWORK   (input) INTEGER
00065 *          The dimension of the array WORK.
00066 *
00067 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (M)
00068 *
00069 *  RESULT  (output) DOUBLE PRECISION array, dimension (2)
00070 *          The test ratios:
00071 *          RESULT(1) = norm( R - A*Q' ) / ( N * norm(A) * EPS )
00072 *          RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
00073 *
00074 *  =====================================================================
00075 *
00076 *     .. Parameters ..
00077       DOUBLE PRECISION   ZERO, ONE
00078       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00079       COMPLEX*16         ROGUE
00080       PARAMETER          ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
00081 *     ..
00082 *     .. Local Scalars ..
00083       INTEGER            INFO
00084       DOUBLE PRECISION   ANORM, EPS, RESID
00085 *     ..
00086 *     .. External Functions ..
00087       DOUBLE PRECISION   DLAMCH, ZLANGE, ZLANSY
00088       EXTERNAL           DLAMCH, ZLANGE, ZLANSY
00089 *     ..
00090 *     .. External Subroutines ..
00091       EXTERNAL           ZGEMM, ZHERK, ZLACPY, ZLASET, ZUNGRQ
00092 *     ..
00093 *     .. Intrinsic Functions ..
00094       INTRINSIC          DBLE, DCMPLX, MAX
00095 *     ..
00096 *     .. Scalars in Common ..
00097       CHARACTER*32       SRNAMT
00098 *     ..
00099 *     .. Common blocks ..
00100       COMMON             / SRNAMC / SRNAMT
00101 *     ..
00102 *     .. Executable Statements ..
00103 *
00104 *     Quick return if possible
00105 *
00106       IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
00107          RESULT( 1 ) = ZERO
00108          RESULT( 2 ) = ZERO
00109          RETURN
00110       END IF
00111 *
00112       EPS = DLAMCH( 'Epsilon' )
00113 *
00114 *     Copy the last k rows of the factorization to the array Q
00115 *
00116       CALL ZLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
00117       IF( K.LT.N )
00118      $   CALL ZLACPY( 'Full', K, N-K, AF( M-K+1, 1 ), LDA,
00119      $                Q( M-K+1, 1 ), LDA )
00120       IF( K.GT.1 )
00121      $   CALL ZLACPY( 'Lower', K-1, K-1, AF( M-K+2, N-K+1 ), LDA,
00122      $                Q( M-K+2, N-K+1 ), LDA )
00123 *
00124 *     Generate the last n rows of the matrix Q
00125 *
00126       SRNAMT = 'ZUNGRQ'
00127       CALL ZUNGRQ( M, N, K, Q, LDA, TAU( M-K+1 ), WORK, LWORK, INFO )
00128 *
00129 *     Copy R(m-k+1:m,n-m+1:n)
00130 *
00131       CALL ZLASET( 'Full', K, M, DCMPLX( ZERO ), DCMPLX( ZERO ),
00132      $             R( M-K+1, N-M+1 ), LDA )
00133       CALL ZLACPY( 'Upper', K, K, AF( M-K+1, N-K+1 ), LDA,
00134      $             R( M-K+1, N-K+1 ), LDA )
00135 *
00136 *     Compute R(m-k+1:m,n-m+1:n) - A(m-k+1:m,1:n) * Q(n-m+1:n,1:n)'
00137 *
00138       CALL ZGEMM( 'No transpose', 'Conjugate transpose', K, M, N,
00139      $            DCMPLX( -ONE ), A( M-K+1, 1 ), LDA, Q, LDA,
00140      $            DCMPLX( ONE ), R( M-K+1, N-M+1 ), LDA )
00141 *
00142 *     Compute norm( R - A*Q' ) / ( N * norm(A) * EPS ) .
00143 *
00144       ANORM = ZLANGE( '1', K, N, A( M-K+1, 1 ), LDA, RWORK )
00145       RESID = ZLANGE( '1', K, M, R( M-K+1, N-M+1 ), LDA, RWORK )
00146       IF( ANORM.GT.ZERO ) THEN
00147          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
00148       ELSE
00149          RESULT( 1 ) = ZERO
00150       END IF
00151 *
00152 *     Compute I - Q*Q'
00153 *
00154       CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), R, LDA )
00155       CALL ZHERK( 'Upper', 'No transpose', M, N, -ONE, Q, LDA, ONE, R,
00156      $            LDA )
00157 *
00158 *     Compute norm( I - Q*Q' ) / ( N * EPS ) .
00159 *
00160       RESID = ZLANSY( '1', 'Upper', M, R, LDA, RWORK )
00161 *
00162       RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
00163 *
00164       RETURN
00165 *
00166 *     End of ZRQT02
00167 *
00168       END
 All Files Functions