1*> \brief \b ZLAVHE 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8* Definition: 9* =========== 10* 11* SUBROUTINE ZLAVHE( UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B, 12* LDB, INFO ) 13* 14* .. Scalar Arguments .. 15* CHARACTER DIAG, TRANS, UPLO 16* INTEGER INFO, LDA, LDB, N, NRHS 17* .. 18* .. Array Arguments .. 19* INTEGER IPIV( * ) 20* COMPLEX*16 A( LDA, * ), B( LDB, * ) 21* .. 22* 23* 24*> \par Purpose: 25* ============= 26*> 27*> \verbatim 28*> 29*> ZLAVHE performs one of the matrix-vector operations 30*> x := A*x or x := A^H*x, 31*> where x is an N element vector and A is one of the factors 32*> from the block U*D*U' or L*D*L' factorization computed by ZHETRF. 33*> 34*> If TRANS = 'N', multiplies by U or U * D (or L or L * D) 35*> If TRANS = 'C', multiplies by U' or D * U' (or L' or D * L') 36*> \endverbatim 37* 38* Arguments: 39* ========== 40* 41*> \param[in] UPLO 42*> \verbatim 43*> UPLO is CHARACTER*1 44*> Specifies whether the factor stored in A is upper or lower 45*> triangular. 46*> = 'U': Upper triangular 47*> = 'L': Lower triangular 48*> \endverbatim 49*> 50*> \param[in] TRANS 51*> \verbatim 52*> TRANS is CHARACTER*1 53*> Specifies the operation to be performed: 54*> = 'N': x := A*x 55*> = 'C': x := A'*x 56*> \endverbatim 57*> 58*> \param[in] DIAG 59*> \verbatim 60*> DIAG is CHARACTER*1 61*> Specifies whether or not the diagonal blocks are unit 62*> matrices. If the diagonal blocks are assumed to be unit, 63*> then A = U or A = L, otherwise A = U*D or A = L*D. 64*> = 'U': Diagonal blocks are assumed to be unit matrices. 65*> = 'N': Diagonal blocks are assumed to be non-unit matrices. 66*> \endverbatim 67*> 68*> \param[in] N 69*> \verbatim 70*> N is INTEGER 71*> The number of rows and columns of the matrix A. N >= 0. 72*> \endverbatim 73*> 74*> \param[in] NRHS 75*> \verbatim 76*> NRHS is INTEGER 77*> The number of right hand sides, i.e., the number of vectors 78*> x to be multiplied by A. NRHS >= 0. 79*> \endverbatim 80*> 81*> \param[in] A 82*> \verbatim 83*> A is COMPLEX*16 array, dimension (LDA,N) 84*> The block diagonal matrix D and the multipliers used to 85*> obtain the factor U or L as computed by ZHETRF. 86*> Stored as a 2-D triangular matrix. 87*> \endverbatim 88*> 89*> \param[in] LDA 90*> \verbatim 91*> LDA is INTEGER 92*> The leading dimension of the array A. LDA >= max(1,N). 93*> \endverbatim 94*> 95*> \param[in] IPIV 96*> \verbatim 97*> IPIV is INTEGER array, dimension (N) 98*> Details of the interchanges and the block structure of D, 99*> as determined by ZHETRF. 100*> 101*> If UPLO = 'U': 102*> If IPIV(k) > 0, then rows and columns k and IPIV(k) 103*> were interchanged and D(k,k) is a 1-by-1 diagonal block. 104*> (If IPIV( k ) = k, no interchange was done). 105*> 106*> If IPIV(k) = IPIV(k-1) < 0, then rows and 107*> columns k-1 and -IPIV(k) were interchanged, 108*> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. 109*> 110*> If UPLO = 'L': 111*> If IPIV(k) > 0, then rows and columns k and IPIV(k) 112*> were interchanged and D(k,k) is a 1-by-1 diagonal block. 113*> (If IPIV( k ) = k, no interchange was done). 114*> 115*> If IPIV(k) = IPIV(k+1) < 0, then rows and 116*> columns k+1 and -IPIV(k) were interchanged, 117*> D(k:k+1,k:k+1) is a 2-by-2 diagonal block. 118*> \endverbatim 119*> 120*> \param[in,out] B 121*> \verbatim 122*> B is COMPLEX*16 array, dimension (LDB,NRHS) 123*> On entry, B contains NRHS vectors of length N. 124*> On exit, B is overwritten with the product A * B. 125*> \endverbatim 126*> 127*> \param[in] LDB 128*> \verbatim 129*> LDB is INTEGER 130*> The leading dimension of the array B. LDB >= max(1,N). 131*> \endverbatim 132*> 133*> \param[out] INFO 134*> \verbatim 135*> INFO is INTEGER 136*> = 0: successful exit 137*> < 0: if INFO = -k, the k-th argument had an illegal value 138*> \endverbatim 139* 140* Authors: 141* ======== 142* 143*> \author Univ. of Tennessee 144*> \author Univ. of California Berkeley 145*> \author Univ. of Colorado Denver 146*> \author NAG Ltd. 147* 148*> \date November 2013 149* 150*> \ingroup complex16_lin 151* 152* ===================================================================== 153 SUBROUTINE ZLAVHE( UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B, 154 $ LDB, INFO ) 155* 156* -- LAPACK test routine (version 3.5.0) -- 157* -- LAPACK is a software package provided by Univ. of Tennessee, -- 158* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 159* November 2013 160* 161* .. Scalar Arguments .. 162 CHARACTER DIAG, TRANS, UPLO 163 INTEGER INFO, LDA, LDB, N, NRHS 164* .. 165* .. Array Arguments .. 166 INTEGER IPIV( * ) 167 COMPLEX*16 A( LDA, * ), B( LDB, * ) 168* .. 169* 170* ===================================================================== 171* 172* .. Parameters .. 173 COMPLEX*16 ONE 174 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) ) 175* .. 176* .. Local Scalars .. 177 LOGICAL NOUNIT 178 INTEGER J, K, KP 179 COMPLEX*16 D11, D12, D21, D22, T1, T2 180* .. 181* .. External Functions .. 182 LOGICAL LSAME 183 EXTERNAL LSAME 184* .. 185* .. External Subroutines .. 186 EXTERNAL XERBLA, ZGEMV, ZGERU, ZLACGV, ZSCAL, ZSWAP 187* .. 188* .. Intrinsic Functions .. 189 INTRINSIC ABS, DCONJG, MAX 190* .. 191* .. Executable Statements .. 192* 193* Test the input parameters. 194* 195 INFO = 0 196 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 197 INFO = -1 198 ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) 199 $ THEN 200 INFO = -2 201 ELSE IF( .NOT.LSAME( DIAG, 'U' ) .AND. .NOT.LSAME( DIAG, 'N' ) ) 202 $ THEN 203 INFO = -3 204 ELSE IF( N.LT.0 ) THEN 205 INFO = -4 206 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 207 INFO = -6 208 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 209 INFO = -9 210 END IF 211 IF( INFO.NE.0 ) THEN 212 CALL XERBLA( 'ZLAVHE ', -INFO ) 213 RETURN 214 END IF 215* 216* Quick return if possible. 217* 218 IF( N.EQ.0 ) 219 $ RETURN 220* 221 NOUNIT = LSAME( DIAG, 'N' ) 222*------------------------------------------ 223* 224* Compute B := A * B (No transpose) 225* 226*------------------------------------------ 227 IF( LSAME( TRANS, 'N' ) ) THEN 228* 229* Compute B := U*B 230* where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) 231* 232 IF( LSAME( UPLO, 'U' ) ) THEN 233* 234* Loop forward applying the transformations. 235* 236 K = 1 237 10 CONTINUE 238 IF( K.GT.N ) 239 $ GO TO 30 240 IF( IPIV( K ).GT.0 ) THEN 241* 242* 1 x 1 pivot block 243* 244* Multiply by the diagonal element if forming U * D. 245* 246 IF( NOUNIT ) 247 $ CALL ZSCAL( NRHS, A( K, K ), B( K, 1 ), LDB ) 248* 249* Multiply by P(K) * inv(U(K)) if K > 1. 250* 251 IF( K.GT.1 ) THEN 252* 253* Apply the transformation. 254* 255 CALL ZGERU( K-1, NRHS, ONE, A( 1, K ), 1, B( K, 1 ), 256 $ LDB, B( 1, 1 ), LDB ) 257* 258* Interchange if P(K) != I. 259* 260 KP = IPIV( K ) 261 IF( KP.NE.K ) 262 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 263 END IF 264 K = K + 1 265 ELSE 266* 267* 2 x 2 pivot block 268* 269* Multiply by the diagonal block if forming U * D. 270* 271 IF( NOUNIT ) THEN 272 D11 = A( K, K ) 273 D22 = A( K+1, K+1 ) 274 D12 = A( K, K+1 ) 275 D21 = DCONJG( D12 ) 276 DO 20 J = 1, NRHS 277 T1 = B( K, J ) 278 T2 = B( K+1, J ) 279 B( K, J ) = D11*T1 + D12*T2 280 B( K+1, J ) = D21*T1 + D22*T2 281 20 CONTINUE 282 END IF 283* 284* Multiply by P(K) * inv(U(K)) if K > 1. 285* 286 IF( K.GT.1 ) THEN 287* 288* Apply the transformations. 289* 290 CALL ZGERU( K-1, NRHS, ONE, A( 1, K ), 1, B( K, 1 ), 291 $ LDB, B( 1, 1 ), LDB ) 292 CALL ZGERU( K-1, NRHS, ONE, A( 1, K+1 ), 1, 293 $ B( K+1, 1 ), LDB, B( 1, 1 ), LDB ) 294* 295* Interchange if P(K) != I. 296* 297 KP = ABS( IPIV( K ) ) 298 IF( KP.NE.K ) 299 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 300 END IF 301 K = K + 2 302 END IF 303 GO TO 10 304 30 CONTINUE 305* 306* Compute B := L*B 307* where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) . 308* 309 ELSE 310* 311* Loop backward applying the transformations to B. 312* 313 K = N 314 40 CONTINUE 315 IF( K.LT.1 ) 316 $ GO TO 60 317* 318* Test the pivot index. If greater than zero, a 1 x 1 319* pivot was used, otherwise a 2 x 2 pivot was used. 320* 321 IF( IPIV( K ).GT.0 ) THEN 322* 323* 1 x 1 pivot block: 324* 325* Multiply by the diagonal element if forming L * D. 326* 327 IF( NOUNIT ) 328 $ CALL ZSCAL( NRHS, A( K, K ), B( K, 1 ), LDB ) 329* 330* Multiply by P(K) * inv(L(K)) if K < N. 331* 332 IF( K.NE.N ) THEN 333 KP = IPIV( K ) 334* 335* Apply the transformation. 336* 337 CALL ZGERU( N-K, NRHS, ONE, A( K+1, K ), 1, B( K, 1 ), 338 $ LDB, B( K+1, 1 ), LDB ) 339* 340* Interchange if a permutation was applied at the 341* K-th step of the factorization. 342* 343 IF( KP.NE.K ) 344 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 345 END IF 346 K = K - 1 347* 348 ELSE 349* 350* 2 x 2 pivot block: 351* 352* Multiply by the diagonal block if forming L * D. 353* 354 IF( NOUNIT ) THEN 355 D11 = A( K-1, K-1 ) 356 D22 = A( K, K ) 357 D21 = A( K, K-1 ) 358 D12 = DCONJG( D21 ) 359 DO 50 J = 1, NRHS 360 T1 = B( K-1, J ) 361 T2 = B( K, J ) 362 B( K-1, J ) = D11*T1 + D12*T2 363 B( K, J ) = D21*T1 + D22*T2 364 50 CONTINUE 365 END IF 366* 367* Multiply by P(K) * inv(L(K)) if K < N. 368* 369 IF( K.NE.N ) THEN 370* 371* Apply the transformation. 372* 373 CALL ZGERU( N-K, NRHS, ONE, A( K+1, K ), 1, B( K, 1 ), 374 $ LDB, B( K+1, 1 ), LDB ) 375 CALL ZGERU( N-K, NRHS, ONE, A( K+1, K-1 ), 1, 376 $ B( K-1, 1 ), LDB, B( K+1, 1 ), LDB ) 377* 378* Interchange if a permutation was applied at the 379* K-th step of the factorization. 380* 381 KP = ABS( IPIV( K ) ) 382 IF( KP.NE.K ) 383 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 384 END IF 385 K = K - 2 386 END IF 387 GO TO 40 388 60 CONTINUE 389 END IF 390*-------------------------------------------------- 391* 392* Compute B := A^H * B (conjugate transpose) 393* 394*-------------------------------------------------- 395 ELSE 396* 397* Form B := U^H*B 398* where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) 399* and U^H = inv(U^H(1))*P(1)* ... *inv(U^H(m))*P(m) 400* 401 IF( LSAME( UPLO, 'U' ) ) THEN 402* 403* Loop backward applying the transformations. 404* 405 K = N 406 70 CONTINUE 407 IF( K.LT.1 ) 408 $ GO TO 90 409* 410* 1 x 1 pivot block. 411* 412 IF( IPIV( K ).GT.0 ) THEN 413 IF( K.GT.1 ) THEN 414* 415* Interchange if P(K) != I. 416* 417 KP = IPIV( K ) 418 IF( KP.NE.K ) 419 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 420* 421* Apply the transformation 422* y = y - B' conjg(x), 423* where x is a column of A and y is a row of B. 424* 425 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 426 CALL ZGEMV( 'Conjugate', K-1, NRHS, ONE, B, LDB, 427 $ A( 1, K ), 1, ONE, B( K, 1 ), LDB ) 428 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 429 END IF 430 IF( NOUNIT ) 431 $ CALL ZSCAL( NRHS, A( K, K ), B( K, 1 ), LDB ) 432 K = K - 1 433* 434* 2 x 2 pivot block. 435* 436 ELSE 437 IF( K.GT.2 ) THEN 438* 439* Interchange if P(K) != I. 440* 441 KP = ABS( IPIV( K ) ) 442 IF( KP.NE.K-1 ) 443 $ CALL ZSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), 444 $ LDB ) 445* 446* Apply the transformations 447* y = y - B' conjg(x), 448* where x is a block column of A and y is a block 449* row of B. 450* 451 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 452 CALL ZGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB, 453 $ A( 1, K ), 1, ONE, B( K, 1 ), LDB ) 454 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 455* 456 CALL ZLACGV( NRHS, B( K-1, 1 ), LDB ) 457 CALL ZGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB, 458 $ A( 1, K-1 ), 1, ONE, B( K-1, 1 ), LDB ) 459 CALL ZLACGV( NRHS, B( K-1, 1 ), LDB ) 460 END IF 461* 462* Multiply by the diagonal block if non-unit. 463* 464 IF( NOUNIT ) THEN 465 D11 = A( K-1, K-1 ) 466 D22 = A( K, K ) 467 D12 = A( K-1, K ) 468 D21 = DCONJG( D12 ) 469 DO 80 J = 1, NRHS 470 T1 = B( K-1, J ) 471 T2 = B( K, J ) 472 B( K-1, J ) = D11*T1 + D12*T2 473 B( K, J ) = D21*T1 + D22*T2 474 80 CONTINUE 475 END IF 476 K = K - 2 477 END IF 478 GO TO 70 479 90 CONTINUE 480* 481* Form B := L^H*B 482* where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) 483* and L^H = inv(L^H(m))*P(m)* ... *inv(L^H(1))*P(1) 484* 485 ELSE 486* 487* Loop forward applying the L-transformations. 488* 489 K = 1 490 100 CONTINUE 491 IF( K.GT.N ) 492 $ GO TO 120 493* 494* 1 x 1 pivot block 495* 496 IF( IPIV( K ).GT.0 ) THEN 497 IF( K.LT.N ) THEN 498* 499* Interchange if P(K) != I. 500* 501 KP = IPIV( K ) 502 IF( KP.NE.K ) 503 $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 504* 505* Apply the transformation 506* 507 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 508 CALL ZGEMV( 'Conjugate', N-K, NRHS, ONE, B( K+1, 1 ), 509 $ LDB, A( K+1, K ), 1, ONE, B( K, 1 ), LDB ) 510 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 511 END IF 512 IF( NOUNIT ) 513 $ CALL ZSCAL( NRHS, A( K, K ), B( K, 1 ), LDB ) 514 K = K + 1 515* 516* 2 x 2 pivot block. 517* 518 ELSE 519 IF( K.LT.N-1 ) THEN 520* 521* Interchange if P(K) != I. 522* 523 KP = ABS( IPIV( K ) ) 524 IF( KP.NE.K+1 ) 525 $ CALL ZSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ), 526 $ LDB ) 527* 528* Apply the transformation 529* 530 CALL ZLACGV( NRHS, B( K+1, 1 ), LDB ) 531 CALL ZGEMV( 'Conjugate', N-K-1, NRHS, ONE, 532 $ B( K+2, 1 ), LDB, A( K+2, K+1 ), 1, ONE, 533 $ B( K+1, 1 ), LDB ) 534 CALL ZLACGV( NRHS, B( K+1, 1 ), LDB ) 535* 536 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 537 CALL ZGEMV( 'Conjugate', N-K-1, NRHS, ONE, 538 $ B( K+2, 1 ), LDB, A( K+2, K ), 1, ONE, 539 $ B( K, 1 ), LDB ) 540 CALL ZLACGV( NRHS, B( K, 1 ), LDB ) 541 END IF 542* 543* Multiply by the diagonal block if non-unit. 544* 545 IF( NOUNIT ) THEN 546 D11 = A( K, K ) 547 D22 = A( K+1, K+1 ) 548 D21 = A( K+1, K ) 549 D12 = DCONJG( D21 ) 550 DO 110 J = 1, NRHS 551 T1 = B( K, J ) 552 T2 = B( K+1, J ) 553 B( K, J ) = D11*T1 + D12*T2 554 B( K+1, J ) = D21*T1 + D22*T2 555 110 CONTINUE 556 END IF 557 K = K + 2 558 END IF 559 GO TO 100 560 120 CONTINUE 561 END IF 562* 563 END IF 564 RETURN 565* 566* End of ZLAVHE 567* 568 END 569