LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE SGRQTS( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T, 00002 $ BWK, LDB, TAUB, WORK, LWORK, 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 LDA, LDB, LWORK, M, P, N 00010 * .. 00011 * .. Array Arguments .. 00012 REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ), 00013 $ Q( LDA, * ), 00014 $ B( LDB, * ), BF( LDB, * ), T( LDB, * ), 00015 $ Z( LDB, * ), BWK( LDB, * ), 00016 $ TAUA( * ), TAUB( * ), 00017 $ RESULT( 4 ), RWORK( * ), WORK( LWORK ) 00018 * .. 00019 * 00020 * Purpose 00021 * ======= 00022 * 00023 * SGRQTS tests SGGRQF, which computes the GRQ factorization of an 00024 * M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q. 00025 * 00026 * Arguments 00027 * ========= 00028 * 00029 * M (input) INTEGER 00030 * The number of rows of the matrix A. M >= 0. 00031 * 00032 * P (input) INTEGER 00033 * The number of rows of the matrix B. P >= 0. 00034 * 00035 * N (input) INTEGER 00036 * The number of columns of the matrices A and B. N >= 0. 00037 * 00038 * A (input) REAL array, dimension (LDA,N) 00039 * The M-by-N matrix A. 00040 * 00041 * AF (output) REAL array, dimension (LDA,N) 00042 * Details of the GRQ factorization of A and B, as returned 00043 * by SGGRQF, see SGGRQF for further details. 00044 * 00045 * Q (output) REAL array, dimension (LDA,N) 00046 * The N-by-N orthogonal matrix Q. 00047 * 00048 * R (workspace) REAL array, dimension (LDA,MAX(M,N)) 00049 * 00050 * LDA (input) INTEGER 00051 * The leading dimension of the arrays A, AF, R and Q. 00052 * LDA >= max(M,N). 00053 * 00054 * TAUA (output) REAL array, dimension (min(M,N)) 00055 * The scalar factors of the elementary reflectors, as returned 00056 * by SGGQRC. 00057 * 00058 * B (input) REAL array, dimension (LDB,N) 00059 * On entry, the P-by-N matrix A. 00060 * 00061 * BF (output) REAL array, dimension (LDB,N) 00062 * Details of the GQR factorization of A and B, as returned 00063 * by SGGRQF, see SGGRQF for further details. 00064 * 00065 * Z (output) REAL array, dimension (LDB,P) 00066 * The P-by-P orthogonal matrix Z. 00067 * 00068 * T (workspace) REAL array, dimension (LDB,max(P,N)) 00069 * 00070 * BWK (workspace) REAL array, dimension (LDB,N) 00071 * 00072 * LDB (input) INTEGER 00073 * The leading dimension of the arrays B, BF, Z and T. 00074 * LDB >= max(P,N). 00075 * 00076 * TAUB (output) REAL array, dimension (min(P,N)) 00077 * The scalar factors of the elementary reflectors, as returned 00078 * by SGGRQF. 00079 * 00080 * WORK (workspace) REAL array, dimension (LWORK) 00081 * 00082 * LWORK (input) INTEGER 00083 * The dimension of the array WORK, LWORK >= max(M,P,N)**2. 00084 * 00085 * RWORK (workspace) REAL array, dimension (M) 00086 * 00087 * RESULT (output) REAL array, dimension (4) 00088 * The test ratios: 00089 * RESULT(1) = norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP) 00090 * RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP) 00091 * RESULT(3) = norm( I - Q'*Q ) / ( N*ULP ) 00092 * RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) 00093 * 00094 * ===================================================================== 00095 * 00096 * .. Parameters .. 00097 REAL ZERO, ONE 00098 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00099 REAL ROGUE 00100 PARAMETER ( ROGUE = -1.0E+10 ) 00101 * .. 00102 * .. Local Scalars .. 00103 INTEGER INFO 00104 REAL ANORM, BNORM, ULP, UNFL, RESID 00105 * .. 00106 * .. External Functions .. 00107 REAL SLAMCH, SLANGE, SLANSY 00108 EXTERNAL SLAMCH, SLANGE, SLANSY 00109 * .. 00110 * .. External Subroutines .. 00111 EXTERNAL SGEMM, SGGRQF, SLACPY, SLASET, SORGQR, 00112 $ SORGRQ, SSYRK 00113 * .. 00114 * .. Intrinsic Functions .. 00115 INTRINSIC MAX, MIN, REAL 00116 * .. 00117 * .. Executable Statements .. 00118 * 00119 ULP = SLAMCH( 'Precision' ) 00120 UNFL = SLAMCH( 'Safe minimum' ) 00121 * 00122 * Copy the matrix A to the array AF. 00123 * 00124 CALL SLACPY( 'Full', M, N, A, LDA, AF, LDA ) 00125 CALL SLACPY( 'Full', P, N, B, LDB, BF, LDB ) 00126 * 00127 ANORM = MAX( SLANGE( '1', M, N, A, LDA, RWORK ), UNFL ) 00128 BNORM = MAX( SLANGE( '1', P, N, B, LDB, RWORK ), UNFL ) 00129 * 00130 * Factorize the matrices A and B in the arrays AF and BF. 00131 * 00132 CALL SGGRQF( M, P, N, AF, LDA, TAUA, BF, LDB, TAUB, WORK, 00133 $ LWORK, INFO ) 00134 * 00135 * Generate the N-by-N matrix Q 00136 * 00137 CALL SLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA ) 00138 IF( M.LE.N ) THEN 00139 IF( M.GT.0 .AND. M.LT.N ) 00140 $ CALL SLACPY( 'Full', M, N-M, AF, LDA, Q( N-M+1, 1 ), LDA ) 00141 IF( M.GT.1 ) 00142 $ CALL SLACPY( 'Lower', M-1, M-1, AF( 2, N-M+1 ), LDA, 00143 $ Q( N-M+2, N-M+1 ), LDA ) 00144 ELSE 00145 IF( N.GT.1 ) 00146 $ CALL SLACPY( 'Lower', N-1, N-1, AF( M-N+2, 1 ), LDA, 00147 $ Q( 2, 1 ), LDA ) 00148 END IF 00149 CALL SORGRQ( N, N, MIN( M, N ), Q, LDA, TAUA, WORK, LWORK, INFO ) 00150 * 00151 * Generate the P-by-P matrix Z 00152 * 00153 CALL SLASET( 'Full', P, P, ROGUE, ROGUE, Z, LDB ) 00154 IF( P.GT.1 ) 00155 $ CALL SLACPY( 'Lower', P-1, N, BF( 2,1 ), LDB, Z( 2,1 ), LDB ) 00156 CALL SORGQR( P, P, MIN( P,N ), Z, LDB, TAUB, WORK, LWORK, INFO ) 00157 * 00158 * Copy R 00159 * 00160 CALL SLASET( 'Full', M, N, ZERO, ZERO, R, LDA ) 00161 IF( M.LE.N )THEN 00162 CALL SLACPY( 'Upper', M, M, AF( 1, N-M+1 ), LDA, R( 1, N-M+1 ), 00163 $ LDA ) 00164 ELSE 00165 CALL SLACPY( 'Full', M-N, N, AF, LDA, R, LDA ) 00166 CALL SLACPY( 'Upper', N, N, AF( M-N+1, 1 ), LDA, R( M-N+1, 1 ), 00167 $ LDA ) 00168 END IF 00169 * 00170 * Copy T 00171 * 00172 CALL SLASET( 'Full', P, N, ZERO, ZERO, T, LDB ) 00173 CALL SLACPY( 'Upper', P, N, BF, LDB, T, LDB ) 00174 * 00175 * Compute R - A*Q' 00176 * 00177 CALL SGEMM( 'No transpose', 'Transpose', M, N, N, -ONE, A, LDA, Q, 00178 $ LDA, ONE, R, LDA ) 00179 * 00180 * Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) . 00181 * 00182 RESID = SLANGE( '1', M, N, R, LDA, RWORK ) 00183 IF( ANORM.GT.ZERO ) THEN 00184 RESULT( 1 ) = ( ( RESID / REAL(MAX(1,M,N) ) ) / ANORM ) / ULP 00185 ELSE 00186 RESULT( 1 ) = ZERO 00187 END IF 00188 * 00189 * Compute T*Q - Z'*B 00190 * 00191 CALL SGEMM( 'Transpose', 'No transpose', P, N, P, ONE, Z, LDB, B, 00192 $ LDB, ZERO, BWK, LDB ) 00193 CALL SGEMM( 'No transpose', 'No transpose', P, N, N, ONE, T, LDB, 00194 $ Q, LDA, -ONE, BWK, LDB ) 00195 * 00196 * Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) . 00197 * 00198 RESID = SLANGE( '1', P, N, BWK, LDB, RWORK ) 00199 IF( BNORM.GT.ZERO ) THEN 00200 RESULT( 2 ) = ( ( RESID / REAL( MAX( 1,P,M ) ) )/BNORM ) / ULP 00201 ELSE 00202 RESULT( 2 ) = ZERO 00203 END IF 00204 * 00205 * Compute I - Q*Q' 00206 * 00207 CALL SLASET( 'Full', N, N, ZERO, ONE, R, LDA ) 00208 CALL SSYRK( 'Upper', 'No Transpose', N, N, -ONE, Q, LDA, ONE, R, 00209 $ LDA ) 00210 * 00211 * Compute norm( I - Q'*Q ) / ( N * ULP ) . 00212 * 00213 RESID = SLANSY( '1', 'Upper', N, R, LDA, RWORK ) 00214 RESULT( 3 ) = ( RESID / REAL( MAX( 1,N ) ) ) / ULP 00215 * 00216 * Compute I - Z'*Z 00217 * 00218 CALL SLASET( 'Full', P, P, ZERO, ONE, T, LDB ) 00219 CALL SSYRK( 'Upper', 'Transpose', P, P, -ONE, Z, LDB, ONE, T, 00220 $ LDB ) 00221 * 00222 * Compute norm( I - Z'*Z ) / ( P*ULP ) . 00223 * 00224 RESID = SLANSY( '1', 'Upper', P, T, LDB, RWORK ) 00225 RESULT( 4 ) = ( RESID / REAL( MAX( 1,P ) ) ) / ULP 00226 * 00227 RETURN 00228 * 00229 * End of SGRQTS 00230 * 00231 END