3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE SGRQTS( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
12 * BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
14 * .. Scalar Arguments ..
15 * INTEGER LDA, LDB, LWORK, M, P, N
17 * .. Array Arguments ..
18 * REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
20 * $ B( LDB, * ), BF( LDB, * ), T( LDB, * ),
21 * $ Z( LDB, * ), BWK( LDB, * ),
22 * $ TAUA( * ), TAUB( * ),
23 * $ RESULT( 4 ), RWORK( * ), WORK( LWORK )
32 *> SGRQTS tests SGGRQF, which computes the GRQ factorization of an
33 *> M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q.
42 *> The number of rows of the matrix A. M >= 0.
48 *> The number of rows of the matrix B. P >= 0.
54 *> The number of columns of the matrices A and B. N >= 0.
59 *> A is REAL array, dimension (LDA,N)
60 *> The M-by-N matrix A.
65 *> AF is REAL array, dimension (LDA,N)
66 *> Details of the GRQ factorization of A and B, as returned
67 *> by SGGRQF, see SGGRQF for further details.
72 *> Q is REAL array, dimension (LDA,N)
73 *> The N-by-N orthogonal matrix Q.
78 *> R is REAL array, dimension (LDA,MAX(M,N))
84 *> The leading dimension of the arrays A, AF, R and Q.
90 *> TAUA is REAL array, dimension (min(M,N))
91 *> The scalar factors of the elementary reflectors, as returned
97 *> B is REAL array, dimension (LDB,N)
98 *> On entry, the P-by-N matrix A.
103 *> BF is REAL array, dimension (LDB,N)
104 *> Details of the GQR factorization of A and B, as returned
105 *> by SGGRQF, see SGGRQF for further details.
110 *> Z is REAL array, dimension (LDB,P)
111 *> The P-by-P orthogonal matrix Z.
116 *> T is REAL array, dimension (LDB,max(P,N))
121 *> BWK is REAL array, dimension (LDB,N)
127 *> The leading dimension of the arrays B, BF, Z and T.
133 *> TAUB is REAL array, dimension (min(P,N))
134 *> The scalar factors of the elementary reflectors, as returned
140 *> WORK is REAL array, dimension (LWORK)
146 *> The dimension of the array WORK, LWORK >= max(M,P,N)**2.
151 *> RWORK is REAL array, dimension (M)
154 *> \param[out] RESULT
156 *> RESULT is REAL array, dimension (4)
158 *> RESULT(1) = norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP)
159 *> RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP)
160 *> RESULT(3) = norm( I - Q'*Q ) / ( N*ULP )
161 *> RESULT(4) = norm( I - Z'*Z ) / ( P*ULP )
167 *> \author Univ. of Tennessee
168 *> \author Univ. of California Berkeley
169 *> \author Univ. of Colorado Denver
172 *> \date November 2011
174 *> \ingroup single_eig
176 * =====================================================================
177 SUBROUTINE SGRQTS( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
178 $ BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
180 * -- LAPACK test routine (version 3.4.0) --
181 * -- LAPACK is a software package provided by Univ. of Tennessee, --
182 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
185 * .. Scalar Arguments ..
186 INTEGER LDA, LDB, LWORK, M, P, N
188 * .. Array Arguments ..
189 REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
191 $ B( LDB, * ), BF( LDB, * ), T( LDB, * ),
192 $ Z( LDB, * ), BWK( LDB, * ),
193 $ TAUA( * ), TAUB( * ),
194 $ RESULT( 4 ), RWORK( * ), WORK( LWORK )
197 * =====================================================================
201 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
203 PARAMETER ( ROGUE = -1.0E+10 )
205 * .. Local Scalars ..
207 REAL ANORM, BNORM, ULP, UNFL, RESID
209 * .. External Functions ..
210 REAL SLAMCH, SLANGE, SLANSY
211 EXTERNAL SLAMCH, SLANGE, SLANSY
213 * .. External Subroutines ..
214 EXTERNAL SGEMM, SGGRQF, SLACPY, SLASET, SORGQR,
217 * .. Intrinsic Functions ..
218 INTRINSIC MAX, MIN, REAL
220 * .. Executable Statements ..
222 ULP = SLAMCH( 'Precision' )
223 UNFL = SLAMCH( 'Safe minimum' )
225 * Copy the matrix A to the array AF.
227 CALL SLACPY( 'Full', M, N, A, LDA, AF, LDA )
228 CALL SLACPY( 'Full', P, N, B, LDB, BF, LDB )
230 ANORM = MAX( SLANGE( '1', M, N, A, LDA, RWORK ), UNFL )
231 BNORM = MAX( SLANGE( '1', P, N, B, LDB, RWORK ), UNFL )
233 * Factorize the matrices A and B in the arrays AF and BF.
235 CALL SGGRQF( M, P, N, AF, LDA, TAUA, BF, LDB, TAUB, WORK,
238 * Generate the N-by-N matrix Q
240 CALL SLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
242 IF( M.GT.0 .AND. M.LT.N )
243 $ CALL SLACPY( 'Full', M, N-M, AF, LDA, Q( N-M+1, 1 ), LDA )
245 $ CALL SLACPY( 'Lower', M-1, M-1, AF( 2, N-M+1 ), LDA,
246 $ Q( N-M+2, N-M+1 ), LDA )
249 $ CALL SLACPY( 'Lower', N-1, N-1, AF( M-N+2, 1 ), LDA,
252 CALL SORGRQ( N, N, MIN( M, N ), Q, LDA, TAUA, WORK, LWORK, INFO )
254 * Generate the P-by-P matrix Z
256 CALL SLASET( 'Full', P, P, ROGUE, ROGUE, Z, LDB )
258 $ CALL SLACPY( 'Lower', P-1, N, BF( 2,1 ), LDB, Z( 2,1 ), LDB )
259 CALL SORGQR( P, P, MIN( P,N ), Z, LDB, TAUB, WORK, LWORK, INFO )
263 CALL SLASET( 'Full', M, N, ZERO, ZERO, R, LDA )
265 CALL SLACPY( 'Upper', M, M, AF( 1, N-M+1 ), LDA, R( 1, N-M+1 ),
268 CALL SLACPY( 'Full', M-N, N, AF, LDA, R, LDA )
269 CALL SLACPY( 'Upper', N, N, AF( M-N+1, 1 ), LDA, R( M-N+1, 1 ),
275 CALL SLASET( 'Full', P, N, ZERO, ZERO, T, LDB )
276 CALL SLACPY( 'Upper', P, N, BF, LDB, T, LDB )
280 CALL SGEMM( 'No transpose', 'Transpose', M, N, N, -ONE, A, LDA, Q,
283 * Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) .
285 RESID = SLANGE( '1', M, N, R, LDA, RWORK )
286 IF( ANORM.GT.ZERO ) THEN
287 RESULT( 1 ) = ( ( RESID / REAL(MAX(1,M,N) ) ) / ANORM ) / ULP
294 CALL SGEMM( 'Transpose', 'No transpose', P, N, P, ONE, Z, LDB, B,
295 $ LDB, ZERO, BWK, LDB )
296 CALL SGEMM( 'No transpose', 'No transpose', P, N, N, ONE, T, LDB,
297 $ Q, LDA, -ONE, BWK, LDB )
299 * Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
301 RESID = SLANGE( '1', P, N, BWK, LDB, RWORK )
302 IF( BNORM.GT.ZERO ) THEN
303 RESULT( 2 ) = ( ( RESID / REAL( MAX( 1,P,M ) ) )/BNORM ) / ULP
310 CALL SLASET( 'Full', N, N, ZERO, ONE, R, LDA )
311 CALL SSYRK( 'Upper', 'No Transpose', N, N, -ONE, Q, LDA, ONE, R,
314 * Compute norm( I - Q'*Q ) / ( N * ULP ) .
316 RESID = SLANSY( '1', 'Upper', N, R, LDA, RWORK )
317 RESULT( 3 ) = ( RESID / REAL( MAX( 1,N ) ) ) / ULP
321 CALL SLASET( 'Full', P, P, ZERO, ONE, T, LDB )
322 CALL SSYRK( 'Upper', 'Transpose', P, P, -ONE, Z, LDB, ONE, T,
325 * Compute norm( I - Z'*Z ) / ( P*ULP ) .
327 RESID = SLANSY( '1', 'Upper', P, T, LDB, RWORK )
328 RESULT( 4 ) = ( RESID / REAL( MAX( 1,P ) ) ) / ULP