3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CUNGTR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cungtr.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cungtr.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cungtr.f">
21 * SUBROUTINE CUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
23 * .. Scalar Arguments ..
25 * INTEGER INFO, LDA, LWORK, N
27 * .. Array Arguments ..
28 * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
37 *> CUNGTR generates a complex unitary matrix Q which is defined as the
38 *> product of n-1 elementary reflectors of order N, as returned by
41 *> if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
43 *> if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
51 *> UPLO is CHARACTER*1
52 *> = 'U': Upper triangle of A contains elementary reflectors
54 *> = 'L': Lower triangle of A contains elementary reflectors
61 *> The order of the matrix Q. N >= 0.
66 *> A is COMPLEX array, dimension (LDA,N)
67 *> On entry, the vectors which define the elementary reflectors,
68 *> as returned by CHETRD.
69 *> On exit, the N-by-N unitary matrix Q.
75 *> The leading dimension of the array A. LDA >= N.
80 *> TAU is COMPLEX array, dimension (N-1)
81 *> TAU(i) must contain the scalar factor of the elementary
82 *> reflector H(i), as returned by CHETRD.
87 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
88 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
94 *> The dimension of the array WORK. LWORK >= N-1.
95 *> For optimum performance LWORK >= (N-1)*NB, where NB is
96 *> the optimal blocksize.
98 *> If LWORK = -1, then a workspace query is assumed; the routine
99 *> only calculates the optimal size of the WORK array, returns
100 *> this value as the first entry of the WORK array, and no error
101 *> message related to LWORK is issued by XERBLA.
107 *> = 0: successful exit
108 *> < 0: if INFO = -i, the i-th argument had an illegal value
114 *> \author Univ. of Tennessee
115 *> \author Univ. of California Berkeley
116 *> \author Univ. of Colorado Denver
119 *> \date November 2011
121 *> \ingroup complexOTHERcomputational
123 * =====================================================================
124 SUBROUTINE CUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
126 * -- LAPACK computational routine (version 3.4.0) --
127 * -- LAPACK is a software package provided by Univ. of Tennessee, --
128 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
131 * .. Scalar Arguments ..
133 INTEGER INFO, LDA, LWORK, N
135 * .. Array Arguments ..
136 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
139 * =====================================================================
143 PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ),
144 $ ONE = ( 1.0E+0, 0.0E+0 ) )
146 * .. Local Scalars ..
147 LOGICAL LQUERY, UPPER
148 INTEGER I, IINFO, J, LWKOPT, NB
150 * .. External Functions ..
153 EXTERNAL ILAENV, LSAME
155 * .. External Subroutines ..
156 EXTERNAL CUNGQL, CUNGQR, XERBLA
158 * .. Intrinsic Functions ..
161 * .. Executable Statements ..
163 * Test the input arguments
166 LQUERY = ( LWORK.EQ.-1 )
167 UPPER = LSAME( UPLO, 'U' )
168 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
170 ELSE IF( N.LT.0 ) THEN
172 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
174 ELSE IF( LWORK.LT.MAX( 1, N-1 ) .AND. .NOT.LQUERY ) THEN
180 NB = ILAENV( 1, 'CUNGQL', ' ', N-1, N-1, N-1, -1 )
182 NB = ILAENV( 1, 'CUNGQR', ' ', N-1, N-1, N-1, -1 )
184 LWKOPT = MAX( 1, N-1 )*NB
189 CALL XERBLA( 'CUNGTR', -INFO )
191 ELSE IF( LQUERY ) THEN
195 * Quick return if possible
204 * Q was determined by a call to CHETRD with UPLO = 'U'
206 * Shift the vectors which define the elementary reflectors one
207 * column to the left, and set the last row and column of Q to
208 * those of the unit matrix
212 A( I, J ) = A( I, J+1 )
221 * Generate Q(1:n-1,1:n-1)
223 CALL CUNGQL( N-1, N-1, N-1, A, LDA, TAU, WORK, LWORK, IINFO )
227 * Q was determined by a call to CHETRD with UPLO = 'L'.
229 * Shift the vectors which define the elementary reflectors one
230 * column to the right, and set the first row and column of Q to
231 * those of the unit matrix
236 A( I, J ) = A( I, J-1 )
245 * Generate Q(2:n,2:n)
247 CALL CUNGQR( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,