139 SUBROUTINE cpstf2( UPLO, N, A, LDA, PIV, RANK, TOL, WORK,
148 INTEGER INFO, LDA, N, RANK
161 parameter( one = 1.0e+0, zero = 0.0e+0 )
163 parameter( cone = ( 1.0e+0, 0.0e+0 ) )
167 REAL AJJ, SSTOP, STEMP
168 INTEGER I, ITEMP, J, PVT
173 LOGICAL LSAME, SISNAN
174 EXTERNAL slamch, lsame, sisnan
181 INTRINSIC conjg, max, real, sqrt
188 upper = lsame( uplo,
'U' )
189 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
191 ELSE IF( n.LT.0 )
THEN
193 ELSE IF( lda.LT.max( 1, n ) )
THEN
197 CALL xerbla(
'CPSTF2', -info )
215 work( i ) = real( a( i, i ) )
217 pvt = maxloc( work( 1:n ), 1 )
218 ajj = real( a( pvt, pvt ) )
219 IF( ajj.LE.zero.OR.sisnan( ajj ) )
THEN
227 IF( tol.LT.zero )
THEN
228 sstop = real( n ) * slamch(
'Epsilon' ) * ajj
252 work( i ) = work( i ) +
253 $ real( conjg( a( j-1, i ) )*
256 work( n+i ) = real( a( i, i ) ) - work( i )
261 itemp = maxloc( work( (n+j):(2*n) ), 1 )
264 IF( ajj.LE.sstop.OR.sisnan( ajj ) )
THEN
274 a( pvt, pvt ) = a( j, j )
275 CALL cswap( j-1, a( 1, j ), 1, a( 1, pvt ), 1 )
277 $
CALL cswap( n-pvt, a( j, pvt+1 ), lda,
278 $ a( pvt, pvt+1 ), lda )
279 DO 140 i = j + 1, pvt - 1
280 ctemp = conjg( a( j, i ) )
281 a( j, i ) = conjg( a( i, pvt ) )
284 a( j, pvt ) = conjg( a( j, pvt ) )
289 work( j ) = work( pvt )
292 piv( pvt ) = piv( j )
302 CALL clacgv( j-1, a( 1, j ), 1 )
303 CALL cgemv(
'Trans', j-1, n-j, -cone, a( 1, j+1 ),
305 $ a( 1, j ), 1, cone, a( j, j+1 ), lda )
306 CALL clacgv( j-1, a( 1, j ), 1 )
307 CALL csscal( n-j, one / ajj, a( j, j+1 ), lda )
325 work( i ) = work( i ) +
326 $ real( conjg( a( i, j-1 ) )*
329 work( n+i ) = real( a( i, i ) ) - work( i )
334 itemp = maxloc( work( (n+j):(2*n) ), 1 )
337 IF( ajj.LE.sstop.OR.sisnan( ajj ) )
THEN
347 a( pvt, pvt ) = a( j, j )
348 CALL cswap( j-1, a( j, 1 ), lda, a( pvt, 1 ), lda )
350 $
CALL cswap( n-pvt, a( pvt+1, j ), 1, a( pvt+1,
353 DO 170 i = j + 1, pvt - 1
354 ctemp = conjg( a( i, j ) )
355 a( i, j ) = conjg( a( pvt, i ) )
358 a( pvt, j ) = conjg( a( pvt, j ) )
363 work( j ) = work( pvt )
366 piv( pvt ) = piv( j )
376 CALL clacgv( j-1, a( j, 1 ), lda )
377 CALL cgemv(
'No Trans', n-j, j-1, -cone, a( j+1, 1 ),
378 $ lda, a( j, 1 ), lda, cone, a( j+1, j ), 1 )
379 CALL clacgv( j-1, a( j, 1 ), lda )
380 CALL csscal( n-j, one / ajj, a( j+1, j ), 1 )