1*> \brief \b CGQRTS 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8* Definition: 9* =========== 10* 11* SUBROUTINE CGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T, 12* BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT ) 13* 14* .. Scalar Arguments .. 15* INTEGER LDA, LDB, LWORK, M, P, N 16* .. 17* .. Array Arguments .. 18* REAL RWORK( * ), RESULT( 4 ) 19* COMPLEX A( LDA, * ), AF( LDA, * ), R( LDA, * ), 20* $ Q( LDA, * ), B( LDB, * ), BF( LDB, * ), 21* $ T( LDB, * ), Z( LDB, * ), BWK( LDB, * ), 22* $ TAUA( * ), TAUB( * ), WORK( LWORK ) 23* .. 24* 25* 26*> \par Purpose: 27* ============= 28*> 29*> \verbatim 30*> 31*> CGQRTS tests CGGQRF, which computes the GQR factorization of an 32*> N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z. 33*> \endverbatim 34* 35* Arguments: 36* ========== 37* 38*> \param[in] N 39*> \verbatim 40*> N is INTEGER 41*> The number of rows of the matrices A and B. N >= 0. 42*> \endverbatim 43*> 44*> \param[in] M 45*> \verbatim 46*> M is INTEGER 47*> The number of columns of the matrix A. M >= 0. 48*> \endverbatim 49*> 50*> \param[in] P 51*> \verbatim 52*> P is INTEGER 53*> The number of columns of the matrix B. P >= 0. 54*> \endverbatim 55*> 56*> \param[in] A 57*> \verbatim 58*> A is COMPLEX array, dimension (LDA,M) 59*> The N-by-M matrix A. 60*> \endverbatim 61*> 62*> \param[out] AF 63*> \verbatim 64*> AF is COMPLEX array, dimension (LDA,N) 65*> Details of the GQR factorization of A and B, as returned 66*> by CGGQRF, see CGGQRF for further details. 67*> \endverbatim 68*> 69*> \param[out] Q 70*> \verbatim 71*> Q is COMPLEX array, dimension (LDA,N) 72*> The M-by-M unitary matrix Q. 73*> \endverbatim 74*> 75*> \param[out] R 76*> \verbatim 77*> R is COMPLEX array, dimension (LDA,MAX(M,N)) 78*> \endverbatim 79*> 80*> \param[in] LDA 81*> \verbatim 82*> LDA is INTEGER 83*> The leading dimension of the arrays A, AF, R and Q. 84*> LDA >= max(M,N). 85*> \endverbatim 86*> 87*> \param[out] TAUA 88*> \verbatim 89*> TAUA is COMPLEX array, dimension (min(M,N)) 90*> The scalar factors of the elementary reflectors, as returned 91*> by CGGQRF. 92*> \endverbatim 93*> 94*> \param[in] B 95*> \verbatim 96*> B is COMPLEX array, dimension (LDB,P) 97*> On entry, the N-by-P matrix A. 98*> \endverbatim 99*> 100*> \param[out] BF 101*> \verbatim 102*> BF is COMPLEX array, dimension (LDB,N) 103*> Details of the GQR factorization of A and B, as returned 104*> by CGGQRF, see CGGQRF for further details. 105*> \endverbatim 106*> 107*> \param[out] Z 108*> \verbatim 109*> Z is COMPLEX array, dimension (LDB,P) 110*> The P-by-P unitary matrix Z. 111*> \endverbatim 112*> 113*> \param[out] T 114*> \verbatim 115*> T is COMPLEX array, dimension (LDB,max(P,N)) 116*> \endverbatim 117*> 118*> \param[out] BWK 119*> \verbatim 120*> BWK is COMPLEX array, dimension (LDB,N) 121*> \endverbatim 122*> 123*> \param[in] LDB 124*> \verbatim 125*> LDB is INTEGER 126*> The leading dimension of the arrays B, BF, Z and T. 127*> LDB >= max(P,N). 128*> \endverbatim 129*> 130*> \param[out] TAUB 131*> \verbatim 132*> TAUB is COMPLEX array, dimension (min(P,N)) 133*> The scalar factors of the elementary reflectors, as returned 134*> by SGGRQF. 135*> \endverbatim 136*> 137*> \param[out] WORK 138*> \verbatim 139*> WORK is COMPLEX array, dimension (LWORK) 140*> \endverbatim 141*> 142*> \param[in] LWORK 143*> \verbatim 144*> LWORK is INTEGER 145*> The dimension of the array WORK, LWORK >= max(N,M,P)**2. 146*> \endverbatim 147*> 148*> \param[out] RWORK 149*> \verbatim 150*> RWORK is REAL array, dimension (max(N,M,P)) 151*> \endverbatim 152*> 153*> \param[out] RESULT 154*> \verbatim 155*> RESULT is REAL array, dimension (4) 156*> The test ratios: 157*> RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP) 158*> RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP) 159*> RESULT(3) = norm( I - Q'*Q ) / ( M*ULP ) 160*> RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) 161*> \endverbatim 162* 163* Authors: 164* ======== 165* 166*> \author Univ. of Tennessee 167*> \author Univ. of California Berkeley 168*> \author Univ. of Colorado Denver 169*> \author NAG Ltd. 170* 171*> \ingroup complex_eig 172* 173* ===================================================================== 174 SUBROUTINE CGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T, 175 $ BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT ) 176* 177* -- LAPACK test routine -- 178* -- LAPACK is a software package provided by Univ. of Tennessee, -- 179* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 180* 181* .. Scalar Arguments .. 182 INTEGER LDA, LDB, LWORK, M, P, N 183* .. 184* .. Array Arguments .. 185 REAL RWORK( * ), RESULT( 4 ) 186 COMPLEX A( LDA, * ), AF( LDA, * ), R( LDA, * ), 187 $ Q( LDA, * ), B( LDB, * ), BF( LDB, * ), 188 $ T( LDB, * ), Z( LDB, * ), BWK( LDB, * ), 189 $ TAUA( * ), TAUB( * ), WORK( LWORK ) 190* .. 191* 192* ===================================================================== 193* 194* .. Parameters .. 195 REAL ZERO, ONE 196 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 197 COMPLEX CZERO, CONE 198 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ), 199 $ CONE = ( 1.0E+0, 0.0E+0 ) ) 200 COMPLEX CROGUE 201 PARAMETER ( CROGUE = ( -1.0E+10, 0.0E+0 ) ) 202* .. 203* .. Local Scalars .. 204 INTEGER INFO 205 REAL ANORM, BNORM, ULP, UNFL, RESID 206* .. 207* .. External Functions .. 208 REAL SLAMCH, CLANGE, CLANHE 209 EXTERNAL SLAMCH, CLANGE, CLANHE 210* .. 211* .. External Subroutines .. 212 EXTERNAL CGEMM, CLACPY, CLASET, CUNGQR, 213 $ CUNGRQ, CHERK 214* .. 215* .. Intrinsic Functions .. 216 INTRINSIC MAX, MIN, REAL 217* .. 218* .. Executable Statements .. 219* 220 ULP = SLAMCH( 'Precision' ) 221 UNFL = SLAMCH( 'Safe minimum' ) 222* 223* Copy the matrix A to the array AF. 224* 225 CALL CLACPY( 'Full', N, M, A, LDA, AF, LDA ) 226 CALL CLACPY( 'Full', N, P, B, LDB, BF, LDB ) 227* 228 ANORM = MAX( CLANGE( '1', N, M, A, LDA, RWORK ), UNFL ) 229 BNORM = MAX( CLANGE( '1', N, P, B, LDB, RWORK ), UNFL ) 230* 231* Factorize the matrices A and B in the arrays AF and BF. 232* 233 CALL CGGQRF( N, M, P, AF, LDA, TAUA, BF, LDB, TAUB, WORK, 234 $ LWORK, INFO ) 235* 236* Generate the N-by-N matrix Q 237* 238 CALL CLASET( 'Full', N, N, CROGUE, CROGUE, Q, LDA ) 239 CALL CLACPY( 'Lower', N-1, M, AF( 2,1 ), LDA, Q( 2,1 ), LDA ) 240 CALL CUNGQR( N, N, MIN( N, M ), Q, LDA, TAUA, WORK, LWORK, INFO ) 241* 242* Generate the P-by-P matrix Z 243* 244 CALL CLASET( 'Full', P, P, CROGUE, CROGUE, Z, LDB ) 245 IF( N.LE.P ) THEN 246 IF( N.GT.0 .AND. N.LT.P ) 247 $ CALL CLACPY( 'Full', N, P-N, BF, LDB, Z( P-N+1, 1 ), LDB ) 248 IF( N.GT.1 ) 249 $ CALL CLACPY( 'Lower', N-1, N-1, BF( 2, P-N+1 ), LDB, 250 $ Z( P-N+2, P-N+1 ), LDB ) 251 ELSE 252 IF( P.GT.1) 253 $ CALL CLACPY( 'Lower', P-1, P-1, BF( N-P+2, 1 ), LDB, 254 $ Z( 2, 1 ), LDB ) 255 END IF 256 CALL CUNGRQ( P, P, MIN( N, P ), Z, LDB, TAUB, WORK, LWORK, INFO ) 257* 258* Copy R 259* 260 CALL CLASET( 'Full', N, M, CZERO, CZERO, R, LDA ) 261 CALL CLACPY( 'Upper', N, M, AF, LDA, R, LDA ) 262* 263* Copy T 264* 265 CALL CLASET( 'Full', N, P, CZERO, CZERO, T, LDB ) 266 IF( N.LE.P ) THEN 267 CALL CLACPY( 'Upper', N, N, BF( 1, P-N+1 ), LDB, T( 1, P-N+1 ), 268 $ LDB ) 269 ELSE 270 CALL CLACPY( 'Full', N-P, P, BF, LDB, T, LDB ) 271 CALL CLACPY( 'Upper', P, P, BF( N-P+1, 1 ), LDB, T( N-P+1, 1 ), 272 $ LDB ) 273 END IF 274* 275* Compute R - Q'*A 276* 277 CALL CGEMM( 'Conjugate transpose', 'No transpose', N, M, N, -CONE, 278 $ Q, LDA, A, LDA, CONE, R, LDA ) 279* 280* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) . 281* 282 RESID = CLANGE( '1', N, M, R, LDA, RWORK ) 283 IF( ANORM.GT.ZERO ) THEN 284 RESULT( 1 ) = ( ( RESID / REAL( MAX(1,M,N) ) ) / ANORM ) / ULP 285 ELSE 286 RESULT( 1 ) = ZERO 287 END IF 288* 289* Compute T*Z - Q'*B 290* 291 CALL CGEMM( 'No Transpose', 'No transpose', N, P, P, CONE, T, LDB, 292 $ Z, LDB, CZERO, BWK, LDB ) 293 CALL CGEMM( 'Conjugate transpose', 'No transpose', N, P, N, -CONE, 294 $ Q, LDA, B, LDB, CONE, BWK, LDB ) 295* 296* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) . 297* 298 RESID = CLANGE( '1', N, P, BWK, LDB, RWORK ) 299 IF( BNORM.GT.ZERO ) THEN 300 RESULT( 2 ) = ( ( RESID / REAL( MAX(1,P,N ) ) )/BNORM ) / ULP 301 ELSE 302 RESULT( 2 ) = ZERO 303 END IF 304* 305* Compute I - Q'*Q 306* 307 CALL CLASET( 'Full', N, N, CZERO, CONE, R, LDA ) 308 CALL CHERK( 'Upper', 'Conjugate transpose', N, N, -ONE, Q, LDA, 309 $ ONE, R, LDA ) 310* 311* Compute norm( I - Q'*Q ) / ( N * ULP ) . 312* 313 RESID = CLANHE( '1', 'Upper', N, R, LDA, RWORK ) 314 RESULT( 3 ) = ( RESID / REAL( MAX( 1, N ) ) ) / ULP 315* 316* Compute I - Z'*Z 317* 318 CALL CLASET( 'Full', P, P, CZERO, CONE, T, LDB ) 319 CALL CHERK( 'Upper', 'Conjugate transpose', P, P, -ONE, Z, LDB, 320 $ ONE, T, LDB ) 321* 322* Compute norm( I - Z'*Z ) / ( P*ULP ) . 323* 324 RESID = CLANHE( '1', 'Upper', P, T, LDB, RWORK ) 325 RESULT( 4 ) = ( RESID / REAL( MAX( 1, P ) ) ) / ULP 326* 327 RETURN 328* 329* End of CGQRTS 330* 331 END 332