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