LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cungtr.f
Go to the documentation of this file.
00001 *> \brief \b CUNGTR
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CUNGTR + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cungtr.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cungtr.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cungtr.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          UPLO
00025 *       INTEGER            INFO, LDA, LWORK, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> CUNGTR generates a complex unitary matrix Q which is defined as the
00038 *> product of n-1 elementary reflectors of order N, as returned by
00039 *> CHETRD:
00040 *>
00041 *> if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
00042 *>
00043 *> if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
00044 *> \endverbatim
00045 *
00046 *  Arguments:
00047 *  ==========
00048 *
00049 *> \param[in] UPLO
00050 *> \verbatim
00051 *>          UPLO is CHARACTER*1
00052 *>          = 'U': Upper triangle of A contains elementary reflectors
00053 *>                 from CHETRD;
00054 *>          = 'L': Lower triangle of A contains elementary reflectors
00055 *>                 from CHETRD.
00056 *> \endverbatim
00057 *>
00058 *> \param[in] N
00059 *> \verbatim
00060 *>          N is INTEGER
00061 *>          The order of the matrix Q. N >= 0.
00062 *> \endverbatim
00063 *>
00064 *> \param[in,out] A
00065 *> \verbatim
00066 *>          A is COMPLEX array, dimension (LDA,N)
00067 *>          On entry, the vectors which define the elementary reflectors,
00068 *>          as returned by CHETRD.
00069 *>          On exit, the N-by-N unitary matrix Q.
00070 *> \endverbatim
00071 *>
00072 *> \param[in] LDA
00073 *> \verbatim
00074 *>          LDA is INTEGER
00075 *>          The leading dimension of the array A. LDA >= N.
00076 *> \endverbatim
00077 *>
00078 *> \param[in] TAU
00079 *> \verbatim
00080 *>          TAU is COMPLEX array, dimension (N-1)
00081 *>          TAU(i) must contain the scalar factor of the elementary
00082 *>          reflector H(i), as returned by CHETRD.
00083 *> \endverbatim
00084 *>
00085 *> \param[out] WORK
00086 *> \verbatim
00087 *>          WORK is COMPLEX array, dimension (MAX(1,LWORK))
00088 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00089 *> \endverbatim
00090 *>
00091 *> \param[in] LWORK
00092 *> \verbatim
00093 *>          LWORK is INTEGER
00094 *>          The dimension of the array WORK. LWORK >= N-1.
00095 *>          For optimum performance LWORK >= (N-1)*NB, where NB is
00096 *>          the optimal blocksize.
00097 *>
00098 *>          If LWORK = -1, then a workspace query is assumed; the routine
00099 *>          only calculates the optimal size of the WORK array, returns
00100 *>          this value as the first entry of the WORK array, and no error
00101 *>          message related to LWORK is issued by XERBLA.
00102 *> \endverbatim
00103 *>
00104 *> \param[out] INFO
00105 *> \verbatim
00106 *>          INFO is INTEGER
00107 *>          = 0:  successful exit
00108 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00109 *> \endverbatim
00110 *
00111 *  Authors:
00112 *  ========
00113 *
00114 *> \author Univ. of Tennessee 
00115 *> \author Univ. of California Berkeley 
00116 *> \author Univ. of Colorado Denver 
00117 *> \author NAG Ltd. 
00118 *
00119 *> \date November 2011
00120 *
00121 *> \ingroup complexOTHERcomputational
00122 *
00123 *  =====================================================================
00124       SUBROUTINE CUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
00125 *
00126 *  -- LAPACK computational routine (version 3.4.0) --
00127 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00128 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00129 *     November 2011
00130 *
00131 *     .. Scalar Arguments ..
00132       CHARACTER          UPLO
00133       INTEGER            INFO, LDA, LWORK, N
00134 *     ..
00135 *     .. Array Arguments ..
00136       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00137 *     ..
00138 *
00139 *  =====================================================================
00140 *
00141 *     .. Parameters ..
00142       COMPLEX            ZERO, ONE
00143       PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ),
00144      $                   ONE = ( 1.0E+0, 0.0E+0 ) )
00145 *     ..
00146 *     .. Local Scalars ..
00147       LOGICAL            LQUERY, UPPER
00148       INTEGER            I, IINFO, J, LWKOPT, NB
00149 *     ..
00150 *     .. External Functions ..
00151       LOGICAL            LSAME
00152       INTEGER            ILAENV
00153       EXTERNAL           ILAENV, LSAME
00154 *     ..
00155 *     .. External Subroutines ..
00156       EXTERNAL           CUNGQL, CUNGQR, XERBLA
00157 *     ..
00158 *     .. Intrinsic Functions ..
00159       INTRINSIC          MAX
00160 *     ..
00161 *     .. Executable Statements ..
00162 *
00163 *     Test the input arguments
00164 *
00165       INFO = 0
00166       LQUERY = ( LWORK.EQ.-1 )
00167       UPPER = LSAME( UPLO, 'U' )
00168       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00169          INFO = -1
00170       ELSE IF( N.LT.0 ) THEN
00171          INFO = -2
00172       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00173          INFO = -4
00174       ELSE IF( LWORK.LT.MAX( 1, N-1 ) .AND. .NOT.LQUERY ) THEN
00175          INFO = -7
00176       END IF
00177 *
00178       IF( INFO.EQ.0 ) THEN
00179          IF ( UPPER ) THEN
00180            NB = ILAENV( 1, 'CUNGQL', ' ', N-1, N-1, N-1, -1 )
00181          ELSE
00182            NB = ILAENV( 1, 'CUNGQR', ' ', N-1, N-1, N-1, -1 )
00183          END IF
00184          LWKOPT = MAX( 1, N-1 )*NB
00185          WORK( 1 ) = LWKOPT
00186       END IF
00187 *
00188       IF( INFO.NE.0 ) THEN
00189          CALL XERBLA( 'CUNGTR', -INFO )
00190          RETURN
00191       ELSE IF( LQUERY ) THEN
00192          RETURN
00193       END IF
00194 *
00195 *     Quick return if possible
00196 *
00197       IF( N.EQ.0 ) THEN
00198          WORK( 1 ) = 1
00199          RETURN
00200       END IF
00201 *
00202       IF( UPPER ) THEN
00203 *
00204 *        Q was determined by a call to CHETRD with UPLO = 'U'
00205 *
00206 *        Shift the vectors which define the elementary reflectors one
00207 *        column to the left, and set the last row and column of Q to
00208 *        those of the unit matrix
00209 *
00210          DO 20 J = 1, N - 1
00211             DO 10 I = 1, J - 1
00212                A( I, J ) = A( I, J+1 )
00213    10       CONTINUE
00214             A( N, J ) = ZERO
00215    20    CONTINUE
00216          DO 30 I = 1, N - 1
00217             A( I, N ) = ZERO
00218    30    CONTINUE
00219          A( N, N ) = ONE
00220 *
00221 *        Generate Q(1:n-1,1:n-1)
00222 *
00223          CALL CUNGQL( N-1, N-1, N-1, A, LDA, TAU, WORK, LWORK, IINFO )
00224 *
00225       ELSE
00226 *
00227 *        Q was determined by a call to CHETRD with UPLO = 'L'.
00228 *
00229 *        Shift the vectors which define the elementary reflectors one
00230 *        column to the right, and set the first row and column of Q to
00231 *        those of the unit matrix
00232 *
00233          DO 50 J = N, 2, -1
00234             A( 1, J ) = ZERO
00235             DO 40 I = J + 1, N
00236                A( I, J ) = A( I, J-1 )
00237    40       CONTINUE
00238    50    CONTINUE
00239          A( 1, 1 ) = ONE
00240          DO 60 I = 2, N
00241             A( I, 1 ) = ZERO
00242    60    CONTINUE
00243          IF( N.GT.1 ) THEN
00244 *
00245 *           Generate Q(2:n,2:n)
00246 *
00247             CALL CUNGQR( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
00248      $                   LWORK, IINFO )
00249          END IF
00250       END IF
00251       WORK( 1 ) = LWKOPT
00252       RETURN
00253 *
00254 *     End of CUNGTR
00255 *
00256       END
 All Files Functions