LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE CLAVHP( UPLO, TRANS, DIAG, N, NRHS, A, IPIV, B, LDB, 00002 $ INFO ) 00003 * 00004 * -- LAPACK auxiliary routine (version 3.1) -- 00005 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 CHARACTER DIAG, TRANS, UPLO 00010 INTEGER INFO, LDB, N, NRHS 00011 * .. 00012 * .. Array Arguments .. 00013 INTEGER IPIV( * ) 00014 COMPLEX A( * ), B( LDB, * ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * CLAVHP performs one of the matrix-vector operations 00021 * x := A*x or x := A^H*x, 00022 * where x is an N element vector and A is one of the factors 00023 * from the symmetric factorization computed by CHPTRF. 00024 * CHPTRF produces a factorization of the form 00025 * U * D * U^H or L * D * L^H, 00026 * where U (or L) is a product of permutation and unit upper (lower) 00027 * triangular matrices, U^H (or L^H) is the conjugate transpose of 00028 * U (or L), and D is Hermitian and block diagonal with 1 x 1 and 00029 * 2 x 2 diagonal blocks. The multipliers for the transformations 00030 * and the upper or lower triangular parts of the diagonal blocks 00031 * are stored columnwise in packed format in the linear array A. 00032 * 00033 * If TRANS = 'N' or 'n', CLAVHP multiplies either by U or U * D 00034 * (or L or L * D). 00035 * If TRANS = 'C' or 'c', CLAVHP multiplies either by U^H or D * U^H 00036 * (or L^H or D * L^H ). 00037 * 00038 * Arguments 00039 * ========== 00040 * 00041 * UPLO - CHARACTER*1 00042 * On entry, UPLO specifies whether the triangular matrix 00043 * stored in A is upper or lower triangular. 00044 * UPLO = 'U' or 'u' The matrix is upper triangular. 00045 * UPLO = 'L' or 'l' The matrix is lower triangular. 00046 * Unchanged on exit. 00047 * 00048 * TRANS - CHARACTER*1 00049 * On entry, TRANS specifies the operation to be performed as 00050 * follows: 00051 * TRANS = 'N' or 'n' x := A*x. 00052 * TRANS = 'C' or 'c' x := A^H*x. 00053 * Unchanged on exit. 00054 * 00055 * DIAG - CHARACTER*1 00056 * On entry, DIAG specifies whether the diagonal blocks are 00057 * assumed to be unit matrices, as follows: 00058 * DIAG = 'U' or 'u' Diagonal blocks are unit matrices. 00059 * DIAG = 'N' or 'n' Diagonal blocks are non-unit. 00060 * Unchanged on exit. 00061 * 00062 * N - INTEGER 00063 * On entry, N specifies the order of the matrix A. 00064 * N must be at least zero. 00065 * Unchanged on exit. 00066 * 00067 * NRHS - INTEGER 00068 * On entry, NRHS specifies the number of right hand sides, 00069 * i.e., the number of vectors x to be multiplied by A. 00070 * NRHS must be at least zero. 00071 * Unchanged on exit. 00072 * 00073 * A - COMPLEX array, dimension( N*(N+1)/2 ) 00074 * On entry, A contains a block diagonal matrix and the 00075 * multipliers of the transformations used to obtain it, 00076 * stored as a packed triangular matrix. 00077 * Unchanged on exit. 00078 * 00079 * IPIV - INTEGER array, dimension( N ) 00080 * On entry, IPIV contains the vector of pivot indices as 00081 * determined by CSPTRF or CHPTRF. 00082 * If IPIV( K ) = K, no interchange was done. 00083 * If IPIV( K ) <> K but IPIV( K ) > 0, then row K was inter- 00084 * changed with row IPIV( K ) and a 1 x 1 pivot block was used. 00085 * If IPIV( K ) < 0 and UPLO = 'U', then row K-1 was exchanged 00086 * with row | IPIV( K ) | and a 2 x 2 pivot block was used. 00087 * If IPIV( K ) < 0 and UPLO = 'L', then row K+1 was exchanged 00088 * with row | IPIV( K ) | and a 2 x 2 pivot block was used. 00089 * 00090 * B - COMPLEX array, dimension( LDB, NRHS ) 00091 * On entry, B contains NRHS vectors of length N. 00092 * On exit, B is overwritten with the product A * B. 00093 * 00094 * LDB - INTEGER 00095 * On entry, LDB contains the leading dimension of B as 00096 * declared in the calling program. LDB must be at least 00097 * max( 1, N ). 00098 * Unchanged on exit. 00099 * 00100 * INFO - INTEGER 00101 * INFO is the error flag. 00102 * On exit, a value of 0 indicates a successful exit. 00103 * A negative value, say -K, indicates that the K-th argument 00104 * has an illegal value. 00105 * 00106 * ===================================================================== 00107 * 00108 * .. Parameters .. 00109 COMPLEX ONE 00110 PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ) ) 00111 * .. 00112 * .. Local Scalars .. 00113 LOGICAL NOUNIT 00114 INTEGER J, K, KC, KCNEXT, KP 00115 COMPLEX D11, D12, D21, D22, T1, T2 00116 * .. 00117 * .. External Functions .. 00118 LOGICAL LSAME 00119 EXTERNAL LSAME 00120 * .. 00121 * .. External Subroutines .. 00122 EXTERNAL CGEMV, CGERU, CLACGV, CSCAL, CSWAP, XERBLA 00123 * .. 00124 * .. Intrinsic Functions .. 00125 INTRINSIC ABS, CONJG, MAX 00126 * .. 00127 * .. Executable Statements .. 00128 * 00129 * Test the input parameters. 00130 * 00131 INFO = 0 00132 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00133 INFO = -1 00134 ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) 00135 $ THEN 00136 INFO = -2 00137 ELSE IF( .NOT.LSAME( DIAG, 'U' ) .AND. .NOT.LSAME( DIAG, 'N' ) ) 00138 $ THEN 00139 INFO = -3 00140 ELSE IF( N.LT.0 ) THEN 00141 INFO = -4 00142 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00143 INFO = -8 00144 END IF 00145 IF( INFO.NE.0 ) THEN 00146 CALL XERBLA( 'CLAVHP ', -INFO ) 00147 RETURN 00148 END IF 00149 * 00150 * Quick return if possible. 00151 * 00152 IF( N.EQ.0 ) 00153 $ RETURN 00154 * 00155 NOUNIT = LSAME( DIAG, 'N' ) 00156 *------------------------------------------ 00157 * 00158 * Compute B := A * B (No transpose) 00159 * 00160 *------------------------------------------ 00161 IF( LSAME( TRANS, 'N' ) ) THEN 00162 * 00163 * Compute B := U*B 00164 * where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) 00165 * 00166 IF( LSAME( UPLO, 'U' ) ) THEN 00167 * 00168 * Loop forward applying the transformations. 00169 * 00170 K = 1 00171 KC = 1 00172 10 CONTINUE 00173 IF( K.GT.N ) 00174 $ GO TO 30 00175 * 00176 * 1 x 1 pivot block 00177 * 00178 IF( IPIV( K ).GT.0 ) THEN 00179 * 00180 * Multiply by the diagonal element if forming U * D. 00181 * 00182 IF( NOUNIT ) 00183 $ CALL CSCAL( NRHS, A( KC+K-1 ), B( K, 1 ), LDB ) 00184 * 00185 * Multiply by P(K) * inv(U(K)) if K > 1. 00186 * 00187 IF( K.GT.1 ) THEN 00188 * 00189 * Apply the transformation. 00190 * 00191 CALL CGERU( K-1, NRHS, ONE, A( KC ), 1, B( K, 1 ), 00192 $ LDB, B( 1, 1 ), LDB ) 00193 * 00194 * Interchange if P(K) != I. 00195 * 00196 KP = IPIV( K ) 00197 IF( KP.NE.K ) 00198 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00199 END IF 00200 KC = KC + K 00201 K = K + 1 00202 ELSE 00203 * 00204 * 2 x 2 pivot block 00205 * 00206 KCNEXT = KC + K 00207 * 00208 * Multiply by the diagonal block if forming U * D. 00209 * 00210 IF( NOUNIT ) THEN 00211 D11 = A( KCNEXT-1 ) 00212 D22 = A( KCNEXT+K ) 00213 D12 = A( KCNEXT+K-1 ) 00214 D21 = CONJG( D12 ) 00215 DO 20 J = 1, NRHS 00216 T1 = B( K, J ) 00217 T2 = B( K+1, J ) 00218 B( K, J ) = D11*T1 + D12*T2 00219 B( K+1, J ) = D21*T1 + D22*T2 00220 20 CONTINUE 00221 END IF 00222 * 00223 * Multiply by P(K) * inv(U(K)) if K > 1. 00224 * 00225 IF( K.GT.1 ) THEN 00226 * 00227 * Apply the transformations. 00228 * 00229 CALL CGERU( K-1, NRHS, ONE, A( KC ), 1, B( K, 1 ), 00230 $ LDB, B( 1, 1 ), LDB ) 00231 CALL CGERU( K-1, NRHS, ONE, A( KCNEXT ), 1, 00232 $ B( K+1, 1 ), LDB, B( 1, 1 ), LDB ) 00233 * 00234 * Interchange if P(K) != I. 00235 * 00236 KP = ABS( IPIV( K ) ) 00237 IF( KP.NE.K ) 00238 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00239 END IF 00240 KC = KCNEXT + K + 1 00241 K = K + 2 00242 END IF 00243 GO TO 10 00244 30 CONTINUE 00245 * 00246 * Compute B := L*B 00247 * where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) . 00248 * 00249 ELSE 00250 * 00251 * Loop backward applying the transformations to B. 00252 * 00253 K = N 00254 KC = N*( N+1 ) / 2 + 1 00255 40 CONTINUE 00256 IF( K.LT.1 ) 00257 $ GO TO 60 00258 KC = KC - ( N-K+1 ) 00259 * 00260 * Test the pivot index. If greater than zero, a 1 x 1 00261 * pivot was used, otherwise a 2 x 2 pivot was used. 00262 * 00263 IF( IPIV( K ).GT.0 ) THEN 00264 * 00265 * 1 x 1 pivot block: 00266 * 00267 * Multiply by the diagonal element if forming L * D. 00268 * 00269 IF( NOUNIT ) 00270 $ CALL CSCAL( NRHS, A( KC ), B( K, 1 ), LDB ) 00271 * 00272 * Multiply by P(K) * inv(L(K)) if K < N. 00273 * 00274 IF( K.NE.N ) THEN 00275 KP = IPIV( K ) 00276 * 00277 * Apply the transformation. 00278 * 00279 CALL CGERU( N-K, NRHS, ONE, A( KC+1 ), 1, B( K, 1 ), 00280 $ LDB, B( K+1, 1 ), LDB ) 00281 * 00282 * Interchange if a permutation was applied at the 00283 * K-th step of the factorization. 00284 * 00285 IF( KP.NE.K ) 00286 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00287 END IF 00288 K = K - 1 00289 * 00290 ELSE 00291 * 00292 * 2 x 2 pivot block: 00293 * 00294 KCNEXT = KC - ( N-K+2 ) 00295 * 00296 * Multiply by the diagonal block if forming L * D. 00297 * 00298 IF( NOUNIT ) THEN 00299 D11 = A( KCNEXT ) 00300 D22 = A( KC ) 00301 D21 = A( KCNEXT+1 ) 00302 D12 = CONJG( D21 ) 00303 DO 50 J = 1, NRHS 00304 T1 = B( K-1, J ) 00305 T2 = B( K, J ) 00306 B( K-1, J ) = D11*T1 + D12*T2 00307 B( K, J ) = D21*T1 + D22*T2 00308 50 CONTINUE 00309 END IF 00310 * 00311 * Multiply by P(K) * inv(L(K)) if K < N. 00312 * 00313 IF( K.NE.N ) THEN 00314 * 00315 * Apply the transformation. 00316 * 00317 CALL CGERU( N-K, NRHS, ONE, A( KC+1 ), 1, B( K, 1 ), 00318 $ LDB, B( K+1, 1 ), LDB ) 00319 CALL CGERU( N-K, NRHS, ONE, A( KCNEXT+2 ), 1, 00320 $ B( K-1, 1 ), LDB, B( K+1, 1 ), LDB ) 00321 * 00322 * Interchange if a permutation was applied at the 00323 * K-th step of the factorization. 00324 * 00325 KP = ABS( IPIV( K ) ) 00326 IF( KP.NE.K ) 00327 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00328 END IF 00329 KC = KCNEXT 00330 K = K - 2 00331 END IF 00332 GO TO 40 00333 60 CONTINUE 00334 END IF 00335 *------------------------------------------------- 00336 * 00337 * Compute B := A^H * B (conjugate transpose) 00338 * 00339 *------------------------------------------------- 00340 ELSE 00341 * 00342 * Form B := U^H*B 00343 * where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) 00344 * and U^H = inv(U^H(1))*P(1)* ... *inv(U^H(m))*P(m) 00345 * 00346 IF( LSAME( UPLO, 'U' ) ) THEN 00347 * 00348 * Loop backward applying the transformations. 00349 * 00350 K = N 00351 KC = N*( N+1 ) / 2 + 1 00352 70 IF( K.LT.1 ) 00353 $ GO TO 90 00354 KC = KC - K 00355 * 00356 * 1 x 1 pivot block. 00357 * 00358 IF( IPIV( K ).GT.0 ) THEN 00359 IF( K.GT.1 ) THEN 00360 * 00361 * Interchange if P(K) != I. 00362 * 00363 KP = IPIV( K ) 00364 IF( KP.NE.K ) 00365 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00366 * 00367 * Apply the transformation: 00368 * y := y - B' * conjg(x) 00369 * where x is a column of A and y is a row of B. 00370 * 00371 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00372 CALL CGEMV( 'Conjugate', K-1, NRHS, ONE, B, LDB, 00373 $ A( KC ), 1, ONE, B( K, 1 ), LDB ) 00374 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00375 END IF 00376 IF( NOUNIT ) 00377 $ CALL CSCAL( NRHS, A( KC+K-1 ), B( K, 1 ), LDB ) 00378 K = K - 1 00379 * 00380 * 2 x 2 pivot block. 00381 * 00382 ELSE 00383 KCNEXT = KC - ( K-1 ) 00384 IF( K.GT.2 ) THEN 00385 * 00386 * Interchange if P(K) != I. 00387 * 00388 KP = ABS( IPIV( K ) ) 00389 IF( KP.NE.K-1 ) 00390 $ CALL CSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), 00391 $ LDB ) 00392 * 00393 * Apply the transformations. 00394 * 00395 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00396 CALL CGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB, 00397 $ A( KC ), 1, ONE, B( K, 1 ), LDB ) 00398 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00399 * 00400 CALL CLACGV( NRHS, B( K-1, 1 ), LDB ) 00401 CALL CGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB, 00402 $ A( KCNEXT ), 1, ONE, B( K-1, 1 ), LDB ) 00403 CALL CLACGV( NRHS, B( K-1, 1 ), LDB ) 00404 END IF 00405 * 00406 * Multiply by the diagonal block if non-unit. 00407 * 00408 IF( NOUNIT ) THEN 00409 D11 = A( KC-1 ) 00410 D22 = A( KC+K-1 ) 00411 D12 = A( KC+K-2 ) 00412 D21 = CONJG( D12 ) 00413 DO 80 J = 1, NRHS 00414 T1 = B( K-1, J ) 00415 T2 = B( K, J ) 00416 B( K-1, J ) = D11*T1 + D12*T2 00417 B( K, J ) = D21*T1 + D22*T2 00418 80 CONTINUE 00419 END IF 00420 KC = KCNEXT 00421 K = K - 2 00422 END IF 00423 GO TO 70 00424 90 CONTINUE 00425 * 00426 * Form B := L^H*B 00427 * where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) 00428 * and L^H = inv(L(m))*P(m)* ... *inv(L(1))*P(1) 00429 * 00430 ELSE 00431 * 00432 * Loop forward applying the L-transformations. 00433 * 00434 K = 1 00435 KC = 1 00436 100 CONTINUE 00437 IF( K.GT.N ) 00438 $ GO TO 120 00439 * 00440 * 1 x 1 pivot block 00441 * 00442 IF( IPIV( K ).GT.0 ) THEN 00443 IF( K.LT.N ) THEN 00444 * 00445 * Interchange if P(K) != I. 00446 * 00447 KP = IPIV( K ) 00448 IF( KP.NE.K ) 00449 $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB ) 00450 * 00451 * Apply the transformation 00452 * 00453 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00454 CALL CGEMV( 'Conjugate', N-K, NRHS, ONE, B( K+1, 1 ), 00455 $ LDB, A( KC+1 ), 1, ONE, B( K, 1 ), LDB ) 00456 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00457 END IF 00458 IF( NOUNIT ) 00459 $ CALL CSCAL( NRHS, A( KC ), B( K, 1 ), LDB ) 00460 KC = KC + N - K + 1 00461 K = K + 1 00462 * 00463 * 2 x 2 pivot block. 00464 * 00465 ELSE 00466 KCNEXT = KC + N - K + 1 00467 IF( K.LT.N-1 ) THEN 00468 * 00469 * Interchange if P(K) != I. 00470 * 00471 KP = ABS( IPIV( K ) ) 00472 IF( KP.NE.K+1 ) 00473 $ CALL CSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ), 00474 $ LDB ) 00475 * 00476 * Apply the transformation 00477 * 00478 CALL CLACGV( NRHS, B( K+1, 1 ), LDB ) 00479 CALL CGEMV( 'Conjugate', N-K-1, NRHS, ONE, 00480 $ B( K+2, 1 ), LDB, A( KCNEXT+1 ), 1, ONE, 00481 $ B( K+1, 1 ), LDB ) 00482 CALL CLACGV( NRHS, B( K+1, 1 ), LDB ) 00483 * 00484 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00485 CALL CGEMV( 'Conjugate', N-K-1, NRHS, ONE, 00486 $ B( K+2, 1 ), LDB, A( KC+2 ), 1, ONE, 00487 $ B( K, 1 ), LDB ) 00488 CALL CLACGV( NRHS, B( K, 1 ), LDB ) 00489 END IF 00490 * 00491 * Multiply by the diagonal block if non-unit. 00492 * 00493 IF( NOUNIT ) THEN 00494 D11 = A( KC ) 00495 D22 = A( KCNEXT ) 00496 D21 = A( KC+1 ) 00497 D12 = CONJG( D21 ) 00498 DO 110 J = 1, NRHS 00499 T1 = B( K, J ) 00500 T2 = B( K+1, J ) 00501 B( K, J ) = D11*T1 + D12*T2 00502 B( K+1, J ) = D21*T1 + D22*T2 00503 110 CONTINUE 00504 END IF 00505 KC = KCNEXT + ( N-K ) 00506 K = K + 2 00507 END IF 00508 GO TO 100 00509 120 CONTINUE 00510 END IF 00511 * 00512 END IF 00513 RETURN 00514 * 00515 * End of CLAVHP 00516 * 00517 END