LAPACK 3.3.0

zgqrts.f

Go to the documentation of this file.
00001       SUBROUTINE ZGQRTS( N, M, P, 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 *  ZGQRTS tests ZGGQRF, which computes the GQR factorization of an
00023 *  N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z.
00024 *
00025 *  Arguments
00026 *  =========
00027 *
00028 *  N       (input) INTEGER
00029 *          The number of rows of the matrices A and B.  N >= 0.
00030 *
00031 *  M       (input) INTEGER
00032 *          The number of columns of the matrix A.  M >= 0.
00033 *
00034 *  P       (input) INTEGER
00035 *          The number of columns of the matrix B.  P >= 0.
00036 *
00037 *  A       (input) COMPLEX*16 array, dimension (LDA,M)
00038 *          The N-by-M matrix A.
00039 *
00040 *  AF      (output) COMPLEX*16 array, dimension (LDA,N)
00041 *          Details of the GQR factorization of A and B, as returned
00042 *          by ZGGQRF, see CGGQRF for further details.
00043 *
00044 *  Q       (output) COMPLEX*16 array, dimension (LDA,N)
00045 *          The M-by-M 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 ZGGQRF.
00056 *
00057 *  B       (input) COMPLEX*16 array, dimension (LDB,P)
00058 *          On entry, the N-by-P 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 ZGGQRF, see CGGQRF for further details.
00063 *
00064 *  Z       (output) COMPLEX*16 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(N,M,P)**2.
00083 *
00084 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(N,M,P))
00085 *
00086 *  RESULT  (output) DOUBLE PRECISION array, dimension (4)
00087 *          The test ratios:
00088 *            RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP)
00089 *            RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP)
00090 *            RESULT(3) = norm( I - Q'*Q ) / ( M*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, ZGGQRF, 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', N, M, A, LDA, AF, LDA )
00127       CALL ZLACPY( 'Full', N, P, B, LDB, BF, LDB )
00128 *
00129       ANORM = MAX( ZLANGE( '1', N, M, A, LDA, RWORK ), UNFL )
00130       BNORM = MAX( ZLANGE( '1', N, P, B, LDB, RWORK ), UNFL )
00131 *
00132 *     Factorize the matrices A and B in the arrays AF and BF.
00133 *
00134       CALL ZGGQRF( N, M, P, 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       CALL ZLACPY( 'Lower', N-1, M, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
00141       CALL ZUNGQR( N, N, MIN( N, M ), Q, LDA, TAUA, WORK, LWORK, INFO )
00142 *
00143 *     Generate the P-by-P matrix Z
00144 *
00145       CALL ZLASET( 'Full', P, P, CROGUE, CROGUE, Z, LDB )
00146       IF( N.LE.P ) THEN
00147          IF( N.GT.0 .AND. N.LT.P )
00148      $      CALL ZLACPY( 'Full', N, P-N, BF, LDB, Z( P-N+1, 1 ), LDB )
00149          IF( N.GT.1 )
00150      $      CALL ZLACPY( 'Lower', N-1, N-1, BF( 2, P-N+1 ), LDB,
00151      $                   Z( P-N+2, P-N+1 ), LDB )
00152       ELSE
00153          IF( P.GT.1 )
00154      $      CALL ZLACPY( 'Lower', P-1, P-1, BF( N-P+2, 1 ), LDB,
00155      $                   Z( 2, 1 ), LDB )
00156       END IF
00157       CALL ZUNGRQ( P, P, MIN( N, P ), Z, LDB, TAUB, WORK, LWORK, INFO )
00158 *
00159 *     Copy R
00160 *
00161       CALL ZLASET( 'Full', N, M, CZERO, CZERO, R, LDA )
00162       CALL ZLACPY( 'Upper', N, M, AF, LDA, R, LDA )
00163 *
00164 *     Copy T
00165 *
00166       CALL ZLASET( 'Full', N, P, CZERO, CZERO, T, LDB )
00167       IF( N.LE.P ) THEN
00168          CALL ZLACPY( 'Upper', N, N, BF( 1, P-N+1 ), LDB, T( 1, P-N+1 ),
00169      $                LDB )
00170       ELSE
00171          CALL ZLACPY( 'Full', N-P, P, BF, LDB, T, LDB )
00172          CALL ZLACPY( 'Upper', P, P, BF( N-P+1, 1 ), LDB, T( N-P+1, 1 ),
00173      $                LDB )
00174       END IF
00175 *
00176 *     Compute R - Q'*A
00177 *
00178       CALL ZGEMM( 'Conjugate transpose', 'No transpose', N, M, N, -CONE,
00179      $            Q, LDA, A, LDA, CONE, R, LDA )
00180 *
00181 *     Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) .
00182 *
00183       RESID = ZLANGE( '1', N, M, R, LDA, RWORK )
00184       IF( ANORM.GT.ZERO ) THEN
00185          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M, N ) ) ) / ANORM ) /
00186      $                 ULP
00187       ELSE
00188          RESULT( 1 ) = ZERO
00189       END IF
00190 *
00191 *     Compute T*Z - Q'*B
00192 *
00193       CALL ZGEMM( 'No Transpose', 'No transpose', N, P, P, CONE, T, LDB,
00194      $            Z, LDB, CZERO, BWK, LDB )
00195       CALL ZGEMM( 'Conjugate transpose', 'No transpose', N, P, N, -CONE,
00196      $            Q, LDA, B, LDB, CONE, BWK, LDB )
00197 *
00198 *     Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
00199 *
00200       RESID = ZLANGE( '1', N, P, BWK, LDB, RWORK )
00201       IF( BNORM.GT.ZERO ) THEN
00202          RESULT( 2 ) = ( ( RESID / DBLE( MAX( 1, P, N ) ) ) / BNORM ) /
00203      $                 ULP
00204       ELSE
00205          RESULT( 2 ) = ZERO
00206       END IF
00207 *
00208 *     Compute I - Q'*Q
00209 *
00210       CALL ZLASET( 'Full', N, N, CZERO, CONE, R, LDA )
00211       CALL ZHERK( 'Upper', 'Conjugate transpose', N, N, -ONE, Q, LDA,
00212      $            ONE, R, LDA )
00213 *
00214 *     Compute norm( I - Q'*Q ) / ( N * ULP ) .
00215 *
00216       RESID = ZLANHE( '1', 'Upper', N, R, LDA, RWORK )
00217       RESULT( 3 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / ULP
00218 *
00219 *     Compute I - Z'*Z
00220 *
00221       CALL ZLASET( 'Full', P, P, CZERO, CONE, T, LDB )
00222       CALL ZHERK( 'Upper', 'Conjugate transpose', P, P, -ONE, Z, LDB,
00223      $            ONE, T, LDB )
00224 *
00225 *     Compute norm( I - Z'*Z ) / ( P*ULP ) .
00226 *
00227       RESID = ZLANHE( '1', 'Upper', P, T, LDB, RWORK )
00228       RESULT( 4 ) = ( RESID / DBLE( MAX( 1, P ) ) ) / ULP
00229 *
00230       RETURN
00231 *
00232 *     End of ZGQRTS
00233 *
00234       END
 All Files Functions