LAPACK 3.3.0

zqrt03.f

Go to the documentation of this file.
00001       SUBROUTINE ZQRT03( M, N, K, AF, C, CC, Q, LDA, TAU, WORK, LWORK,
00002      $                   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            K, LDA, LWORK, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   RESULT( * ), RWORK( * )
00013       COMPLEX*16         AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
00014      $                   Q( LDA, * ), TAU( * ), WORK( LWORK )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  ZQRT03 tests ZUNMQR, which computes Q*C, Q'*C, C*Q or C*Q'.
00021 *
00022 *  ZQRT03 compares the results of a call to ZUNMQR with the results of
00023 *  forming Q explicitly by a call to ZUNGQR and then performing matrix
00024 *  multiplication by a call to ZGEMM.
00025 *
00026 *  Arguments
00027 *  =========
00028 *
00029 *  M       (input) INTEGER
00030 *          The order of the orthogonal matrix Q.  M >= 0.
00031 *
00032 *  N       (input) INTEGER
00033 *          The number of rows or columns of the matrix C; C is m-by-n if
00034 *          Q is applied from the left, or n-by-m if Q is applied from
00035 *          the right.  N >= 0.
00036 *
00037 *  K       (input) INTEGER
00038 *          The number of elementary reflectors whose product defines the
00039 *          orthogonal matrix Q.  M >= K >= 0.
00040 *
00041 *  AF      (input) COMPLEX*16 array, dimension (LDA,N)
00042 *          Details of the QR factorization of an m-by-n matrix, as
00043 *          returnedby ZGEQRF. See CGEQRF for further details.
00044 *
00045 *  C       (workspace) COMPLEX*16 array, dimension (LDA,N)
00046 *
00047 *  CC      (workspace) COMPLEX*16 array, dimension (LDA,N)
00048 *
00049 *  Q       (workspace) COMPLEX*16 array, dimension (LDA,M)
00050 *
00051 *  LDA     (input) INTEGER
00052 *          The leading dimension of the arrays AF, C, CC, and Q.
00053 *
00054 *  TAU     (input) COMPLEX*16 array, dimension (min(M,N))
00055 *          The scalar factors of the elementary reflectors corresponding
00056 *          to the QR factorization in AF.
00057 *
00058 *  WORK    (workspace) COMPLEX*16 array, dimension (LWORK)
00059 *
00060 *  LWORK   (input) INTEGER
00061 *          The length of WORK.  LWORK must be at least M, and should be
00062 *          M*NB, where NB is the blocksize for this environment.
00063 *
00064 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (M)
00065 *
00066 *  RESULT  (output) DOUBLE PRECISION array, dimension (4)
00067 *          The test ratios compare two techniques for multiplying a
00068 *          random matrix C by an m-by-m orthogonal matrix Q.
00069 *          RESULT(1) = norm( Q*C - Q*C )  / ( M * norm(C) * EPS )
00070 *          RESULT(2) = norm( C*Q - C*Q )  / ( M * norm(C) * EPS )
00071 *          RESULT(3) = norm( Q'*C - Q'*C )/ ( M * norm(C) * EPS )
00072 *          RESULT(4) = norm( C*Q' - C*Q' )/ ( M * norm(C) * EPS )
00073 *
00074 *  =====================================================================
00075 *
00076 *     .. Parameters ..
00077       DOUBLE PRECISION   ZERO, ONE
00078       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00079       COMPLEX*16         ROGUE
00080       PARAMETER          ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
00081 *     ..
00082 *     .. Local Scalars ..
00083       CHARACTER          SIDE, TRANS
00084       INTEGER            INFO, ISIDE, ITRANS, J, MC, NC
00085       DOUBLE PRECISION   CNORM, EPS, RESID
00086 *     ..
00087 *     .. External Functions ..
00088       LOGICAL            LSAME
00089       DOUBLE PRECISION   DLAMCH, ZLANGE
00090       EXTERNAL           LSAME, DLAMCH, ZLANGE
00091 *     ..
00092 *     .. External Subroutines ..
00093       EXTERNAL           ZGEMM, ZLACPY, ZLARNV, ZLASET, ZUNGQR, ZUNMQR
00094 *     ..
00095 *     .. Local Arrays ..
00096       INTEGER            ISEED( 4 )
00097 *     ..
00098 *     .. Intrinsic Functions ..
00099       INTRINSIC          DBLE, DCMPLX, MAX
00100 *     ..
00101 *     .. Scalars in Common ..
00102       CHARACTER*32       SRNAMT
00103 *     ..
00104 *     .. Common blocks ..
00105       COMMON             / SRNAMC / SRNAMT
00106 *     ..
00107 *     .. Data statements ..
00108       DATA               ISEED / 1988, 1989, 1990, 1991 /
00109 *     ..
00110 *     .. Executable Statements ..
00111 *
00112       EPS = DLAMCH( 'Epsilon' )
00113 *
00114 *     Copy the first k columns of the factorization to the array Q
00115 *
00116       CALL ZLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
00117       CALL ZLACPY( 'Lower', M-1, K, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
00118 *
00119 *     Generate the m-by-m matrix Q
00120 *
00121       SRNAMT = 'ZUNGQR'
00122       CALL ZUNGQR( M, M, K, Q, LDA, TAU, WORK, LWORK, INFO )
00123 *
00124       DO 30 ISIDE = 1, 2
00125          IF( ISIDE.EQ.1 ) THEN
00126             SIDE = 'L'
00127             MC = M
00128             NC = N
00129          ELSE
00130             SIDE = 'R'
00131             MC = N
00132             NC = M
00133          END IF
00134 *
00135 *        Generate MC by NC matrix C
00136 *
00137          DO 10 J = 1, NC
00138             CALL ZLARNV( 2, ISEED, MC, C( 1, J ) )
00139    10    CONTINUE
00140          CNORM = ZLANGE( '1', MC, NC, C, LDA, RWORK )
00141          IF( CNORM.EQ.ZERO )
00142      $      CNORM = ONE
00143 *
00144          DO 20 ITRANS = 1, 2
00145             IF( ITRANS.EQ.1 ) THEN
00146                TRANS = 'N'
00147             ELSE
00148                TRANS = 'C'
00149             END IF
00150 *
00151 *           Copy C
00152 *
00153             CALL ZLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
00154 *
00155 *           Apply Q or Q' to C
00156 *
00157             SRNAMT = 'ZUNMQR'
00158             CALL ZUNMQR( SIDE, TRANS, MC, NC, K, AF, LDA, TAU, CC, LDA,
00159      $                   WORK, LWORK, INFO )
00160 *
00161 *           Form explicit product and subtract
00162 *
00163             IF( LSAME( SIDE, 'L' ) ) THEN
00164                CALL ZGEMM( TRANS, 'No transpose', MC, NC, MC,
00165      $                     DCMPLX( -ONE ), Q, LDA, C, LDA,
00166      $                     DCMPLX( ONE ), CC, LDA )
00167             ELSE
00168                CALL ZGEMM( 'No transpose', TRANS, MC, NC, NC,
00169      $                     DCMPLX( -ONE ), C, LDA, Q, LDA,
00170      $                     DCMPLX( ONE ), CC, LDA )
00171             END IF
00172 *
00173 *           Compute error in the difference
00174 *
00175             RESID = ZLANGE( '1', MC, NC, CC, LDA, RWORK )
00176             RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
00177      $         ( DBLE( MAX( 1, M ) )*CNORM*EPS )
00178 *
00179    20    CONTINUE
00180    30 CONTINUE
00181 *
00182       RETURN
00183 *
00184 *     End of ZQRT03
00185 *
00186       END
 All Files Functions