125 SUBROUTINE chetrs2( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
134 INTEGER INFO, LDA, LDB, N, NRHS
138 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
145 parameter( one = (1.0e+0,0.0e+0) )
149 INTEGER I, IINFO, J, K, KP
151 COMPLEX AK, AKM1, AKM1K, BK, BKM1, DENOM
161 INTRINSIC conjg, max, real
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(
'CHETRS2', -info )
185 IF( n.EQ.0 .OR. nrhs.EQ.0 )
190 CALL csyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
198 DO WHILE ( k .GE. 1 )
199 IF( ipiv( k ).GT.0 )
THEN
204 $
CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
210 IF( kp.EQ.-ipiv( k-1 ) )
211 $
CALL cswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
218 CALL ctrsm(
'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 = real( one ) / real( a( i, i ) )
226 CALL csscal( 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 ) / conjg( akm1k )
232 denom = akm1*ak - one
234 bkm1 = b( i-1, j ) / akm1k
235 bk = b( i, j ) / conjg( akm1k )
236 b( i-1, j ) = ( ak*bkm1-bk ) / denom
237 b( i, j ) = ( akm1*bk-bkm1 ) / denom
247 CALL ctrsm(
'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 cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
264 IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
265 $
CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
276 DO WHILE ( k .LE. n )
277 IF( ipiv( k ).GT.0 )
THEN
282 $
CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
288 IF( kp.EQ.-ipiv( k ) )
289 $
CALL cswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
296 CALL ctrsm(
'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 = real( one ) / real( a( i, i ) )
304 CALL csscal( nrhs, s, b( i, 1 ), ldb )
307 akm1 = a( i, i ) / conjg( akm1k )
308 ak = a( i+1, i+1 ) / akm1k
309 denom = akm1*ak - one
311 bkm1 = b( i, j ) / conjg( 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 ctrsm(
'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 cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
340 IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
341 $
CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
350 CALL csyconv( uplo,
'R', n, a, lda, ipiv, work, iinfo )
subroutine xerbla(srname, info)
subroutine chetrs2(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, info)
CHETRS2
subroutine csscal(n, sa, cx, incx)
CSSCAL
subroutine cswap(n, cx, incx, cy, incy)
CSWAP
subroutine csyconv(uplo, way, n, a, lda, ipiv, e, info)
CSYCONV
subroutine ctrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
CTRSM