LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine cungtr ( character  UPLO,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
complex, dimension( * )  TAU,
complex, dimension( * )  WORK,
integer  LWORK,
integer  INFO 
)

CUNGTR

Download CUNGTR + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CUNGTR generates a complex unitary matrix Q which is defined as the
 product of n-1 elementary reflectors of order N, as returned by
 CHETRD:

 if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),

 if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          = 'U': Upper triangle of A contains elementary reflectors
                 from CHETRD;
          = 'L': Lower triangle of A contains elementary reflectors
                 from CHETRD.
[in]N
          N is INTEGER
          The order of the matrix Q. N >= 0.
[in,out]A
          A is COMPLEX array, dimension (LDA,N)
          On entry, the vectors which define the elementary reflectors,
          as returned by CHETRD.
          On exit, the N-by-N unitary matrix Q.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A. LDA >= N.
[in]TAU
          TAU is COMPLEX array, dimension (N-1)
          TAU(i) must contain the scalar factor of the elementary
          reflector H(i), as returned by CHETRD.
[out]WORK
          WORK is COMPLEX array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK. LWORK >= N-1.
          For optimum performance LWORK >= (N-1)*NB, where NB is
          the optimal blocksize.

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal size of the WORK array, returns
          this value as the first entry of the WORK array, and no error
          message related to LWORK is issued by XERBLA.
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 125 of file cungtr.f.

125 *
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..--
129 * November 2011
130 *
131 * .. Scalar Arguments ..
132  CHARACTER uplo
133  INTEGER info, lda, lwork, n
134 * ..
135 * .. Array Arguments ..
136  COMPLEX a( lda, * ), tau( * ), work( * )
137 * ..
138 *
139 * =====================================================================
140 *
141 * .. Parameters ..
142  COMPLEX zero, one
143  parameter ( zero = ( 0.0e+0, 0.0e+0 ),
144  $ one = ( 1.0e+0, 0.0e+0 ) )
145 * ..
146 * .. Local Scalars ..
147  LOGICAL lquery, upper
148  INTEGER i, iinfo, j, lwkopt, nb
149 * ..
150 * .. External Functions ..
151  LOGICAL lsame
152  INTEGER ilaenv
153  EXTERNAL ilaenv, lsame
154 * ..
155 * .. External Subroutines ..
156  EXTERNAL cungql, cungqr, xerbla
157 * ..
158 * .. Intrinsic Functions ..
159  INTRINSIC max
160 * ..
161 * .. Executable Statements ..
162 *
163 * Test the input arguments
164 *
165  info = 0
166  lquery = ( lwork.EQ.-1 )
167  upper = lsame( uplo, 'U' )
168  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
169  info = -1
170  ELSE IF( n.LT.0 ) THEN
171  info = -2
172  ELSE IF( lda.LT.max( 1, n ) ) THEN
173  info = -4
174  ELSE IF( lwork.LT.max( 1, n-1 ) .AND. .NOT.lquery ) THEN
175  info = -7
176  END IF
177 *
178  IF( info.EQ.0 ) THEN
179  IF ( upper ) THEN
180  nb = ilaenv( 1, 'CUNGQL', ' ', n-1, n-1, n-1, -1 )
181  ELSE
182  nb = ilaenv( 1, 'CUNGQR', ' ', n-1, n-1, n-1, -1 )
183  END IF
184  lwkopt = max( 1, n-1 )*nb
185  work( 1 ) = lwkopt
186  END IF
187 *
188  IF( info.NE.0 ) THEN
189  CALL xerbla( 'CUNGTR', -info )
190  RETURN
191  ELSE IF( lquery ) THEN
192  RETURN
193  END IF
194 *
195 * Quick return if possible
196 *
197  IF( n.EQ.0 ) THEN
198  work( 1 ) = 1
199  RETURN
200  END IF
201 *
202  IF( upper ) THEN
203 *
204 * Q was determined by a call to CHETRD with UPLO = 'U'
205 *
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
209 *
210  DO 20 j = 1, n - 1
211  DO 10 i = 1, j - 1
212  a( i, j ) = a( i, j+1 )
213  10 CONTINUE
214  a( n, j ) = zero
215  20 CONTINUE
216  DO 30 i = 1, n - 1
217  a( i, n ) = zero
218  30 CONTINUE
219  a( n, n ) = one
220 *
221 * Generate Q(1:n-1,1:n-1)
222 *
223  CALL cungql( n-1, n-1, n-1, a, lda, tau, work, lwork, iinfo )
224 *
225  ELSE
226 *
227 * Q was determined by a call to CHETRD with UPLO = 'L'.
228 *
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
232 *
233  DO 50 j = n, 2, -1
234  a( 1, j ) = zero
235  DO 40 i = j + 1, n
236  a( i, j ) = a( i, j-1 )
237  40 CONTINUE
238  50 CONTINUE
239  a( 1, 1 ) = one
240  DO 60 i = 2, n
241  a( i, 1 ) = zero
242  60 CONTINUE
243  IF( n.GT.1 ) THEN
244 *
245 * Generate Q(2:n,2:n)
246 *
247  CALL cungqr( n-1, n-1, n-1, a( 2, 2 ), lda, tau, work,
248  $ lwork, iinfo )
249  END IF
250  END IF
251  work( 1 ) = lwkopt
252  RETURN
253 *
254 * End of CUNGTR
255 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
Definition: tstiee.f:83
subroutine cungql(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQL
Definition: cungql.f:130
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR
Definition: cungqr.f:130
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: