125 SUBROUTINE zhetrs2( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
134 INTEGER INFO, LDA, LDB, N, NRHS
138 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
145 parameter( one = (1.0d+0,0.0d+0) )
149 INTEGER I, IINFO, J, K, KP
151 COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
161 INTRINSIC dble, dconjg, max
166 upper = lsame( uplo,
'U' )
167 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
169 ELSE IF( n.LT.0 )
THEN
171 ELSE IF( nrhs.LT.0 )
THEN
173 ELSE IF( lda.LT.max( 1, n ) )
THEN
175 ELSE IF( ldb.LT.max( 1, n ) )
THEN
179 CALL xerbla(
'ZHETRS2', -info )
185 IF( n.EQ.0 .OR. nrhs.EQ.0 )
190 CALL zsyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
198 DO WHILE ( k .GE. 1 )
199 IF( ipiv( k ).GT.0 )
THEN
204 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
210 IF( kp.EQ.-ipiv( k-1 ) )
211 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
218 CALL ztrsm(
'L',
'U',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
223 DO WHILE ( i .GE. 1 )
224 IF( ipiv(i) .GT. 0 )
THEN
225 s = dble( one ) / dble( a( i, i ) )
226 CALL zdscal( nrhs, s, b( i, 1 ), ldb )
227 ELSEIF ( i .GT. 1)
THEN
228 IF ( ipiv(i-1) .EQ. ipiv(i) )
THEN
230 akm1 = a( i-1, i-1 ) / akm1k
231 ak = a( i, i ) / dconjg( akm1k )
232 denom = akm1*ak - one
234 bkm1 = b( i-1, j ) / akm1k
235 bk = b( i, j ) / dconjg( akm1k )
236 b( i-1, j ) = ( ak*bkm1-bk ) / denom
237 b( i, j ) = ( akm1*bk-bkm1 ) / denom
247 CALL ztrsm(
'L',
'U',
'C',
'U',n,nrhs,one,a,lda,b,ldb)
252 DO WHILE ( k .LE. n )
253 IF( ipiv( k ).GT.0 )
THEN
258 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
264 IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
265 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
276 DO WHILE ( k .LE. n )
277 IF( ipiv( k ).GT.0 )
THEN
282 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
288 IF( kp.EQ.-ipiv( k ) )
289 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
296 CALL ztrsm(
'L',
'L',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
301 DO WHILE ( i .LE. n )
302 IF( ipiv(i) .GT. 0 )
THEN
303 s = dble( one ) / dble( a( i, i ) )
304 CALL zdscal( nrhs, s, b( i, 1 ), ldb )
307 akm1 = a( i, i ) / dconjg( akm1k )
308 ak = a( i+1, i+1 ) / akm1k
309 denom = akm1*ak - one
311 bkm1 = b( i, j ) / dconjg( akm1k )
312 bk = b( i+1, j ) / akm1k
313 b( i, j ) = ( ak*bkm1-bk ) / denom
314 b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
323 CALL ztrsm(
'L',
'L',
'C',
'U',n,nrhs,one,a,lda,b,ldb)
328 DO WHILE ( k .GE. 1 )
329 IF( ipiv( k ).GT.0 )
THEN
334 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
340 IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
341 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
350 CALL zsyconv( uplo,
'R', n, a, lda, ipiv, work, iinfo )
subroutine xerbla(srname, info)
subroutine zhetrs2(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, info)
ZHETRS2
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
subroutine zsyconv(uplo, way, n, a, lda, ipiv, e, info)
ZSYCONV
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM