123 SUBROUTINE zhetrs2( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
132 INTEGER INFO, LDA, LDB, N, NRHS
136 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
143 parameter( one = (1.0d+0,0.0d+0) )
147 INTEGER I, IINFO, J, K, KP
149 COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
160 INTRINSIC dble, dconjg, max
165 upper = lsame( uplo,
'U' )
166 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
168 ELSE IF( n.LT.0 )
THEN
170 ELSE IF( nrhs.LT.0 )
THEN
172 ELSE IF( lda.LT.max( 1, n ) )
THEN
174 ELSE IF( ldb.LT.max( 1, n ) )
THEN
178 CALL xerbla(
'ZHETRS2', -info )
184 IF( n.EQ.0 .OR. nrhs.EQ.0 )
189 CALL zsyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
197 DO WHILE ( k .GE. 1 )
198 IF( ipiv( k ).GT.0 )
THEN
203 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
209 IF( kp.EQ.-ipiv( k-1 ) )
210 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
217 CALL ztrsm(
'L',
'U',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
222 DO WHILE ( i .GE. 1 )
223 IF( ipiv(i) .GT. 0 )
THEN
224 s = dble( one ) / dble( a( i, i ) )
225 CALL zdscal( nrhs, s, b( i, 1 ), ldb )
226 ELSEIF ( i .GT. 1)
THEN
227 IF ( ipiv(i-1) .EQ. ipiv(i) )
THEN
229 akm1 = a( i-1, i-1 ) / akm1k
230 ak = a( i, i ) / dconjg( akm1k )
231 denom = akm1*ak - one
233 bkm1 = b( i-1, j ) / akm1k
234 bk = b( i, j ) / dconjg( akm1k )
235 b( i-1, j ) = ( ak*bkm1-bk ) / denom
236 b( i, j ) = ( akm1*bk-bkm1 ) / denom
246 CALL ztrsm(
'L',
'U',
'C',
'U',n,nrhs,one,a,lda,b,ldb)
251 DO WHILE ( k .LE. n )
252 IF( ipiv( k ).GT.0 )
THEN
257 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
263 IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
264 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
275 DO WHILE ( k .LE. n )
276 IF( ipiv( k ).GT.0 )
THEN
281 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
287 IF( kp.EQ.-ipiv( k ) )
288 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
295 CALL ztrsm(
'L',
'L',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
300 DO WHILE ( i .LE. n )
301 IF( ipiv(i) .GT. 0 )
THEN
302 s = dble( one ) / dble( a( i, i ) )
303 CALL zdscal( nrhs, s, b( i, 1 ), ldb )
306 akm1 = a( i, i ) / dconjg( akm1k )
307 ak = a( i+1, i+1 ) / akm1k
308 denom = akm1*ak - one
310 bkm1 = b( i, j ) / dconjg( akm1k )
311 bk = b( i+1, j ) / akm1k
312 b( i, j ) = ( ak*bkm1-bk ) / denom
313 b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
322 CALL ztrsm(
'L',
'L',
'C',
'U',n,nrhs,one,a,lda,b,ldb)
327 DO WHILE ( k .GE. 1 )
328 IF( ipiv( k ).GT.0 )
THEN
333 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
339 IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
340 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
349 CALL zsyconv( uplo,
'R', n, a, lda, ipiv, work, iinfo )