LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dqrt01p.f
Go to the documentation of this file.
00001 *> \brief \b DQRT01P
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 DQRT01P( 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   A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00019 *      $                   R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
00020 *      $                   WORK( LWORK )
00021 *       ..
00022 *  
00023 *
00024 *> \par Purpose:
00025 *  =============
00026 *>
00027 *> \verbatim
00028 *>
00029 *> DQRT01P tests DGEQRFP, which computes the QR factorization of an m-by-n
00030 *> matrix A, and partially tests DORGQR which forms the m-by-m
00031 *> orthogonal matrix Q.
00032 *>
00033 *> DQRT01P 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 DOUBLE PRECISION array, dimension (LDA,N)
00054 *>          The m-by-n matrix A.
00055 *> \endverbatim
00056 *>
00057 *> \param[out] AF
00058 *> \verbatim
00059 *>          AF is DOUBLE PRECISION array, dimension (LDA,N)
00060 *>          Details of the QR factorization of A, as returned by DGEQRFP.
00061 *>          See DGEQRFP for further details.
00062 *> \endverbatim
00063 *>
00064 *> \param[out] Q
00065 *> \verbatim
00066 *>          Q is DOUBLE PRECISION array, dimension (LDA,M)
00067 *>          The m-by-m orthogonal matrix Q.
00068 *> \endverbatim
00069 *>
00070 *> \param[out] R
00071 *> \verbatim
00072 *>          R is DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (min(M,N))
00085 *>          The scalar factors of the elementary reflectors, as returned
00086 *>          by DGEQRFP.
00087 *> \endverbatim
00088 *>
00089 *> \param[out] WORK
00090 *> \verbatim
00091 *>          WORK is DOUBLE PRECISION 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 double_lin
00124 *
00125 *  =====================================================================
00126       SUBROUTINE DQRT01P( 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   A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
00139      $                   R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
00140      $                   WORK( LWORK )
00141 *     ..
00142 *
00143 *  =====================================================================
00144 *
00145 *     .. Parameters ..
00146       DOUBLE PRECISION   ZERO, ONE
00147       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00148       DOUBLE PRECISION   ROGUE
00149       PARAMETER          ( ROGUE = -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, DLANGE, DLANSY
00157       EXTERNAL           DLAMCH, DLANGE, DLANSY
00158 *     ..
00159 *     .. External Subroutines ..
00160       EXTERNAL           DGEMM, DGEQRFP, DLACPY, DLASET, DORGQR, DSYRK
00161 *     ..
00162 *     .. Intrinsic Functions ..
00163       INTRINSIC          DBLE, 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 DLACPY( 'Full', M, N, A, LDA, AF, LDA )
00179 *
00180 *     Factorize the matrix A in the array AF.
00181 *
00182       SRNAMT = 'DGEQRFP'
00183       CALL DGEQRFP( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
00184 *
00185 *     Copy details of Q
00186 *
00187       CALL DLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
00188       CALL DLACPY( 'Lower', M-1, N, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
00189 *
00190 *     Generate the m-by-m matrix Q
00191 *
00192       SRNAMT = 'DORGQR'
00193       CALL DORGQR( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
00194 *
00195 *     Copy R
00196 *
00197       CALL DLASET( 'Full', M, N, ZERO, ZERO, R, LDA )
00198       CALL DLACPY( 'Upper', M, N, AF, LDA, R, LDA )
00199 *
00200 *     Compute R - Q'*A
00201 *
00202       CALL DGEMM( 'Transpose', 'No transpose', M, N, M, -ONE, Q, LDA, A,
00203      $            LDA, ONE, R, LDA )
00204 *
00205 *     Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
00206 *
00207       ANORM = DLANGE( '1', M, N, A, LDA, RWORK )
00208       RESID = DLANGE( '1', M, N, R, LDA, RWORK )
00209       IF( ANORM.GT.ZERO ) THEN
00210          RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M ) ) ) / ANORM ) / EPS
00211       ELSE
00212          RESULT( 1 ) = ZERO
00213       END IF
00214 *
00215 *     Compute I - Q'*Q
00216 *
00217       CALL DLASET( 'Full', M, M, ZERO, ONE, R, LDA )
00218       CALL DSYRK( 'Upper', 'Transpose', M, M, -ONE, Q, LDA, ONE, R,
00219      $            LDA )
00220 *
00221 *     Compute norm( I - Q'*Q ) / ( M * EPS ) .
00222 *
00223       RESID = DLANSY( '1', 'Upper', M, R, LDA, RWORK )
00224 *
00225       RESULT( 2 ) = ( RESID / DBLE( MAX( 1, M ) ) ) / EPS
00226 *
00227       RETURN
00228 *
00229 *     End of DQRT01P
00230 *
00231       END
 All Files Functions