LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cungr2.f
Go to the documentation of this file.
00001 *> \brief \b CUNGR2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CUNGR2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cungr2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cungr2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cungr2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CUNGR2( M, N, K, A, LDA, TAU, WORK, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, K, LDA, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00028 *       ..
00029 *  
00030 *
00031 *> \par Purpose:
00032 *  =============
00033 *>
00034 *> \verbatim
00035 *>
00036 *> CUNGR2 generates an m by n complex matrix Q with orthonormal rows,
00037 *> which is defined as the last m rows of a product of k elementary
00038 *> reflectors of order n
00039 *>
00040 *>       Q  =  H(1)**H H(2)**H . . . H(k)**H
00041 *>
00042 *> as returned by CGERQF.
00043 *> \endverbatim
00044 *
00045 *  Arguments:
00046 *  ==========
00047 *
00048 *> \param[in] M
00049 *> \verbatim
00050 *>          M is INTEGER
00051 *>          The number of rows of the matrix Q. M >= 0.
00052 *> \endverbatim
00053 *>
00054 *> \param[in] N
00055 *> \verbatim
00056 *>          N is INTEGER
00057 *>          The number of columns of the matrix Q. N >= M.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] K
00061 *> \verbatim
00062 *>          K is INTEGER
00063 *>          The number of elementary reflectors whose product defines the
00064 *>          matrix Q. M >= K >= 0.
00065 *> \endverbatim
00066 *>
00067 *> \param[in,out] A
00068 *> \verbatim
00069 *>          A is COMPLEX array, dimension (LDA,N)
00070 *>          On entry, the (m-k+i)-th row must contain the vector which
00071 *>          defines the elementary reflector H(i), for i = 1,2,...,k, as
00072 *>          returned by CGERQF in the last k rows of its array argument
00073 *>          A.
00074 *>          On exit, the m-by-n matrix Q.
00075 *> \endverbatim
00076 *>
00077 *> \param[in] LDA
00078 *> \verbatim
00079 *>          LDA is INTEGER
00080 *>          The first dimension of the array A. LDA >= max(1,M).
00081 *> \endverbatim
00082 *>
00083 *> \param[in] TAU
00084 *> \verbatim
00085 *>          TAU is COMPLEX array, dimension (K)
00086 *>          TAU(i) must contain the scalar factor of the elementary
00087 *>          reflector H(i), as returned by CGERQF.
00088 *> \endverbatim
00089 *>
00090 *> \param[out] WORK
00091 *> \verbatim
00092 *>          WORK is COMPLEX array, dimension (M)
00093 *> \endverbatim
00094 *>
00095 *> \param[out] INFO
00096 *> \verbatim
00097 *>          INFO is INTEGER
00098 *>          = 0: successful exit
00099 *>          < 0: if INFO = -i, the i-th argument has an illegal value
00100 *> \endverbatim
00101 *
00102 *  Authors:
00103 *  ========
00104 *
00105 *> \author Univ. of Tennessee 
00106 *> \author Univ. of California Berkeley 
00107 *> \author Univ. of Colorado Denver 
00108 *> \author NAG Ltd. 
00109 *
00110 *> \date November 2011
00111 *
00112 *> \ingroup complexOTHERcomputational
00113 *
00114 *  =====================================================================
00115       SUBROUTINE CUNGR2( M, N, K, A, LDA, TAU, WORK, INFO )
00116 *
00117 *  -- LAPACK computational routine (version 3.4.0) --
00118 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00119 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00120 *     November 2011
00121 *
00122 *     .. Scalar Arguments ..
00123       INTEGER            INFO, K, LDA, M, N
00124 *     ..
00125 *     .. Array Arguments ..
00126       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00127 *     ..
00128 *
00129 *  =====================================================================
00130 *
00131 *     .. Parameters ..
00132       COMPLEX            ONE, ZERO
00133       PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ),
00134      $                   ZERO = ( 0.0E+0, 0.0E+0 ) )
00135 *     ..
00136 *     .. Local Scalars ..
00137       INTEGER            I, II, J, L
00138 *     ..
00139 *     .. External Subroutines ..
00140       EXTERNAL           CLACGV, CLARF, CSCAL, XERBLA
00141 *     ..
00142 *     .. Intrinsic Functions ..
00143       INTRINSIC          CONJG, MAX
00144 *     ..
00145 *     .. Executable Statements ..
00146 *
00147 *     Test the input arguments
00148 *
00149       INFO = 0
00150       IF( M.LT.0 ) THEN
00151          INFO = -1
00152       ELSE IF( N.LT.M ) THEN
00153          INFO = -2
00154       ELSE IF( K.LT.0 .OR. K.GT.M ) THEN
00155          INFO = -3
00156       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00157          INFO = -5
00158       END IF
00159       IF( INFO.NE.0 ) THEN
00160          CALL XERBLA( 'CUNGR2', -INFO )
00161          RETURN
00162       END IF
00163 *
00164 *     Quick return if possible
00165 *
00166       IF( M.LE.0 )
00167      $   RETURN
00168 *
00169       IF( K.LT.M ) THEN
00170 *
00171 *        Initialise rows 1:m-k to rows of the unit matrix
00172 *
00173          DO 20 J = 1, N
00174             DO 10 L = 1, M - K
00175                A( L, J ) = ZERO
00176    10       CONTINUE
00177             IF( J.GT.N-M .AND. J.LE.N-K )
00178      $         A( M-N+J, J ) = ONE
00179    20    CONTINUE
00180       END IF
00181 *
00182       DO 40 I = 1, K
00183          II = M - K + I
00184 *
00185 *        Apply H(i)**H to A(1:m-k+i,1:n-k+i) from the right
00186 *
00187          CALL CLACGV( N-M+II-1, A( II, 1 ), LDA )
00188          A( II, N-M+II ) = ONE
00189          CALL CLARF( 'Right', II-1, N-M+II, A( II, 1 ), LDA,
00190      $               CONJG( TAU( I ) ), A, LDA, WORK )
00191          CALL CSCAL( N-M+II-1, -TAU( I ), A( II, 1 ), LDA )
00192          CALL CLACGV( N-M+II-1, A( II, 1 ), LDA )
00193          A( II, N-M+II ) = ONE - CONJG( TAU( I ) )
00194 *
00195 *        Set A(m-k+i,n-k+i+1:n) to zero
00196 *
00197          DO 30 L = N - M + II + 1, N
00198             A( II, L ) = ZERO
00199    30    CONTINUE
00200    40 CONTINUE
00201       RETURN
00202 *
00203 *     End of CUNGR2
00204 *
00205       END
 All Files Functions