![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SQRT02 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 SQRT02( 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 A( LDA, * ), AF( LDA, * ), Q( LDA, * ), 00019 * $ R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ), 00020 * $ WORK( LWORK ) 00021 * .. 00022 * 00023 * 00024 *> \par Purpose: 00025 * ============= 00026 *> 00027 *> \verbatim 00028 *> 00029 *> SQRT02 tests SORGQR, 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, SQRT02 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 REAL array, dimension (LDA,N) 00065 *> The m-by-n matrix A which was factorized by SQRT01. 00066 *> \endverbatim 00067 *> 00068 *> \param[in] AF 00069 *> \verbatim 00070 *> AF is REAL array, dimension (LDA,N) 00071 *> Details of the QR factorization of A, as returned by SGEQRF. 00072 *> See SGEQRF for further details. 00073 *> \endverbatim 00074 *> 00075 *> \param[out] Q 00076 *> \verbatim 00077 *> Q is REAL array, dimension (LDA,N) 00078 *> \endverbatim 00079 *> 00080 *> \param[out] R 00081 *> \verbatim 00082 *> R is REAL 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 REAL 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 REAL 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 single_lin 00133 * 00134 * ===================================================================== 00135 SUBROUTINE SQRT02( 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 A( LDA, * ), AF( LDA, * ), Q( LDA, * ), 00148 $ R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ), 00149 $ WORK( LWORK ) 00150 * .. 00151 * 00152 * ===================================================================== 00153 * 00154 * .. Parameters .. 00155 REAL ZERO, ONE 00156 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00157 REAL ROGUE 00158 PARAMETER ( ROGUE = -1.0E+10 ) 00159 * .. 00160 * .. Local Scalars .. 00161 INTEGER INFO 00162 REAL ANORM, EPS, RESID 00163 * .. 00164 * .. External Functions .. 00165 REAL SLAMCH, SLANGE, SLANSY 00166 EXTERNAL SLAMCH, SLANGE, SLANSY 00167 * .. 00168 * .. External Subroutines .. 00169 EXTERNAL SGEMM, SLACPY, SLASET, SORGQR, SSYRK 00170 * .. 00171 * .. Intrinsic Functions .. 00172 INTRINSIC 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 SLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA ) 00187 CALL SLACPY( '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 = 'SORGQR' 00192 CALL SORGQR( M, N, K, Q, LDA, TAU, WORK, LWORK, INFO ) 00193 * 00194 * Copy R(1:n,1:k) 00195 * 00196 CALL SLASET( 'Full', N, K, ZERO, ZERO, R, LDA ) 00197 CALL SLACPY( '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 SGEMM( 'Transpose', 'No transpose', N, K, M, -ONE, Q, LDA, A, 00202 $ LDA, ONE, R, LDA ) 00203 * 00204 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) . 00205 * 00206 ANORM = SLANGE( '1', M, K, A, LDA, RWORK ) 00207 RESID = SLANGE( '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 SLASET( 'Full', N, N, ZERO, ONE, R, LDA ) 00217 CALL SSYRK( 'Upper', 'Transpose', N, M, -ONE, Q, LDA, ONE, R, 00218 $ LDA ) 00219 * 00220 * Compute norm( I - Q'*Q ) / ( M * EPS ) . 00221 * 00222 RESID = SLANSY( '1', 'Upper', N, R, LDA, RWORK ) 00223 * 00224 RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS 00225 * 00226 RETURN 00227 * 00228 * End of SQRT02 00229 * 00230 END