117 SUBROUTINE zhetrs( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
125 INTEGER INFO, LDA, LDB, N, NRHS
129 COMPLEX*16 A( LDA, * ), B( LDB, * )
136 parameter( one = ( 1.0d+0, 0.0d+0 ) )
142 COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
153 INTRINSIC dble, dconjg, max
158 upper = lsame( uplo,
'U' )
159 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
161 ELSE IF( n.LT.0 )
THEN
163 ELSE IF( nrhs.LT.0 )
THEN
165 ELSE IF( lda.LT.max( 1, n ) )
THEN
167 ELSE IF( ldb.LT.max( 1, n ) )
THEN
171 CALL xerbla(
'ZHETRS', -info )
177 IF( n.EQ.0 .OR. nrhs.EQ.0 )
197 IF( ipiv( k ).GT.0 )
THEN
205 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
210 CALL zgeru( k-1, nrhs, -one, a( 1, k ), 1, b( k, 1 ),
216 s = dble( one ) / dble( a( k, k ) )
217 CALL zdscal( nrhs, s, b( k, 1 ), ldb )
227 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
232 CALL zgeru( k-2, nrhs, -one, a( 1, k ), 1, b( k, 1 ),
235 CALL zgeru( k-2, nrhs, -one, a( 1, k-1 ), 1, b( k-1, 1 ),
236 $ ldb, b( 1, 1 ), ldb )
241 akm1 = a( k-1, k-1 ) / akm1k
242 ak = a( k, k ) / dconjg( akm1k )
243 denom = akm1*ak - one
245 bkm1 = b( k-1, j ) / akm1k
246 bk = b( k, j ) / dconjg( akm1k )
247 b( k-1, j ) = ( ak*bkm1-bk ) / denom
248 b( k, j ) = ( akm1*bk-bkm1 ) / denom
269 IF( ipiv( k ).GT.0 )
THEN
277 CALL zlacgv( nrhs, b( k, 1 ), ldb )
278 CALL zgemv(
'Conjugate transpose', k-1, nrhs, -one, b,
279 $ ldb, a( 1, k ), 1, one, b( k, 1 ), ldb )
280 CALL zlacgv( nrhs, b( k, 1 ), ldb )
287 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
297 CALL zlacgv( nrhs, b( k, 1 ), ldb )
298 CALL zgemv(
'Conjugate transpose', k-1, nrhs, -one, b,
299 $ ldb, a( 1, k ), 1, one, b( k, 1 ), ldb )
300 CALL zlacgv( nrhs, b( k, 1 ), ldb )
302 CALL zlacgv( nrhs, b( k+1, 1 ), ldb )
303 CALL zgemv(
'Conjugate transpose', k-1, nrhs, -one, b,
304 $ ldb, a( 1, k+1 ), 1, one, b( k+1, 1 ), ldb )
305 CALL zlacgv( nrhs, b( k+1, 1 ), ldb )
312 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
336 IF( ipiv( k ).GT.0 )
THEN
344 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
350 $
CALL zgeru( n-k, nrhs, -one, a( k+1, k ), 1, b( k,
352 $ ldb, b( k+1, 1 ), ldb )
356 s = dble( one ) / dble( a( k, k ) )
357 CALL zdscal( nrhs, s, b( k, 1 ), ldb )
367 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
373 CALL zgeru( n-k-1, nrhs, -one, a( k+2, k ), 1, b( k,
375 $ ldb, b( k+2, 1 ), ldb )
376 CALL zgeru( n-k-1, nrhs, -one, a( k+2, k+1 ), 1,
377 $ b( k+1, 1 ), ldb, b( k+2, 1 ), ldb )
383 akm1 = a( k, k ) / dconjg( akm1k )
384 ak = a( k+1, k+1 ) / akm1k
385 denom = akm1*ak - one
387 bkm1 = b( k, j ) / dconjg( akm1k )
388 bk = b( k+1, j ) / akm1k
389 b( k, j ) = ( ak*bkm1-bk ) / denom
390 b( k+1, j ) = ( akm1*bk-bkm1 ) / denom
411 IF( ipiv( k ).GT.0 )
THEN
419 CALL zlacgv( nrhs, b( k, 1 ), ldb )
420 CALL zgemv(
'Conjugate transpose', n-k, nrhs, -one,
421 $ b( k+1, 1 ), ldb, a( k+1, k ), 1, one,
423 CALL zlacgv( nrhs, b( k, 1 ), ldb )
430 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
440 CALL zlacgv( nrhs, b( k, 1 ), ldb )
441 CALL zgemv(
'Conjugate transpose', n-k, nrhs, -one,
442 $ b( k+1, 1 ), ldb, a( k+1, k ), 1, one,
444 CALL zlacgv( nrhs, b( k, 1 ), ldb )
446 CALL zlacgv( nrhs, b( k-1, 1 ), ldb )
447 CALL zgemv(
'Conjugate transpose', n-k, nrhs, -one,
448 $ b( k+1, 1 ), ldb, a( k+1, k-1 ), 1, one,
450 CALL zlacgv( nrhs, b( k-1, 1 ), ldb )
457 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )