LAPACK 3.3.1
Linear Algebra PACKage

cgqrts.f

Go to the documentation of this file.
00001       SUBROUTINE CGQRTS( 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, P, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       REAL               RWORK( * ), RESULT( 4 )
00013       COMPLEX            A( LDA, * ), AF( LDA, * ), R( LDA, * ),
00014      $                   Q( LDA, * ), B( LDB, * ), BF( LDB, * ),
00015      $                   T( LDB, * ), Z( LDB, * ), BWK( LDB, * ),
00016      $                   TAUA( * ), TAUB( * ), WORK( LWORK )
00017 *     ..
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  CGQRTS tests CGGQRF, 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 array, dimension (LDA,M)
00038 *          The N-by-M matrix A.
00039 *
00040 *  AF      (output) COMPLEX array, dimension (LDA,N)
00041 *          Details of the GQR factorization of A and B, as returned
00042 *          by CGGQRF, see CGGQRF for further details.
00043 *
00044 *  Q       (output) COMPLEX array, dimension (LDA,N)
00045 *          The M-by-M unitary matrix Q.
00046 *
00047 *  R       (workspace) COMPLEX 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 array, dimension (min(M,N))
00054 *          The scalar factors of the elementary reflectors, as returned
00055 *          by CGGQRF.
00056 *
00057 *  B       (input) COMPLEX array, dimension (LDB,P)
00058 *          On entry, the N-by-P matrix A.
00059 *
00060 *  BF      (output) COMPLEX array, dimension (LDB,N)
00061 *          Details of the GQR factorization of A and B, as returned
00062 *          by CGGQRF, see CGGQRF for further details.
00063 *
00064 *  Z       (output) COMPLEX array, dimension (LDB,P)
00065 *          The P-by-P unitary matrix Z.
00066 *
00067 *  T       (workspace) COMPLEX array, dimension (LDB,max(P,N))
00068 *
00069 *  BWK     (workspace) COMPLEX 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 array, dimension (min(P,N))
00076 *          The scalar factors of the elementary reflectors, as returned
00077 *          by SGGRQF.
00078 *
00079 *  WORK    (workspace) COMPLEX 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) REAL array, dimension (max(N,M,P))
00085 *
00086 *  RESULT  (output) REAL 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       REAL               ZERO, ONE
00097       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00098       COMPLEX            CZERO, CONE
00099       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00100      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00101       COMPLEX            CROGUE
00102       PARAMETER          ( CROGUE = ( -1.0E+10, 0.0E+0 ) )
00103 *     ..
00104 *     .. Local Scalars ..
00105       INTEGER            INFO
00106       REAL               ANORM, BNORM, ULP, UNFL, RESID
00107 *     ..
00108 *     .. External Functions ..
00109       REAL               SLAMCH, CLANGE, CLANHE
00110       EXTERNAL           SLAMCH, CLANGE, CLANHE
00111 *     ..
00112 *     .. External Subroutines ..
00113       EXTERNAL           CGEMM, CLACPY, CLASET, CUNGQR,
00114      $                   CUNGRQ, CHERK
00115 *     ..
00116 *     .. Intrinsic Functions ..
00117       INTRINSIC          MAX, MIN, REAL
00118 *     ..
00119 *     .. Executable Statements ..
00120 *
00121       ULP = SLAMCH( 'Precision' )
00122       UNFL = SLAMCH( 'Safe minimum' )
00123 *
00124 *     Copy the matrix A to the array AF.
00125 *
00126       CALL CLACPY( 'Full', N, M, A, LDA, AF, LDA )
00127       CALL CLACPY( 'Full', N, P, B, LDB, BF, LDB )
00128 *
00129       ANORM = MAX( CLANGE( '1', N, M, A, LDA, RWORK ), UNFL )
00130       BNORM = MAX( CLANGE( '1', N, P, B, LDB, RWORK ), UNFL )
00131 *
00132 *     Factorize the matrices A and B in the arrays AF and BF.
00133 *
00134       CALL CGGQRF( N, M, P, AF, LDA, TAUA, BF, LDB, TAUB, WORK,
00135      $             LWORK, INFO )
00136 *
00137 *     Generate the N-by-N matrix Q
00138 *
00139       CALL CLASET( 'Full', N, N, CROGUE, CROGUE, Q, LDA )
00140       CALL CLACPY( 'Lower', N-1, M, AF( 2,1 ), LDA, Q( 2,1 ), LDA )
00141       CALL CUNGQR( N, N, MIN( N, M ), Q, LDA, TAUA, WORK, LWORK, INFO )
00142 *
00143 *     Generate the P-by-P matrix Z
00144 *
00145       CALL CLASET( 'Full', P, P, CROGUE, CROGUE, Z, LDB )
00146       IF( N.LE.P ) THEN
00147          IF( N.GT.0 .AND. N.LT.P )
00148      $      CALL CLACPY( 'Full', N, P-N, BF, LDB, Z( P-N+1, 1 ), LDB )
00149          IF( N.GT.1 )
00150      $      CALL CLACPY( '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 CLACPY( 'Lower', P-1, P-1, BF( N-P+2, 1 ), LDB,
00155      $                    Z( 2, 1 ), LDB )
00156       END IF
00157       CALL CUNGRQ( P, P, MIN( N, P ), Z, LDB, TAUB, WORK, LWORK, INFO )
00158 *
00159 *     Copy R
00160 *
00161       CALL CLASET( 'Full', N, M, CZERO, CZERO, R, LDA )
00162       CALL CLACPY( 'Upper', N, M, AF, LDA, R, LDA )
00163 *
00164 *     Copy T
00165 *
00166       CALL CLASET( 'Full', N, P, CZERO, CZERO, T, LDB )
00167       IF( N.LE.P ) THEN
00168          CALL CLACPY( 'Upper', N, N, BF( 1, P-N+1 ), LDB, T( 1, P-N+1 ),
00169      $                LDB )
00170       ELSE
00171          CALL CLACPY( 'Full', N-P, P, BF, LDB, T, LDB )
00172          CALL CLACPY( '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 CGEMM( '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 = CLANGE( '1', N, M, R, LDA, RWORK )
00184       IF( ANORM.GT.ZERO ) THEN
00185          RESULT( 1 ) = ( ( RESID / REAL( MAX(1,M,N) ) ) / ANORM ) / ULP
00186       ELSE
00187          RESULT( 1 ) = ZERO
00188       END IF
00189 *
00190 *     Compute T*Z - Q'*B
00191 *
00192       CALL CGEMM( 'No Transpose', 'No transpose', N, P, P, CONE, T, LDB,
00193      $            Z, LDB, CZERO, BWK, LDB )
00194       CALL CGEMM( 'Conjugate transpose', 'No transpose', N, P, N, -CONE,
00195      $            Q, LDA, B, LDB, CONE, BWK, LDB )
00196 *
00197 *     Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
00198 *
00199       RESID = CLANGE( '1', N, P, BWK, LDB, RWORK )
00200       IF( BNORM.GT.ZERO ) THEN
00201          RESULT( 2 ) = ( ( RESID / REAL( MAX(1,P,N ) ) )/BNORM ) / ULP
00202       ELSE
00203          RESULT( 2 ) = ZERO
00204       END IF
00205 *
00206 *     Compute I - Q'*Q
00207 *
00208       CALL CLASET( 'Full', N, N, CZERO, CONE, R, LDA )
00209       CALL CHERK( 'Upper', 'Conjugate transpose', N, N, -ONE, Q, LDA,
00210      $            ONE, R, LDA )
00211 *
00212 *     Compute norm( I - Q'*Q ) / ( N * ULP ) .
00213 *
00214       RESID = CLANHE( '1', 'Upper', N, R, LDA, RWORK )
00215       RESULT( 3 ) = ( RESID / REAL( MAX( 1, N ) ) ) / ULP
00216 *
00217 *     Compute I - Z'*Z
00218 *
00219       CALL CLASET( 'Full', P, P, CZERO, CONE, T, LDB )
00220       CALL CHERK( 'Upper', 'Conjugate transpose', P, P, -ONE, Z, LDB,
00221      $            ONE, T, LDB )
00222 *
00223 *     Compute norm( I - Z'*Z ) / ( P*ULP ) .
00224 *
00225       RESID = CLANHE( '1', 'Upper', P, T, LDB, RWORK )
00226       RESULT( 4 ) = ( RESID / REAL( MAX( 1, P ) ) ) / ULP
00227 *
00228       RETURN
00229 *
00230 *     End of CGQRTS
00231 *
00232       END
 All Files Functions