LAPACK 3.3.0

cgrqts.f

Go to the documentation of this file.
00001       SUBROUTINE CGRQTS( 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, P, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       REAL               RESULT( 4 ), RWORK( * )
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 *  CGRQTS tests CGGRQF, 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 array, dimension (LDA,N)
00038 *          The M-by-N matrix A.
00039 *
00040 *  AF      (output) COMPLEX array, dimension (LDA,N)
00041 *          Details of the GRQ factorization of A and B, as returned
00042 *          by CGGRQF, see CGGRQF for further details.
00043 *
00044 *  Q       (output) COMPLEX array, dimension (LDA,N)
00045 *          The N-by-N 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 SGGQRC.
00056 *
00057 *  B       (input) COMPLEX array, dimension (LDB,N)
00058 *          On entry, the P-by-N 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 CGGRQF, see CGGRQF for further details.
00063 *
00064 *  Z       (output) REAL 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(M,P,N)**2.
00083 *
00084 *  RWORK   (workspace) REAL array, dimension (M)
00085 *
00086 *  RESULT  (output) REAL 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       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, CGGRQF, 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', M, N, A, LDA, AF, LDA )
00127       CALL CLACPY( 'Full', P, N, B, LDB, BF, LDB )
00128 *
00129       ANORM = MAX( CLANGE( '1', M, N, A, LDA, RWORK ), UNFL )
00130       BNORM = MAX( CLANGE( '1', P, N, B, LDB, RWORK ), UNFL )
00131 *
00132 *     Factorize the matrices A and B in the arrays AF and BF.
00133 *
00134       CALL CGGRQF( M, P, N, 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       IF( M.LE.N ) THEN
00141          IF( M.GT.0 .AND. M.LT.N )
00142      $      CALL CLACPY( 'Full', M, N-M, AF, LDA, Q( N-M+1, 1 ), LDA )
00143          IF( M.GT.1 )
00144      $      CALL CLACPY( '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 CLACPY( 'Lower', N-1, N-1, AF( M-N+2, 1 ), LDA,
00149      $                   Q( 2, 1 ), LDA )
00150       END IF
00151       CALL CUNGRQ( N, N, MIN( M, N ), Q, LDA, TAUA, WORK, LWORK, INFO )
00152 *
00153 *     Generate the P-by-P matrix Z
00154 *
00155       CALL CLASET( 'Full', P, P, CROGUE, CROGUE, Z, LDB )
00156       IF( P.GT.1 )
00157      $   CALL CLACPY( 'Lower', P-1, N, BF( 2,1 ), LDB, Z( 2,1 ), LDB )
00158       CALL CUNGQR( P, P, MIN( P,N ), Z, LDB, TAUB, WORK, LWORK, INFO )
00159 *
00160 *     Copy R
00161 *
00162       CALL CLASET( 'Full', M, N, CZERO, CZERO, R, LDA )
00163       IF( M.LE.N )THEN
00164          CALL CLACPY( 'Upper', M, M, AF( 1, N-M+1 ), LDA, R( 1, N-M+1 ),
00165      $                LDA )
00166       ELSE
00167          CALL CLACPY( 'Full', M-N, N, AF, LDA, R, LDA )
00168          CALL CLACPY( '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 CLASET( 'Full', P, N, CZERO, CZERO, T, LDB )
00175       CALL CLACPY( 'Upper', P, N, BF, LDB, T, LDB )
00176 *
00177 *     Compute R - A*Q'
00178 *
00179       CALL CGEMM( '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 = CLANGE( '1', M, N, R, LDA, RWORK )
00185       IF( ANORM.GT.ZERO ) THEN
00186          RESULT( 1 ) = ( ( RESID / REAL(MAX(1,M,N) ) ) / ANORM ) / ULP
00187       ELSE
00188          RESULT( 1 ) = ZERO
00189       END IF
00190 *
00191 *     Compute T*Q - Z'*B
00192 *
00193       CALL CGEMM( 'Conjugate transpose', 'No transpose', P, N, P, CONE,
00194      $           Z, LDB, B, LDB, CZERO, BWK, LDB )
00195       CALL CGEMM( 'No transpose', 'No transpose', P, N, N, CONE, T, LDB,
00196      $            Q, LDA, -CONE, BWK, LDB )
00197 *
00198 *     Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
00199 *
00200       RESID = CLANGE( '1', P, N, BWK, LDB, RWORK )
00201       IF( BNORM.GT.ZERO ) THEN
00202          RESULT( 2 ) = ( ( RESID / REAL( MAX( 1,P,M ) ) )/BNORM ) / ULP
00203       ELSE
00204          RESULT( 2 ) = ZERO
00205       END IF
00206 *
00207 *     Compute I - Q*Q'
00208 *
00209       CALL CLASET( 'Full', N, N, CZERO, CONE, R, LDA )
00210       CALL CHERK( 'Upper', 'No Transpose', N, N, -ONE, Q, LDA, ONE, R,
00211      $            LDA )
00212 *
00213 *     Compute norm( I - Q'*Q ) / ( N * ULP ) .
00214 *
00215       RESID = CLANHE( '1', 'Upper', N, R, LDA, RWORK )
00216       RESULT( 3 ) = ( RESID / REAL( MAX( 1,N ) ) ) / ULP
00217 *
00218 *     Compute I - Z'*Z
00219 *
00220       CALL CLASET( 'Full', P, P, CZERO, CONE, T, LDB )
00221       CALL CHERK( 'Upper', 'Conjugate transpose', P, P, -ONE, Z, LDB,
00222      $            ONE, T, LDB )
00223 *
00224 *     Compute norm( I - Z'*Z ) / ( P*ULP ) .
00225 *
00226       RESID = CLANHE( '1', 'Upper', P, T, LDB, RWORK )
00227       RESULT( 4 ) = ( RESID / REAL( MAX( 1,P ) ) ) / ULP
00228 *
00229       RETURN
00230 *
00231 *     End of CGRQTS
00232 *
00233       END
 All Files Functions