LAPACK 3.3.0

drqt02.f

Go to the documentation of this file.
00001       SUBROUTINE DRQT02( 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   A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00013      $                   R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
00014      $                   WORK( LWORK )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  DRQT02 tests DORGRQ, 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, DRQT02 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) DOUBLE PRECISION array, dimension (LDA,N)
00045 *          The m-by-n matrix A which was factorized by DRQT01.
00046 *
00047 *  AF      (input) DOUBLE PRECISION array, dimension (LDA,N)
00048 *          Details of the RQ factorization of A, as returned by DGERQF.
00049 *          See DGERQF for further details.
00050 *
00051 *  Q       (workspace) DOUBLE PRECISION array, dimension (LDA,N)
00052 *
00053 *  R       (workspace) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (M)
00059 *          The scalar factors of the elementary reflectors corresponding
00060 *          to the RQ factorization in AF.
00061 *
00062 *  WORK    (workspace) DOUBLE PRECISION 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       DOUBLE PRECISION   ROGUE
00080       PARAMETER          ( ROGUE = -1.0D+10 )
00081 *     ..
00082 *     .. Local Scalars ..
00083       INTEGER            INFO
00084       DOUBLE PRECISION   ANORM, EPS, RESID
00085 *     ..
00086 *     .. External Functions ..
00087       DOUBLE PRECISION   DLAMCH, DLANGE, DLANSY
00088       EXTERNAL           DLAMCH, DLANGE, DLANSY
00089 *     ..
00090 *     .. External Subroutines ..
00091       EXTERNAL           DGEMM, DLACPY, DLASET, DORGRQ, DSYRK
00092 *     ..
00093 *     .. Intrinsic Functions ..
00094       INTRINSIC          DBLE, 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 DLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
00117       IF( K.LT.N )
00118      $   CALL DLACPY( 'Full', K, N-K, AF( M-K+1, 1 ), LDA,
00119      $                Q( M-K+1, 1 ), LDA )
00120       IF( K.GT.1 )
00121      $   CALL DLACPY( '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 = 'DORGRQ'
00127       CALL DORGRQ( 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 DLASET( 'Full', K, M, ZERO, ZERO, R( M-K+1, N-M+1 ), LDA )
00132       CALL DLACPY( 'Upper', K, K, AF( M-K+1, N-K+1 ), LDA,
00133      $             R( M-K+1, N-K+1 ), LDA )
00134 *
00135 *     Compute R(m-k+1:m,n-m+1:n) - A(m-k+1:m,1:n) * Q(n-m+1:n,1:n)'
00136 *
00137       CALL DGEMM( 'No transpose', 'Transpose', K, M, N, -ONE,
00138      $            A( M-K+1, 1 ), LDA, Q, LDA, ONE, R( M-K+1, N-M+1 ),
00139      $            LDA )
00140 *
00141 *     Compute norm( R - A*Q' ) / ( N * norm(A) * EPS ) .
00142 *
00143       ANORM = DLANGE( '1', K, N, A( M-K+1, 1 ), LDA, RWORK )
00144       RESID = DLANGE( '1', K, M, R( M-K+1, N-M+1 ), LDA, RWORK )
00145       IF( ANORM.GT.ZERO ) THEN
00146          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
00147       ELSE
00148          RESULT( 1 ) = ZERO
00149       END IF
00150 *
00151 *     Compute I - Q*Q'
00152 *
00153       CALL DLASET( 'Full', M, M, ZERO, ONE, R, LDA )
00154       CALL DSYRK( 'Upper', 'No transpose', M, N, -ONE, Q, LDA, ONE, R,
00155      $            LDA )
00156 *
00157 *     Compute norm( I - Q*Q' ) / ( N * EPS ) .
00158 *
00159       RESID = DLANSY( '1', 'Upper', M, R, LDA, RWORK )
00160 *
00161       RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
00162 *
00163       RETURN
00164 *
00165 *     End of DRQT02
00166 *
00167       END
 All Files Functions