![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b ZQRT02 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 ZQRT02( 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 *> ZQRT02 tests ZUNGQR, 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, ZQRT02 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*16 array, dimension (LDA,N) 00065 *> The m-by-n matrix A which was factorized by ZQRT01. 00066 *> \endverbatim 00067 *> 00068 *> \param[in] AF 00069 *> \verbatim 00070 *> AF is COMPLEX*16 array, dimension (LDA,N) 00071 *> Details of the QR factorization of A, as returned by ZGEQRF. 00072 *> See ZGEQRF for further details. 00073 *> \endverbatim 00074 *> 00075 *> \param[out] Q 00076 *> \verbatim 00077 *> Q is COMPLEX*16 array, dimension (LDA,N) 00078 *> \endverbatim 00079 *> 00080 *> \param[out] R 00081 *> \verbatim 00082 *> R is COMPLEX*16 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*16 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*16 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 DOUBLE PRECISION array, dimension (M) 00112 *> \endverbatim 00113 *> 00114 *> \param[out] RESULT 00115 *> \verbatim 00116 *> RESULT is DOUBLE PRECISION 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 complex16_lin 00133 * 00134 * ===================================================================== 00135 SUBROUTINE ZQRT02( 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 DOUBLE PRECISION RESULT( * ), RWORK( * ) 00148 COMPLEX*16 A( LDA, * ), AF( LDA, * ), Q( LDA, * ), 00149 $ R( LDA, * ), TAU( * ), WORK( LWORK ) 00150 * .. 00151 * 00152 * ===================================================================== 00153 * 00154 * .. Parameters .. 00155 DOUBLE PRECISION ZERO, ONE 00156 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00157 COMPLEX*16 ROGUE 00158 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) ) 00159 * .. 00160 * .. Local Scalars .. 00161 INTEGER INFO 00162 DOUBLE PRECISION ANORM, EPS, RESID 00163 * .. 00164 * .. External Functions .. 00165 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY 00166 EXTERNAL DLAMCH, ZLANGE, ZLANSY 00167 * .. 00168 * .. External Subroutines .. 00169 EXTERNAL ZGEMM, ZHERK, ZLACPY, ZLASET, ZUNGQR 00170 * .. 00171 * .. Intrinsic Functions .. 00172 INTRINSIC DBLE, DCMPLX, MAX 00173 * .. 00174 * .. Scalars in Common .. 00175 CHARACTER*32 SRNAMT 00176 * .. 00177 * .. Common blocks .. 00178 COMMON / SRNAMC / SRNAMT 00179 * .. 00180 * .. Executable Statements .. 00181 * 00182 EPS = DLAMCH( 'Epsilon' ) 00183 * 00184 * Copy the first k columns of the factorization to the array Q 00185 * 00186 CALL ZLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA ) 00187 CALL ZLACPY( '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 = 'ZUNGQR' 00192 CALL ZUNGQR( M, N, K, Q, LDA, TAU, WORK, LWORK, INFO ) 00193 * 00194 * Copy R(1:n,1:k) 00195 * 00196 CALL ZLASET( 'Full', N, K, DCMPLX( ZERO ), DCMPLX( ZERO ), R, 00197 $ LDA ) 00198 CALL ZLACPY( 'Upper', N, K, AF, LDA, R, LDA ) 00199 * 00200 * Compute R(1:n,1:k) - Q(1:m,1:n)' * A(1:m,1:k) 00201 * 00202 CALL ZGEMM( 'Conjugate transpose', 'No transpose', N, K, M, 00203 $ DCMPLX( -ONE ), Q, LDA, A, LDA, DCMPLX( ONE ), R, 00204 $ LDA ) 00205 * 00206 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) . 00207 * 00208 ANORM = ZLANGE( '1', M, K, A, LDA, RWORK ) 00209 RESID = ZLANGE( '1', N, K, R, LDA, RWORK ) 00210 IF( ANORM.GT.ZERO ) THEN 00211 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M ) ) ) / ANORM ) / EPS 00212 ELSE 00213 RESULT( 1 ) = ZERO 00214 END IF 00215 * 00216 * Compute I - Q'*Q 00217 * 00218 CALL ZLASET( 'Full', N, N, DCMPLX( ZERO ), DCMPLX( ONE ), R, LDA ) 00219 CALL ZHERK( 'Upper', 'Conjugate transpose', N, M, -ONE, Q, LDA, 00220 $ ONE, R, LDA ) 00221 * 00222 * Compute norm( I - Q'*Q ) / ( M * EPS ) . 00223 * 00224 RESID = ZLANSY( '1', 'Upper', N, R, LDA, RWORK ) 00225 * 00226 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, M ) ) ) / EPS 00227 * 00228 RETURN 00229 * 00230 * End of ZQRT02 00231 * 00232 END