LAPACK 3.3.0

zlqt01.f

Go to the documentation of this file.
00001       SUBROUTINE ZLQT01( M, N, A, AF, Q, L, 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            LDA, LWORK, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   RESULT( * ), RWORK( * )
00013       COMPLEX*16         A( LDA, * ), AF( LDA, * ), L( LDA, * ),
00014      $                   Q( LDA, * ), TAU( * ), WORK( LWORK )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  ZLQT01 tests ZGELQF, which computes the LQ factorization of an m-by-n
00021 *  matrix A, and partially tests ZUNGLQ which forms the n-by-n
00022 *  orthogonal matrix Q.
00023 *
00024 *  ZLQT01 compares L with A*Q', and checks that Q is orthogonal.
00025 *
00026 *  Arguments
00027 *  =========
00028 *
00029 *  M       (input) INTEGER
00030 *          The number of rows of the matrix A.  M >= 0.
00031 *
00032 *  N       (input) INTEGER
00033 *          The number of columns of the matrix A.  N >= 0.
00034 *
00035 *  A       (input) COMPLEX*16 array, dimension (LDA,N)
00036 *          The m-by-n matrix A.
00037 *
00038 *  AF      (output) COMPLEX*16 array, dimension (LDA,N)
00039 *          Details of the LQ factorization of A, as returned by ZGELQF.
00040 *          See ZGELQF for further details.
00041 *
00042 *  Q       (output) COMPLEX*16 array, dimension (LDA,N)
00043 *          The n-by-n orthogonal matrix Q.
00044 *
00045 *  L       (workspace) COMPLEX*16 array, dimension (LDA,max(M,N))
00046 *
00047 *  LDA     (input) INTEGER
00048 *          The leading dimension of the arrays A, AF, Q and L.
00049 *          LDA >= max(M,N).
00050 *
00051 *  TAU     (output) COMPLEX*16 array, dimension (min(M,N))
00052 *          The scalar factors of the elementary reflectors, as returned
00053 *          by ZGELQF.
00054 *
00055 *  WORK    (workspace) COMPLEX*16 array, dimension (LWORK)
00056 *
00057 *  LWORK   (input) INTEGER
00058 *          The dimension of the array WORK.
00059 *
00060 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(M,N))
00061 *
00062 *  RESULT  (output) DOUBLE PRECISION array, dimension (2)
00063 *          The test ratios:
00064 *          RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS )
00065 *          RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
00066 *
00067 *  =====================================================================
00068 *
00069 *     .. Parameters ..
00070       DOUBLE PRECISION   ZERO, ONE
00071       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00072       COMPLEX*16         ROGUE
00073       PARAMETER          ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
00074 *     ..
00075 *     .. Local Scalars ..
00076       INTEGER            INFO, MINMN
00077       DOUBLE PRECISION   ANORM, EPS, RESID
00078 *     ..
00079 *     .. External Functions ..
00080       DOUBLE PRECISION   DLAMCH, ZLANGE, ZLANSY
00081       EXTERNAL           DLAMCH, ZLANGE, ZLANSY
00082 *     ..
00083 *     .. External Subroutines ..
00084       EXTERNAL           ZGELQF, ZGEMM, ZHERK, ZLACPY, ZLASET, ZUNGLQ
00085 *     ..
00086 *     .. Intrinsic Functions ..
00087       INTRINSIC          DBLE, DCMPLX, MAX, MIN
00088 *     ..
00089 *     .. Scalars in Common ..
00090       CHARACTER*32       SRNAMT
00091 *     ..
00092 *     .. Common blocks ..
00093       COMMON             / SRNAMC / SRNAMT
00094 *     ..
00095 *     .. Executable Statements ..
00096 *
00097       MINMN = MIN( M, N )
00098       EPS = DLAMCH( 'Epsilon' )
00099 *
00100 *     Copy the matrix A to the array AF.
00101 *
00102       CALL ZLACPY( 'Full', M, N, A, LDA, AF, LDA )
00103 *
00104 *     Factorize the matrix A in the array AF.
00105 *
00106       SRNAMT = 'ZGELQF'
00107       CALL ZGELQF( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
00108 *
00109 *     Copy details of Q
00110 *
00111       CALL ZLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
00112       IF( N.GT.1 )
00113      $   CALL ZLACPY( 'Upper', M, N-1, AF( 1, 2 ), LDA, Q( 1, 2 ), LDA )
00114 *
00115 *     Generate the n-by-n matrix Q
00116 *
00117       SRNAMT = 'ZUNGLQ'
00118       CALL ZUNGLQ( N, N, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
00119 *
00120 *     Copy L
00121 *
00122       CALL ZLASET( 'Full', M, N, DCMPLX( ZERO ), DCMPLX( ZERO ), L,
00123      $             LDA )
00124       CALL ZLACPY( 'Lower', M, N, AF, LDA, L, LDA )
00125 *
00126 *     Compute L - A*Q'
00127 *
00128       CALL ZGEMM( 'No transpose', 'Conjugate transpose', M, N, N,
00129      $            DCMPLX( -ONE ), A, LDA, Q, LDA, DCMPLX( ONE ), L,
00130      $            LDA )
00131 *
00132 *     Compute norm( L - Q'*A ) / ( N * norm(A) * EPS ) .
00133 *
00134       ANORM = ZLANGE( '1', M, N, A, LDA, RWORK )
00135       RESID = ZLANGE( '1', M, N, L, LDA, RWORK )
00136       IF( ANORM.GT.ZERO ) THEN
00137          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
00138       ELSE
00139          RESULT( 1 ) = ZERO
00140       END IF
00141 *
00142 *     Compute I - Q*Q'
00143 *
00144       CALL ZLASET( 'Full', N, N, DCMPLX( ZERO ), DCMPLX( ONE ), L, LDA )
00145       CALL ZHERK( 'Upper', 'No transpose', N, N, -ONE, Q, LDA, ONE, L,
00146      $            LDA )
00147 *
00148 *     Compute norm( I - Q*Q' ) / ( N * EPS ) .
00149 *
00150       RESID = ZLANSY( '1', 'Upper', N, L, LDA, RWORK )
00151 *
00152       RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
00153 *
00154       RETURN
00155 *
00156 *     End of ZLQT01
00157 *
00158       END
 All Files Functions