3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CUNGBR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cungbr.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cungbr.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cungbr.f">
21 * SUBROUTINE CUNGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
23 * .. Scalar Arguments ..
25 * INTEGER INFO, K, LDA, LWORK, M, N
27 * .. Array Arguments ..
28 * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
37 *> CUNGBR generates one of the complex unitary matrices Q or P**H
38 *> determined by CGEBRD when reducing a complex matrix A to bidiagonal
39 *> form: A = Q * B * P**H. Q and P**H are defined as products of
40 *> elementary reflectors H(i) or G(i) respectively.
42 *> If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
44 *> if m >= k, Q = H(1) H(2) . . . H(k) and CUNGBR returns the first n
45 *> columns of Q, where m >= n >= k;
46 *> if m < k, Q = H(1) H(2) . . . H(m-1) and CUNGBR returns Q as an
49 *> If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**H
51 *> if k < n, P**H = G(k) . . . G(2) G(1) and CUNGBR returns the first m
52 *> rows of P**H, where n >= m >= k;
53 *> if k >= n, P**H = G(n-1) . . . G(2) G(1) and CUNGBR returns P**H as
62 *> VECT is CHARACTER*1
63 *> Specifies whether the matrix Q or the matrix P**H is
64 *> required, as defined in the transformation applied by CGEBRD:
66 *> = 'P': generate P**H.
72 *> The number of rows of the matrix Q or P**H to be returned.
79 *> The number of columns of the matrix Q or P**H to be returned.
81 *> If VECT = 'Q', M >= N >= min(M,K);
82 *> if VECT = 'P', N >= M >= min(N,K).
88 *> If VECT = 'Q', the number of columns in the original M-by-K
89 *> matrix reduced by CGEBRD.
90 *> If VECT = 'P', the number of rows in the original K-by-N
91 *> matrix reduced by CGEBRD.
97 *> A is COMPLEX array, dimension (LDA,N)
98 *> On entry, the vectors which define the elementary reflectors,
99 *> as returned by CGEBRD.
100 *> On exit, the M-by-N matrix Q or P**H.
106 *> The leading dimension of the array A. LDA >= M.
111 *> TAU is COMPLEX array, dimension
112 *> (min(M,K)) if VECT = 'Q'
113 *> (min(N,K)) if VECT = 'P'
114 *> TAU(i) must contain the scalar factor of the elementary
115 *> reflector H(i) or G(i), which determines Q or P**H, as
116 *> returned by CGEBRD in its array argument TAUQ or TAUP.
121 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
122 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
128 *> The dimension of the array WORK. LWORK >= max(1,min(M,N)).
129 *> For optimum performance LWORK >= min(M,N)*NB, where NB
130 *> is the optimal blocksize.
132 *> If LWORK = -1, then a workspace query is assumed; the routine
133 *> only calculates the optimal size of the WORK array, returns
134 *> this value as the first entry of the WORK array, and no error
135 *> message related to LWORK is issued by XERBLA.
141 *> = 0: successful exit
142 *> < 0: if INFO = -i, the i-th argument had an illegal value
148 *> \author Univ. of Tennessee
149 *> \author Univ. of California Berkeley
150 *> \author Univ. of Colorado Denver
155 *> \ingroup complexGBcomputational
157 * =====================================================================
158 SUBROUTINE CUNGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
160 * -- LAPACK computational routine (version 3.4.1) --
161 * -- LAPACK is a software package provided by Univ. of Tennessee, --
162 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
165 * .. Scalar Arguments ..
167 INTEGER INFO, K, LDA, LWORK, M, N
169 * .. Array Arguments ..
170 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
173 * =====================================================================
177 PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ),
178 $ ONE = ( 1.0E+0, 0.0E+0 ) )
180 * .. Local Scalars ..
181 LOGICAL LQUERY, WANTQ
182 INTEGER I, IINFO, J, LWKOPT, MN
184 * .. External Functions ..
187 EXTERNAL ILAENV, LSAME
189 * .. External Subroutines ..
190 EXTERNAL CUNGLQ, CUNGQR, XERBLA
192 * .. Intrinsic Functions ..
195 * .. Executable Statements ..
197 * Test the input arguments
200 WANTQ = LSAME( VECT, 'Q' )
202 LQUERY = ( LWORK.EQ.-1 )
203 IF( .NOT.WANTQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN
205 ELSE IF( M.LT.0 ) THEN
207 ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M,
208 $ K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT.
209 $ MIN( N, K ) ) ) ) THEN
211 ELSE IF( K.LT.0 ) THEN
213 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
215 ELSE IF( LWORK.LT.MAX( 1, MN ) .AND. .NOT.LQUERY ) THEN
223 CALL CUNGQR( M, N, K, A, LDA, TAU, WORK, -1, IINFO )
226 CALL CUNGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
232 CALL CUNGLQ( M, N, K, A, LDA, TAU, WORK, -1, IINFO )
235 CALL CUNGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
241 LWKOPT = MAX (LWKOPT, MN)
245 CALL XERBLA( 'CUNGBR', -INFO )
247 ELSE IF( LQUERY ) THEN
252 * Quick return if possible
254 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
261 * Form Q, determined by a call to CGEBRD to reduce an m-by-k
266 * If m >= k, assume m >= n >= k
268 CALL CUNGQR( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
272 * If m < k, assume m = n
274 * Shift the vectors which define the elementary reflectors one
275 * column to the right, and set the first row and column of Q
276 * to those of the unit matrix
281 A( I, J ) = A( I, J-1 )
292 CALL CUNGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
298 * Form P**H, determined by a call to CGEBRD to reduce a k-by-n
303 * If k < n, assume k <= m <= n
305 CALL CUNGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
309 * If k >= n, assume m = n
311 * Shift the vectors which define the elementary reflectors one
312 * row downward, and set the first row and column of P**H to
313 * those of the unit matrix
320 DO 50 I = J - 1, 2, -1
321 A( I, J ) = A( I-1, J )
329 CALL CUNGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,