3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZGBBRD + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgbbrd.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgbbrd.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgbbrd.f">
21 * SUBROUTINE ZGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q,
22 * LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO )
24 * .. Scalar Arguments ..
26 * INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC
28 * .. Array Arguments ..
29 * DOUBLE PRECISION D( * ), E( * ), RWORK( * )
30 * COMPLEX*16 AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ),
31 * $ Q( LDQ, * ), WORK( * )
40 *> ZGBBRD reduces a complex general m-by-n band matrix A to real upper
41 *> bidiagonal form B by a unitary transformation: Q**H * A * P = B.
43 *> The routine computes B, and optionally forms Q or P**H, or computes
44 *> Q**H*C for a given matrix C.
52 *> VECT is CHARACTER*1
53 *> Specifies whether or not the matrices Q and P**H are to be
55 *> = 'N': do not form Q or P**H;
56 *> = 'Q': form Q only;
57 *> = 'P': form P**H only;
64 *> The number of rows of the matrix A. M >= 0.
70 *> The number of columns of the matrix A. N >= 0.
76 *> The number of columns of the matrix C. NCC >= 0.
82 *> The number of subdiagonals of the matrix A. KL >= 0.
88 *> The number of superdiagonals of the matrix A. KU >= 0.
93 *> AB is COMPLEX*16 array, dimension (LDAB,N)
94 *> On entry, the m-by-n band matrix A, stored in rows 1 to
95 *> KL+KU+1. The j-th column of A is stored in the j-th column of
96 *> the array AB as follows:
97 *> AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
98 *> On exit, A is overwritten by values generated during the
105 *> The leading dimension of the array A. LDAB >= KL+KU+1.
110 *> D is DOUBLE PRECISION array, dimension (min(M,N))
111 *> The diagonal elements of the bidiagonal matrix B.
116 *> E is DOUBLE PRECISION array, dimension (min(M,N)-1)
117 *> The superdiagonal elements of the bidiagonal matrix B.
122 *> Q is COMPLEX*16 array, dimension (LDQ,M)
123 *> If VECT = 'Q' or 'B', the m-by-m unitary matrix Q.
124 *> If VECT = 'N' or 'P', the array Q is not referenced.
130 *> The leading dimension of the array Q.
131 *> LDQ >= max(1,M) if VECT = 'Q' or 'B'; LDQ >= 1 otherwise.
136 *> PT is COMPLEX*16 array, dimension (LDPT,N)
137 *> If VECT = 'P' or 'B', the n-by-n unitary matrix P'.
138 *> If VECT = 'N' or 'Q', the array PT is not referenced.
144 *> The leading dimension of the array PT.
145 *> LDPT >= max(1,N) if VECT = 'P' or 'B'; LDPT >= 1 otherwise.
150 *> C is COMPLEX*16 array, dimension (LDC,NCC)
151 *> On entry, an m-by-ncc matrix C.
152 *> On exit, C is overwritten by Q**H*C.
153 *> C is not referenced if NCC = 0.
159 *> The leading dimension of the array C.
160 *> LDC >= max(1,M) if NCC > 0; LDC >= 1 if NCC = 0.
165 *> WORK is COMPLEX*16 array, dimension (max(M,N))
170 *> RWORK is DOUBLE PRECISION array, dimension (max(M,N))
176 *> = 0: successful exit.
177 *> < 0: if INFO = -i, the i-th argument had an illegal value.
183 *> \author Univ. of Tennessee
184 *> \author Univ. of California Berkeley
185 *> \author Univ. of Colorado Denver
188 *> \date November 2011
190 *> \ingroup complex16GBcomputational
192 * =====================================================================
193 SUBROUTINE ZGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q,
194 $ LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO )
196 * -- LAPACK computational routine (version 3.4.0) --
197 * -- LAPACK is a software package provided by Univ. of Tennessee, --
198 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
201 * .. Scalar Arguments ..
203 INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC
205 * .. Array Arguments ..
206 DOUBLE PRECISION D( * ), E( * ), RWORK( * )
207 COMPLEX*16 AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ),
208 $ Q( LDQ, * ), WORK( * )
211 * =====================================================================
214 DOUBLE PRECISION ZERO
215 PARAMETER ( ZERO = 0.0D+0 )
216 COMPLEX*16 CZERO, CONE
217 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),
218 $ CONE = ( 1.0D+0, 0.0D+0 ) )
220 * .. Local Scalars ..
221 LOGICAL WANTB, WANTC, WANTPT, WANTQ
222 INTEGER I, INCA, J, J1, J2, KB, KB1, KK, KLM, KLU1,
223 $ KUN, L, MINMN, ML, ML0, MU, MU0, NR, NRT
224 DOUBLE PRECISION ABST, RC
225 COMPLEX*16 RA, RB, RS, T
227 * .. External Subroutines ..
228 EXTERNAL XERBLA, ZLARGV, ZLARTG, ZLARTV, ZLASET, ZROT,
231 * .. Intrinsic Functions ..
232 INTRINSIC ABS, DCONJG, MAX, MIN
234 * .. External Functions ..
238 * .. Executable Statements ..
240 * Test the input parameters
242 WANTB = LSAME( VECT, 'B' )
243 WANTQ = LSAME( VECT, 'Q' ) .OR. WANTB
244 WANTPT = LSAME( VECT, 'P' ) .OR. WANTB
248 IF( .NOT.WANTQ .AND. .NOT.WANTPT .AND. .NOT.LSAME( VECT, 'N' ) )
251 ELSE IF( M.LT.0 ) THEN
253 ELSE IF( N.LT.0 ) THEN
255 ELSE IF( NCC.LT.0 ) THEN
257 ELSE IF( KL.LT.0 ) THEN
259 ELSE IF( KU.LT.0 ) THEN
261 ELSE IF( LDAB.LT.KLU1 ) THEN
263 ELSE IF( LDQ.LT.1 .OR. WANTQ .AND. LDQ.LT.MAX( 1, M ) ) THEN
265 ELSE IF( LDPT.LT.1 .OR. WANTPT .AND. LDPT.LT.MAX( 1, N ) ) THEN
267 ELSE IF( LDC.LT.1 .OR. WANTC .AND. LDC.LT.MAX( 1, M ) ) THEN
271 CALL XERBLA( 'ZGBBRD', -INFO )
275 * Initialize Q and P**H to the unit matrix, if needed
278 $ CALL ZLASET( 'Full', M, M, CZERO, CONE, Q, LDQ )
280 $ CALL ZLASET( 'Full', N, N, CZERO, CONE, PT, LDPT )
282 * Quick return if possible.
284 IF( M.EQ.0 .OR. N.EQ.0 )
289 IF( KL+KU.GT.1 ) THEN
291 * Reduce to upper bidiagonal form if KU > 0; if KU = 0, reduce
292 * first to lower bidiagonal form and then transform to upper
303 * Wherever possible, plane rotations are generated and applied in
304 * vector operations of length NR over the index set J1:J2:KLU1.
306 * The complex sines of the plane rotations are stored in WORK,
307 * and the real cosines in RWORK.
320 * Reduce i-th column and i-th row of matrix to bidiagonal form
328 * generate plane rotations to annihilate nonzero elements
329 * which have been created below the band
332 $ CALL ZLARGV( NR, AB( KLU1, J1-KLM-1 ), INCA,
333 $ WORK( J1 ), KB1, RWORK( J1 ), KB1 )
335 * apply plane rotations from the left
338 IF( J2-KLM+L-1.GT.N ) THEN
344 $ CALL ZLARTV( NRT, AB( KLU1-L, J1-KLM+L-1 ), INCA,
345 $ AB( KLU1-L+1, J1-KLM+L-1 ), INCA,
346 $ RWORK( J1 ), WORK( J1 ), KB1 )
350 IF( ML.LE.M-I+1 ) THEN
352 * generate plane rotation to annihilate a(i+ml-1,i)
353 * within the band, and apply rotation from the left
355 CALL ZLARTG( AB( KU+ML-1, I ), AB( KU+ML, I ),
356 $ RWORK( I+ML-1 ), WORK( I+ML-1 ), RA )
357 AB( KU+ML-1, I ) = RA
359 $ CALL ZROT( MIN( KU+ML-2, N-I ),
360 $ AB( KU+ML-2, I+1 ), LDAB-1,
361 $ AB( KU+ML-1, I+1 ), LDAB-1,
362 $ RWORK( I+ML-1 ), WORK( I+ML-1 ) )
370 * accumulate product of plane rotations in Q
372 DO 20 J = J1, J2, KB1
373 CALL ZROT( M, Q( 1, J-1 ), 1, Q( 1, J ), 1,
374 $ RWORK( J ), DCONJG( WORK( J ) ) )
380 * apply plane rotations to C
382 DO 30 J = J1, J2, KB1
383 CALL ZROT( NCC, C( J-1, 1 ), LDC, C( J, 1 ), LDC,
384 $ RWORK( J ), WORK( J ) )
388 IF( J2+KUN.GT.N ) THEN
390 * adjust J2 to keep within the bounds of the matrix
396 DO 40 J = J1, J2, KB1
398 * create nonzero element a(j-1,j+ku) above the band
399 * and store it in WORK(n+1:2*n)
401 WORK( J+KUN ) = WORK( J )*AB( 1, J+KUN )
402 AB( 1, J+KUN ) = RWORK( J )*AB( 1, J+KUN )
405 * generate plane rotations to annihilate nonzero elements
406 * which have been generated above the band
409 $ CALL ZLARGV( NR, AB( 1, J1+KUN-1 ), INCA,
410 $ WORK( J1+KUN ), KB1, RWORK( J1+KUN ),
413 * apply plane rotations from the right
416 IF( J2+L-1.GT.M ) THEN
422 $ CALL ZLARTV( NRT, AB( L+1, J1+KUN-1 ), INCA,
423 $ AB( L, J1+KUN ), INCA,
424 $ RWORK( J1+KUN ), WORK( J1+KUN ), KB1 )
427 IF( ML.EQ.ML0 .AND. MU.GT.MU0 ) THEN
428 IF( MU.LE.N-I+1 ) THEN
430 * generate plane rotation to annihilate a(i,i+mu-1)
431 * within the band, and apply rotation from the right
433 CALL ZLARTG( AB( KU-MU+3, I+MU-2 ),
434 $ AB( KU-MU+2, I+MU-1 ),
435 $ RWORK( I+MU-1 ), WORK( I+MU-1 ), RA )
436 AB( KU-MU+3, I+MU-2 ) = RA
437 CALL ZROT( MIN( KL+MU-2, M-I ),
438 $ AB( KU-MU+4, I+MU-2 ), 1,
439 $ AB( KU-MU+3, I+MU-1 ), 1,
440 $ RWORK( I+MU-1 ), WORK( I+MU-1 ) )
448 * accumulate product of plane rotations in P**H
450 DO 60 J = J1, J2, KB1
451 CALL ZROT( N, PT( J+KUN-1, 1 ), LDPT,
452 $ PT( J+KUN, 1 ), LDPT, RWORK( J+KUN ),
453 $ DCONJG( WORK( J+KUN ) ) )
457 IF( J2+KB.GT.M ) THEN
459 * adjust J2 to keep within the bounds of the matrix
465 DO 70 J = J1, J2, KB1
467 * create nonzero element a(j+kl+ku,j+ku-1) below the
468 * band and store it in WORK(1:n)
470 WORK( J+KB ) = WORK( J+KUN )*AB( KLU1, J+KUN )
471 AB( KLU1, J+KUN ) = RWORK( J+KUN )*AB( KLU1, J+KUN )
483 IF( KU.EQ.0 .AND. KL.GT.0 ) THEN
485 * A has been reduced to complex lower bidiagonal form
487 * Transform lower bidiagonal form to upper bidiagonal by applying
488 * plane rotations from the left, overwriting superdiagonal
489 * elements on subdiagonal elements
491 DO 100 I = 1, MIN( M-1, N )
492 CALL ZLARTG( AB( 1, I ), AB( 2, I ), RC, RS, RA )
495 AB( 2, I ) = RS*AB( 1, I+1 )
496 AB( 1, I+1 ) = RC*AB( 1, I+1 )
499 $ CALL ZROT( M, Q( 1, I ), 1, Q( 1, I+1 ), 1, RC,
502 $ CALL ZROT( NCC, C( I, 1 ), LDC, C( I+1, 1 ), LDC, RC,
507 * A has been reduced to complex upper bidiagonal form or is
510 IF( KU.GT.0 .AND. M.LT.N ) THEN
512 * Annihilate a(m,m+1) by applying plane rotations from the
517 CALL ZLARTG( AB( KU+1, I ), RB, RC, RS, RA )
520 RB = -DCONJG( RS )*AB( KU, I )
521 AB( KU, I ) = RC*AB( KU, I )
524 $ CALL ZROT( N, PT( I, 1 ), LDPT, PT( M+1, 1 ), LDPT,
530 * Make diagonal and superdiagonal elements real, storing them in D
537 IF( ABST.NE.ZERO ) THEN
543 $ CALL ZSCAL( M, T, Q( 1, I ), 1 )
545 $ CALL ZSCAL( NCC, DCONJG( T ), C( I, 1 ), LDC )
546 IF( I.LT.MINMN ) THEN
547 IF( KU.EQ.0 .AND. KL.EQ.0 ) THEN
552 T = AB( 2, I )*DCONJG( T )
554 T = AB( KU, I+1 )*DCONJG( T )
558 IF( ABST.NE.ZERO ) THEN
564 $ CALL ZSCAL( N, T, PT( I+1, 1 ), LDPT )
565 T = AB( KU+1, I+1 )*DCONJG( T )