![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b ZGBBRD 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download ZGBBRD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgbbrd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgbbrd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgbbrd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE ZGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q, 00022 * LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER VECT 00026 * INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC 00027 * .. 00028 * .. Array Arguments .. 00029 * DOUBLE PRECISION D( * ), E( * ), RWORK( * ) 00030 * COMPLEX*16 AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ), 00031 * $ Q( LDQ, * ), WORK( * ) 00032 * .. 00033 * 00034 * 00035 *> \par Purpose: 00036 * ============= 00037 *> 00038 *> \verbatim 00039 *> 00040 *> ZGBBRD reduces a complex general m-by-n band matrix A to real upper 00041 *> bidiagonal form B by a unitary transformation: Q**H * A * P = B. 00042 *> 00043 *> The routine computes B, and optionally forms Q or P**H, or computes 00044 *> Q**H*C for a given matrix C. 00045 *> \endverbatim 00046 * 00047 * Arguments: 00048 * ========== 00049 * 00050 *> \param[in] VECT 00051 *> \verbatim 00052 *> VECT is CHARACTER*1 00053 *> Specifies whether or not the matrices Q and P**H are to be 00054 *> formed. 00055 *> = 'N': do not form Q or P**H; 00056 *> = 'Q': form Q only; 00057 *> = 'P': form P**H only; 00058 *> = 'B': form both. 00059 *> \endverbatim 00060 *> 00061 *> \param[in] M 00062 *> \verbatim 00063 *> M is INTEGER 00064 *> The number of rows of the matrix A. M >= 0. 00065 *> \endverbatim 00066 *> 00067 *> \param[in] N 00068 *> \verbatim 00069 *> N is INTEGER 00070 *> The number of columns of the matrix A. N >= 0. 00071 *> \endverbatim 00072 *> 00073 *> \param[in] NCC 00074 *> \verbatim 00075 *> NCC is INTEGER 00076 *> The number of columns of the matrix C. NCC >= 0. 00077 *> \endverbatim 00078 *> 00079 *> \param[in] KL 00080 *> \verbatim 00081 *> KL is INTEGER 00082 *> The number of subdiagonals of the matrix A. KL >= 0. 00083 *> \endverbatim 00084 *> 00085 *> \param[in] KU 00086 *> \verbatim 00087 *> KU is INTEGER 00088 *> The number of superdiagonals of the matrix A. KU >= 0. 00089 *> \endverbatim 00090 *> 00091 *> \param[in,out] AB 00092 *> \verbatim 00093 *> AB is COMPLEX*16 array, dimension (LDAB,N) 00094 *> On entry, the m-by-n band matrix A, stored in rows 1 to 00095 *> KL+KU+1. The j-th column of A is stored in the j-th column of 00096 *> the array AB as follows: 00097 *> AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl). 00098 *> On exit, A is overwritten by values generated during the 00099 *> reduction. 00100 *> \endverbatim 00101 *> 00102 *> \param[in] LDAB 00103 *> \verbatim 00104 *> LDAB is INTEGER 00105 *> The leading dimension of the array A. LDAB >= KL+KU+1. 00106 *> \endverbatim 00107 *> 00108 *> \param[out] D 00109 *> \verbatim 00110 *> D is DOUBLE PRECISION array, dimension (min(M,N)) 00111 *> The diagonal elements of the bidiagonal matrix B. 00112 *> \endverbatim 00113 *> 00114 *> \param[out] E 00115 *> \verbatim 00116 *> E is DOUBLE PRECISION array, dimension (min(M,N)-1) 00117 *> The superdiagonal elements of the bidiagonal matrix B. 00118 *> \endverbatim 00119 *> 00120 *> \param[out] Q 00121 *> \verbatim 00122 *> Q is COMPLEX*16 array, dimension (LDQ,M) 00123 *> If VECT = 'Q' or 'B', the m-by-m unitary matrix Q. 00124 *> If VECT = 'N' or 'P', the array Q is not referenced. 00125 *> \endverbatim 00126 *> 00127 *> \param[in] LDQ 00128 *> \verbatim 00129 *> LDQ is INTEGER 00130 *> The leading dimension of the array Q. 00131 *> LDQ >= max(1,M) if VECT = 'Q' or 'B'; LDQ >= 1 otherwise. 00132 *> \endverbatim 00133 *> 00134 *> \param[out] PT 00135 *> \verbatim 00136 *> PT is COMPLEX*16 array, dimension (LDPT,N) 00137 *> If VECT = 'P' or 'B', the n-by-n unitary matrix P'. 00138 *> If VECT = 'N' or 'Q', the array PT is not referenced. 00139 *> \endverbatim 00140 *> 00141 *> \param[in] LDPT 00142 *> \verbatim 00143 *> LDPT is INTEGER 00144 *> The leading dimension of the array PT. 00145 *> LDPT >= max(1,N) if VECT = 'P' or 'B'; LDPT >= 1 otherwise. 00146 *> \endverbatim 00147 *> 00148 *> \param[in,out] C 00149 *> \verbatim 00150 *> C is COMPLEX*16 array, dimension (LDC,NCC) 00151 *> On entry, an m-by-ncc matrix C. 00152 *> On exit, C is overwritten by Q**H*C. 00153 *> C is not referenced if NCC = 0. 00154 *> \endverbatim 00155 *> 00156 *> \param[in] LDC 00157 *> \verbatim 00158 *> LDC is INTEGER 00159 *> The leading dimension of the array C. 00160 *> LDC >= max(1,M) if NCC > 0; LDC >= 1 if NCC = 0. 00161 *> \endverbatim 00162 *> 00163 *> \param[out] WORK 00164 *> \verbatim 00165 *> WORK is COMPLEX*16 array, dimension (max(M,N)) 00166 *> \endverbatim 00167 *> 00168 *> \param[out] RWORK 00169 *> \verbatim 00170 *> RWORK is DOUBLE PRECISION array, dimension (max(M,N)) 00171 *> \endverbatim 00172 *> 00173 *> \param[out] INFO 00174 *> \verbatim 00175 *> INFO is INTEGER 00176 *> = 0: successful exit. 00177 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00178 *> \endverbatim 00179 * 00180 * Authors: 00181 * ======== 00182 * 00183 *> \author Univ. of Tennessee 00184 *> \author Univ. of California Berkeley 00185 *> \author Univ. of Colorado Denver 00186 *> \author NAG Ltd. 00187 * 00188 *> \date November 2011 00189 * 00190 *> \ingroup complex16GBcomputational 00191 * 00192 * ===================================================================== 00193 SUBROUTINE ZGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q, 00194 $ LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO ) 00195 * 00196 * -- LAPACK computational routine (version 3.4.0) -- 00197 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00198 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00199 * November 2011 00200 * 00201 * .. Scalar Arguments .. 00202 CHARACTER VECT 00203 INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC 00204 * .. 00205 * .. Array Arguments .. 00206 DOUBLE PRECISION D( * ), E( * ), RWORK( * ) 00207 COMPLEX*16 AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ), 00208 $ Q( LDQ, * ), WORK( * ) 00209 * .. 00210 * 00211 * ===================================================================== 00212 * 00213 * .. Parameters .. 00214 DOUBLE PRECISION ZERO 00215 PARAMETER ( ZERO = 0.0D+0 ) 00216 COMPLEX*16 CZERO, CONE 00217 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ), 00218 $ CONE = ( 1.0D+0, 0.0D+0 ) ) 00219 * .. 00220 * .. Local Scalars .. 00221 LOGICAL WANTB, WANTC, WANTPT, WANTQ 00222 INTEGER I, INCA, J, J1, J2, KB, KB1, KK, KLM, KLU1, 00223 $ KUN, L, MINMN, ML, ML0, MU, MU0, NR, NRT 00224 DOUBLE PRECISION ABST, RC 00225 COMPLEX*16 RA, RB, RS, T 00226 * .. 00227 * .. External Subroutines .. 00228 EXTERNAL XERBLA, ZLARGV, ZLARTG, ZLARTV, ZLASET, ZROT, 00229 $ ZSCAL 00230 * .. 00231 * .. Intrinsic Functions .. 00232 INTRINSIC ABS, DCONJG, MAX, MIN 00233 * .. 00234 * .. External Functions .. 00235 LOGICAL LSAME 00236 EXTERNAL LSAME 00237 * .. 00238 * .. Executable Statements .. 00239 * 00240 * Test the input parameters 00241 * 00242 WANTB = LSAME( VECT, 'B' ) 00243 WANTQ = LSAME( VECT, 'Q' ) .OR. WANTB 00244 WANTPT = LSAME( VECT, 'P' ) .OR. WANTB 00245 WANTC = NCC.GT.0 00246 KLU1 = KL + KU + 1 00247 INFO = 0 00248 IF( .NOT.WANTQ .AND. .NOT.WANTPT .AND. .NOT.LSAME( VECT, 'N' ) ) 00249 $ THEN 00250 INFO = -1 00251 ELSE IF( M.LT.0 ) THEN 00252 INFO = -2 00253 ELSE IF( N.LT.0 ) THEN 00254 INFO = -3 00255 ELSE IF( NCC.LT.0 ) THEN 00256 INFO = -4 00257 ELSE IF( KL.LT.0 ) THEN 00258 INFO = -5 00259 ELSE IF( KU.LT.0 ) THEN 00260 INFO = -6 00261 ELSE IF( LDAB.LT.KLU1 ) THEN 00262 INFO = -8 00263 ELSE IF( LDQ.LT.1 .OR. WANTQ .AND. LDQ.LT.MAX( 1, M ) ) THEN 00264 INFO = -12 00265 ELSE IF( LDPT.LT.1 .OR. WANTPT .AND. LDPT.LT.MAX( 1, N ) ) THEN 00266 INFO = -14 00267 ELSE IF( LDC.LT.1 .OR. WANTC .AND. LDC.LT.MAX( 1, M ) ) THEN 00268 INFO = -16 00269 END IF 00270 IF( INFO.NE.0 ) THEN 00271 CALL XERBLA( 'ZGBBRD', -INFO ) 00272 RETURN 00273 END IF 00274 * 00275 * Initialize Q and P**H to the unit matrix, if needed 00276 * 00277 IF( WANTQ ) 00278 $ CALL ZLASET( 'Full', M, M, CZERO, CONE, Q, LDQ ) 00279 IF( WANTPT ) 00280 $ CALL ZLASET( 'Full', N, N, CZERO, CONE, PT, LDPT ) 00281 * 00282 * Quick return if possible. 00283 * 00284 IF( M.EQ.0 .OR. N.EQ.0 ) 00285 $ RETURN 00286 * 00287 MINMN = MIN( M, N ) 00288 * 00289 IF( KL+KU.GT.1 ) THEN 00290 * 00291 * Reduce to upper bidiagonal form if KU > 0; if KU = 0, reduce 00292 * first to lower bidiagonal form and then transform to upper 00293 * bidiagonal 00294 * 00295 IF( KU.GT.0 ) THEN 00296 ML0 = 1 00297 MU0 = 2 00298 ELSE 00299 ML0 = 2 00300 MU0 = 1 00301 END IF 00302 * 00303 * Wherever possible, plane rotations are generated and applied in 00304 * vector operations of length NR over the index set J1:J2:KLU1. 00305 * 00306 * The complex sines of the plane rotations are stored in WORK, 00307 * and the real cosines in RWORK. 00308 * 00309 KLM = MIN( M-1, KL ) 00310 KUN = MIN( N-1, KU ) 00311 KB = KLM + KUN 00312 KB1 = KB + 1 00313 INCA = KB1*LDAB 00314 NR = 0 00315 J1 = KLM + 2 00316 J2 = 1 - KUN 00317 * 00318 DO 90 I = 1, MINMN 00319 * 00320 * Reduce i-th column and i-th row of matrix to bidiagonal form 00321 * 00322 ML = KLM + 1 00323 MU = KUN + 1 00324 DO 80 KK = 1, KB 00325 J1 = J1 + KB 00326 J2 = J2 + KB 00327 * 00328 * generate plane rotations to annihilate nonzero elements 00329 * which have been created below the band 00330 * 00331 IF( NR.GT.0 ) 00332 $ CALL ZLARGV( NR, AB( KLU1, J1-KLM-1 ), INCA, 00333 $ WORK( J1 ), KB1, RWORK( J1 ), KB1 ) 00334 * 00335 * apply plane rotations from the left 00336 * 00337 DO 10 L = 1, KB 00338 IF( J2-KLM+L-1.GT.N ) THEN 00339 NRT = NR - 1 00340 ELSE 00341 NRT = NR 00342 END IF 00343 IF( NRT.GT.0 ) 00344 $ CALL ZLARTV( NRT, AB( KLU1-L, J1-KLM+L-1 ), INCA, 00345 $ AB( KLU1-L+1, J1-KLM+L-1 ), INCA, 00346 $ RWORK( J1 ), WORK( J1 ), KB1 ) 00347 10 CONTINUE 00348 * 00349 IF( ML.GT.ML0 ) THEN 00350 IF( ML.LE.M-I+1 ) THEN 00351 * 00352 * generate plane rotation to annihilate a(i+ml-1,i) 00353 * within the band, and apply rotation from the left 00354 * 00355 CALL ZLARTG( AB( KU+ML-1, I ), AB( KU+ML, I ), 00356 $ RWORK( I+ML-1 ), WORK( I+ML-1 ), RA ) 00357 AB( KU+ML-1, I ) = RA 00358 IF( I.LT.N ) 00359 $ CALL ZROT( MIN( KU+ML-2, N-I ), 00360 $ AB( KU+ML-2, I+1 ), LDAB-1, 00361 $ AB( KU+ML-1, I+1 ), LDAB-1, 00362 $ RWORK( I+ML-1 ), WORK( I+ML-1 ) ) 00363 END IF 00364 NR = NR + 1 00365 J1 = J1 - KB1 00366 END IF 00367 * 00368 IF( WANTQ ) THEN 00369 * 00370 * accumulate product of plane rotations in Q 00371 * 00372 DO 20 J = J1, J2, KB1 00373 CALL ZROT( M, Q( 1, J-1 ), 1, Q( 1, J ), 1, 00374 $ RWORK( J ), DCONJG( WORK( J ) ) ) 00375 20 CONTINUE 00376 END IF 00377 * 00378 IF( WANTC ) THEN 00379 * 00380 * apply plane rotations to C 00381 * 00382 DO 30 J = J1, J2, KB1 00383 CALL ZROT( NCC, C( J-1, 1 ), LDC, C( J, 1 ), LDC, 00384 $ RWORK( J ), WORK( J ) ) 00385 30 CONTINUE 00386 END IF 00387 * 00388 IF( J2+KUN.GT.N ) THEN 00389 * 00390 * adjust J2 to keep within the bounds of the matrix 00391 * 00392 NR = NR - 1 00393 J2 = J2 - KB1 00394 END IF 00395 * 00396 DO 40 J = J1, J2, KB1 00397 * 00398 * create nonzero element a(j-1,j+ku) above the band 00399 * and store it in WORK(n+1:2*n) 00400 * 00401 WORK( J+KUN ) = WORK( J )*AB( 1, J+KUN ) 00402 AB( 1, J+KUN ) = RWORK( J )*AB( 1, J+KUN ) 00403 40 CONTINUE 00404 * 00405 * generate plane rotations to annihilate nonzero elements 00406 * which have been generated above the band 00407 * 00408 IF( NR.GT.0 ) 00409 $ CALL ZLARGV( NR, AB( 1, J1+KUN-1 ), INCA, 00410 $ WORK( J1+KUN ), KB1, RWORK( J1+KUN ), 00411 $ KB1 ) 00412 * 00413 * apply plane rotations from the right 00414 * 00415 DO 50 L = 1, KB 00416 IF( J2+L-1.GT.M ) THEN 00417 NRT = NR - 1 00418 ELSE 00419 NRT = NR 00420 END IF 00421 IF( NRT.GT.0 ) 00422 $ CALL ZLARTV( NRT, AB( L+1, J1+KUN-1 ), INCA, 00423 $ AB( L, J1+KUN ), INCA, 00424 $ RWORK( J1+KUN ), WORK( J1+KUN ), KB1 ) 00425 50 CONTINUE 00426 * 00427 IF( ML.EQ.ML0 .AND. MU.GT.MU0 ) THEN 00428 IF( MU.LE.N-I+1 ) THEN 00429 * 00430 * generate plane rotation to annihilate a(i,i+mu-1) 00431 * within the band, and apply rotation from the right 00432 * 00433 CALL ZLARTG( AB( KU-MU+3, I+MU-2 ), 00434 $ AB( KU-MU+2, I+MU-1 ), 00435 $ RWORK( I+MU-1 ), WORK( I+MU-1 ), RA ) 00436 AB( KU-MU+3, I+MU-2 ) = RA 00437 CALL ZROT( MIN( KL+MU-2, M-I ), 00438 $ AB( KU-MU+4, I+MU-2 ), 1, 00439 $ AB( KU-MU+3, I+MU-1 ), 1, 00440 $ RWORK( I+MU-1 ), WORK( I+MU-1 ) ) 00441 END IF 00442 NR = NR + 1 00443 J1 = J1 - KB1 00444 END IF 00445 * 00446 IF( WANTPT ) THEN 00447 * 00448 * accumulate product of plane rotations in P**H 00449 * 00450 DO 60 J = J1, J2, KB1 00451 CALL ZROT( N, PT( J+KUN-1, 1 ), LDPT, 00452 $ PT( J+KUN, 1 ), LDPT, RWORK( J+KUN ), 00453 $ DCONJG( WORK( J+KUN ) ) ) 00454 60 CONTINUE 00455 END IF 00456 * 00457 IF( J2+KB.GT.M ) THEN 00458 * 00459 * adjust J2 to keep within the bounds of the matrix 00460 * 00461 NR = NR - 1 00462 J2 = J2 - KB1 00463 END IF 00464 * 00465 DO 70 J = J1, J2, KB1 00466 * 00467 * create nonzero element a(j+kl+ku,j+ku-1) below the 00468 * band and store it in WORK(1:n) 00469 * 00470 WORK( J+KB ) = WORK( J+KUN )*AB( KLU1, J+KUN ) 00471 AB( KLU1, J+KUN ) = RWORK( J+KUN )*AB( KLU1, J+KUN ) 00472 70 CONTINUE 00473 * 00474 IF( ML.GT.ML0 ) THEN 00475 ML = ML - 1 00476 ELSE 00477 MU = MU - 1 00478 END IF 00479 80 CONTINUE 00480 90 CONTINUE 00481 END IF 00482 * 00483 IF( KU.EQ.0 .AND. KL.GT.0 ) THEN 00484 * 00485 * A has been reduced to complex lower bidiagonal form 00486 * 00487 * Transform lower bidiagonal form to upper bidiagonal by applying 00488 * plane rotations from the left, overwriting superdiagonal 00489 * elements on subdiagonal elements 00490 * 00491 DO 100 I = 1, MIN( M-1, N ) 00492 CALL ZLARTG( AB( 1, I ), AB( 2, I ), RC, RS, RA ) 00493 AB( 1, I ) = RA 00494 IF( I.LT.N ) THEN 00495 AB( 2, I ) = RS*AB( 1, I+1 ) 00496 AB( 1, I+1 ) = RC*AB( 1, I+1 ) 00497 END IF 00498 IF( WANTQ ) 00499 $ CALL ZROT( M, Q( 1, I ), 1, Q( 1, I+1 ), 1, RC, 00500 $ DCONJG( RS ) ) 00501 IF( WANTC ) 00502 $ CALL ZROT( NCC, C( I, 1 ), LDC, C( I+1, 1 ), LDC, RC, 00503 $ RS ) 00504 100 CONTINUE 00505 ELSE 00506 * 00507 * A has been reduced to complex upper bidiagonal form or is 00508 * diagonal 00509 * 00510 IF( KU.GT.0 .AND. M.LT.N ) THEN 00511 * 00512 * Annihilate a(m,m+1) by applying plane rotations from the 00513 * right 00514 * 00515 RB = AB( KU, M+1 ) 00516 DO 110 I = M, 1, -1 00517 CALL ZLARTG( AB( KU+1, I ), RB, RC, RS, RA ) 00518 AB( KU+1, I ) = RA 00519 IF( I.GT.1 ) THEN 00520 RB = -DCONJG( RS )*AB( KU, I ) 00521 AB( KU, I ) = RC*AB( KU, I ) 00522 END IF 00523 IF( WANTPT ) 00524 $ CALL ZROT( N, PT( I, 1 ), LDPT, PT( M+1, 1 ), LDPT, 00525 $ RC, DCONJG( RS ) ) 00526 110 CONTINUE 00527 END IF 00528 END IF 00529 * 00530 * Make diagonal and superdiagonal elements real, storing them in D 00531 * and E 00532 * 00533 T = AB( KU+1, 1 ) 00534 DO 120 I = 1, MINMN 00535 ABST = ABS( T ) 00536 D( I ) = ABST 00537 IF( ABST.NE.ZERO ) THEN 00538 T = T / ABST 00539 ELSE 00540 T = CONE 00541 END IF 00542 IF( WANTQ ) 00543 $ CALL ZSCAL( M, T, Q( 1, I ), 1 ) 00544 IF( WANTC ) 00545 $ CALL ZSCAL( NCC, DCONJG( T ), C( I, 1 ), LDC ) 00546 IF( I.LT.MINMN ) THEN 00547 IF( KU.EQ.0 .AND. KL.EQ.0 ) THEN 00548 E( I ) = ZERO 00549 T = AB( 1, I+1 ) 00550 ELSE 00551 IF( KU.EQ.0 ) THEN 00552 T = AB( 2, I )*DCONJG( T ) 00553 ELSE 00554 T = AB( KU, I+1 )*DCONJG( T ) 00555 END IF 00556 ABST = ABS( T ) 00557 E( I ) = ABST 00558 IF( ABST.NE.ZERO ) THEN 00559 T = T / ABST 00560 ELSE 00561 T = CONE 00562 END IF 00563 IF( WANTPT ) 00564 $ CALL ZSCAL( N, T, PT( I+1, 1 ), LDPT ) 00565 T = AB( KU+1, I+1 )*DCONJG( T ) 00566 END IF 00567 END IF 00568 120 CONTINUE 00569 RETURN 00570 * 00571 * End of ZGBBRD 00572 * 00573 END