128 SUBROUTINE zsytrs2( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
137 INTEGER INFO, LDA, LDB, N, NRHS
141 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
148 parameter( one = (1.0d+0,0.0d+0) )
152 INTEGER I, IINFO, J, K, KP
153 COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
169 upper = lsame( uplo,
'U' )
170 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
172 ELSE IF( n.LT.0 )
THEN
174 ELSE IF( nrhs.LT.0 )
THEN
176 ELSE IF( lda.LT.max( 1, n ) )
THEN
178 ELSE IF( ldb.LT.max( 1, n ) )
THEN
182 CALL xerbla(
'ZSYTRS2', -info )
188 IF( n.EQ.0 .OR. nrhs.EQ.0 )
193 CALL zsyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
201 DO WHILE ( k .GE. 1 )
202 IF( ipiv( k ).GT.0 )
THEN
207 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
213 IF( kp.EQ.-ipiv( k-1 ) )
214 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
221 CALL ztrsm(
'L',
'U',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
226 DO WHILE ( i .GE. 1 )
227 IF( ipiv(i) .GT. 0 )
THEN
228 CALL zscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
229 ELSEIF ( i .GT. 1)
THEN
230 IF ( ipiv(i-1) .EQ. ipiv(i) )
THEN
232 akm1 = a( i-1, i-1 ) / akm1k
233 ak = a( i, i ) / akm1k
234 denom = akm1*ak - one
236 bkm1 = b( i-1, j ) / akm1k
237 bk = b( i, j ) / akm1k
238 b( i-1, j ) = ( ak*bkm1-bk ) / denom
239 b( i, j ) = ( akm1*bk-bkm1 ) / denom
249 CALL ztrsm(
'L',
'U',
'T',
'U',n,nrhs,one,a,lda,b,ldb)
254 DO WHILE ( k .LE. n )
255 IF( ipiv( k ).GT.0 )
THEN
260 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
266 IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
267 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
278 DO WHILE ( k .LE. n )
279 IF( ipiv( k ).GT.0 )
THEN
284 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
290 IF( kp.EQ.-ipiv( k ) )
291 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
298 CALL ztrsm(
'L',
'L',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
303 DO WHILE ( i .LE. n )
304 IF( ipiv(i) .GT. 0 )
THEN
305 CALL zscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
308 akm1 = a( i, i ) / akm1k
309 ak = a( i+1, i+1 ) / akm1k
310 denom = akm1*ak - one
312 bkm1 = b( i, j ) / akm1k
313 bk = b( i+1, j ) / akm1k
314 b( i, j ) = ( ak*bkm1-bk ) / denom
315 b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
324 CALL ztrsm(
'L',
'L',
'T',
'U',n,nrhs,one,a,lda,b,ldb)
329 DO WHILE ( k .GE. 1 )
330 IF( ipiv( k ).GT.0 )
THEN
335 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
341 IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
342 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
351 CALL zsyconv( uplo,
'R', n, a, lda, ipiv, work, iinfo )