LAPACK 3.3.1
Linear Algebra PACKage

dgrqts.f

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