LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zqrt01.f
Go to the documentation of this file.
00001 *> \brief \b ZQRT01
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE ZQRT01( M, N, A, AF, Q, R, LDA, TAU, WORK, LWORK,
00012 *                          RWORK, RESULT )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       INTEGER            LDA, LWORK, M, N
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       DOUBLE PRECISION   RESULT( * ), RWORK( * )
00019 *       COMPLEX*16         A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00020 *      $                   R( LDA, * ), TAU( * ), WORK( LWORK )
00021 *       ..
00022 *  
00023 *
00024 *> \par Purpose:
00025 *  =============
00026 *>
00027 *> \verbatim
00028 *>
00029 *> ZQRT01 tests ZGEQRF, which computes the QR factorization of an m-by-n
00030 *> matrix A, and partially tests ZUNGQR which forms the m-by-m
00031 *> orthogonal matrix Q.
00032 *>
00033 *> ZQRT01 compares R with Q'*A, and checks that Q is orthogonal.
00034 *> \endverbatim
00035 *
00036 *  Arguments:
00037 *  ==========
00038 *
00039 *> \param[in] M
00040 *> \verbatim
00041 *>          M is INTEGER
00042 *>          The number of rows of the matrix A.  M >= 0.
00043 *> \endverbatim
00044 *>
00045 *> \param[in] N
00046 *> \verbatim
00047 *>          N is INTEGER
00048 *>          The number of columns of the matrix A.  N >= 0.
00049 *> \endverbatim
00050 *>
00051 *> \param[in] A
00052 *> \verbatim
00053 *>          A is COMPLEX*16 array, dimension (LDA,N)
00054 *>          The m-by-n matrix A.
00055 *> \endverbatim
00056 *>
00057 *> \param[out] AF
00058 *> \verbatim
00059 *>          AF is COMPLEX*16 array, dimension (LDA,N)
00060 *>          Details of the QR factorization of A, as returned by ZGEQRF.
00061 *>          See ZGEQRF for further details.
00062 *> \endverbatim
00063 *>
00064 *> \param[out] Q
00065 *> \verbatim
00066 *>          Q is COMPLEX*16 array, dimension (LDA,M)
00067 *>          The m-by-m orthogonal matrix Q.
00068 *> \endverbatim
00069 *>
00070 *> \param[out] R
00071 *> \verbatim
00072 *>          R is COMPLEX*16 array, dimension (LDA,max(M,N))
00073 *> \endverbatim
00074 *>
00075 *> \param[in] LDA
00076 *> \verbatim
00077 *>          LDA is INTEGER
00078 *>          The leading dimension of the arrays A, AF, Q and R.
00079 *>          LDA >= max(M,N).
00080 *> \endverbatim
00081 *>
00082 *> \param[out] TAU
00083 *> \verbatim
00084 *>          TAU is COMPLEX*16 array, dimension (min(M,N))
00085 *>          The scalar factors of the elementary reflectors, as returned
00086 *>          by ZGEQRF.
00087 *> \endverbatim
00088 *>
00089 *> \param[out] WORK
00090 *> \verbatim
00091 *>          WORK is COMPLEX*16 array, dimension (LWORK)
00092 *> \endverbatim
00093 *>
00094 *> \param[in] LWORK
00095 *> \verbatim
00096 *>          LWORK is INTEGER
00097 *>          The dimension of the array WORK.
00098 *> \endverbatim
00099 *>
00100 *> \param[out] RWORK
00101 *> \verbatim
00102 *>          RWORK is DOUBLE PRECISION array, dimension (M)
00103 *> \endverbatim
00104 *>
00105 *> \param[out] RESULT
00106 *> \verbatim
00107 *>          RESULT is DOUBLE PRECISION array, dimension (2)
00108 *>          The test ratios:
00109 *>          RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
00110 *>          RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
00111 *> \endverbatim
00112 *
00113 *  Authors:
00114 *  ========
00115 *
00116 *> \author Univ. of Tennessee 
00117 *> \author Univ. of California Berkeley 
00118 *> \author Univ. of Colorado Denver 
00119 *> \author NAG Ltd. 
00120 *
00121 *> \date November 2011
00122 *
00123 *> \ingroup complex16_lin
00124 *
00125 *  =====================================================================
00126       SUBROUTINE ZQRT01( M, N, A, AF, Q, R, LDA, TAU, WORK, LWORK,
00127      $                   RWORK, RESULT )
00128 *
00129 *  -- LAPACK test routine (version 3.4.0) --
00130 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00131 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00132 *     November 2011
00133 *
00134 *     .. Scalar Arguments ..
00135       INTEGER            LDA, LWORK, M, N
00136 *     ..
00137 *     .. Array Arguments ..
00138       DOUBLE PRECISION   RESULT( * ), RWORK( * )
00139       COMPLEX*16         A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00140      $                   R( LDA, * ), TAU( * ), WORK( LWORK )
00141 *     ..
00142 *
00143 *  =====================================================================
00144 *
00145 *     .. Parameters ..
00146       DOUBLE PRECISION   ZERO, ONE
00147       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00148       COMPLEX*16         ROGUE
00149       PARAMETER          ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
00150 *     ..
00151 *     .. Local Scalars ..
00152       INTEGER            INFO, MINMN
00153       DOUBLE PRECISION   ANORM, EPS, RESID
00154 *     ..
00155 *     .. External Functions ..
00156       DOUBLE PRECISION   DLAMCH, ZLANGE, ZLANSY
00157       EXTERNAL           DLAMCH, ZLANGE, ZLANSY
00158 *     ..
00159 *     .. External Subroutines ..
00160       EXTERNAL           ZGEMM, ZGEQRF, ZHERK, ZLACPY, ZLASET, ZUNGQR
00161 *     ..
00162 *     .. Intrinsic Functions ..
00163       INTRINSIC          DBLE, DCMPLX, MAX, MIN
00164 *     ..
00165 *     .. Scalars in Common ..
00166       CHARACTER*32       SRNAMT
00167 *     ..
00168 *     .. Common blocks ..
00169       COMMON             / SRNAMC / SRNAMT
00170 *     ..
00171 *     .. Executable Statements ..
00172 *
00173       MINMN = MIN( M, N )
00174       EPS = DLAMCH( 'Epsilon' )
00175 *
00176 *     Copy the matrix A to the array AF.
00177 *
00178       CALL ZLACPY( 'Full', M, N, A, LDA, AF, LDA )
00179 *
00180 *     Factorize the matrix A in the array AF.
00181 *
00182       SRNAMT = 'ZGEQRF'
00183       CALL ZGEQRF( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
00184 *
00185 *     Copy details of Q
00186 *
00187       CALL ZLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
00188       CALL ZLACPY( 'Lower', M-1, N, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
00189 *
00190 *     Generate the m-by-m matrix Q
00191 *
00192       SRNAMT = 'ZUNGQR'
00193       CALL ZUNGQR( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
00194 *
00195 *     Copy R
00196 *
00197       CALL ZLASET( 'Full', M, N, DCMPLX( ZERO ), DCMPLX( ZERO ), R,
00198      $             LDA )
00199       CALL ZLACPY( 'Upper', M, N, AF, LDA, R, LDA )
00200 *
00201 *     Compute R - Q'*A
00202 *
00203       CALL ZGEMM( 'Conjugate transpose', 'No transpose', M, N, M,
00204      $            DCMPLX( -ONE ), Q, LDA, A, LDA, DCMPLX( ONE ), R,
00205      $            LDA )
00206 *
00207 *     Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
00208 *
00209       ANORM = ZLANGE( '1', M, N, A, LDA, RWORK )
00210       RESID = ZLANGE( '1', M, N, R, LDA, RWORK )
00211       IF( ANORM.GT.ZERO ) THEN
00212          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M ) ) ) / ANORM ) / EPS
00213       ELSE
00214          RESULT( 1 ) = ZERO
00215       END IF
00216 *
00217 *     Compute I - Q'*Q
00218 *
00219       CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), R, LDA )
00220       CALL ZHERK( 'Upper', 'Conjugate transpose', M, M, -ONE, Q, LDA,
00221      $            ONE, R, LDA )
00222 *
00223 *     Compute norm( I - Q'*Q ) / ( M * EPS ) .
00224 *
00225       RESID = ZLANSY( '1', 'Upper', M, R, LDA, RWORK )
00226 *
00227       RESULT( 2 ) = ( RESID / DBLE( MAX( 1, M ) ) ) / EPS
00228 *
00229       RETURN
00230 *
00231 *     End of ZQRT01
00232 *
00233       END
 All Files Functions