130 SUBROUTINE zsytrs2( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
139 INTEGER INFO, LDA, LDB, N, NRHS
143 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
150 parameter( one = (1.0d+0,0.0d+0) )
154 INTEGER I, IINFO, J, K, KP
155 COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
170 upper = lsame( uplo,
'U' )
171 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
173 ELSE IF( n.LT.0 )
THEN
175 ELSE IF( nrhs.LT.0 )
THEN
177 ELSE IF( lda.LT.max( 1, n ) )
THEN
179 ELSE IF( ldb.LT.max( 1, n ) )
THEN
183 CALL xerbla(
'ZSYTRS2', -info )
189 IF( n.EQ.0 .OR. nrhs.EQ.0 )
194 CALL zsyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
202 DO WHILE ( k .GE. 1 )
203 IF( ipiv( k ).GT.0 )
THEN
208 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
214 IF( kp.EQ.-ipiv( k-1 ) )
215 $
CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
222 CALL ztrsm(
'L',
'U',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
227 DO WHILE ( i .GE. 1 )
228 IF( ipiv(i) .GT. 0 )
THEN
229 CALL zscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
230 ELSEIF ( i .GT. 1)
THEN
231 IF ( ipiv(i-1) .EQ. ipiv(i) )
THEN
233 akm1 = a( i-1, i-1 ) / akm1k
234 ak = a( i, i ) / akm1k
235 denom = akm1*ak - one
237 bkm1 = b( i-1, j ) / akm1k
238 bk = b( i, j ) / akm1k
239 b( i-1, j ) = ( ak*bkm1-bk ) / denom
240 b( i, j ) = ( akm1*bk-bkm1 ) / denom
250 CALL ztrsm(
'L',
'U',
'T',
'U',n,nrhs,one,a,lda,b,ldb)
255 DO WHILE ( k .LE. n )
256 IF( ipiv( k ).GT.0 )
THEN
261 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
267 IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
268 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
279 DO WHILE ( k .LE. n )
280 IF( ipiv( k ).GT.0 )
THEN
285 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
291 IF( kp.EQ.-ipiv( k ) )
292 $
CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
299 CALL ztrsm(
'L',
'L',
'N',
'U',n,nrhs,one,a,lda,b,ldb)
304 DO WHILE ( i .LE. n )
305 IF( ipiv(i) .GT. 0 )
THEN
306 CALL zscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
309 akm1 = a( i, i ) / akm1k
310 ak = a( i+1, i+1 ) / akm1k
311 denom = akm1*ak - one
313 bkm1 = b( i, j ) / akm1k
314 bk = b( i+1, j ) / akm1k
315 b( i, j ) = ( ak*bkm1-bk ) / denom
316 b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
325 CALL ztrsm(
'L',
'L',
'T',
'U',n,nrhs,one,a,lda,b,ldb)
330 DO WHILE ( k .GE. 1 )
331 IF( ipiv( k ).GT.0 )
THEN
336 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
342 IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
343 $
CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
352 CALL zsyconv( uplo,
'R', n, a, lda, ipiv, work, iinfo )
subroutine xerbla(srname, info)
subroutine zsytrs2(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, info)
ZSYTRS2
subroutine zscal(n, za, zx, incx)
ZSCAL
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