00001 SUBROUTINE ZPSTRF( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 DOUBLE PRECISION TOL
00012 INTEGER INFO, LDA, N, RANK
00013 CHARACTER UPLO
00014
00015
00016 COMPLEX*16 A( LDA, * )
00017 DOUBLE PRECISION WORK( 2*N )
00018 INTEGER PIV( N )
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 DOUBLE PRECISION ONE, ZERO
00089 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00090 COMPLEX*16 CONE
00091 PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )
00092
00093
00094 COMPLEX*16 ZTEMP
00095 DOUBLE PRECISION AJJ, DSTOP, DTEMP
00096 INTEGER I, ITEMP, J, JB, K, NB, PVT
00097 LOGICAL UPPER
00098
00099
00100 DOUBLE PRECISION DLAMCH
00101 INTEGER ILAENV
00102 LOGICAL LSAME, DISNAN
00103 EXTERNAL DLAMCH, ILAENV, LSAME, DISNAN
00104
00105
00106 EXTERNAL ZDSCAL, ZGEMV, ZHERK, ZLACGV, ZPSTF2, ZSWAP,
00107 $ XERBLA
00108
00109
00110 INTRINSIC DBLE, DCONJG, MAX, MIN, SQRT, MAXLOC
00111
00112
00113
00114
00115
00116 INFO = 0
00117 UPPER = LSAME( UPLO, 'U' )
00118 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00119 INFO = -1
00120 ELSE IF( N.LT.0 ) THEN
00121 INFO = -2
00122 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00123 INFO = -4
00124 END IF
00125 IF( INFO.NE.0 ) THEN
00126 CALL XERBLA( 'ZPSTRF', -INFO )
00127 RETURN
00128 END IF
00129
00130
00131
00132 IF( N.EQ.0 )
00133 $ RETURN
00134
00135
00136
00137 NB = ILAENV( 1, 'ZPOTRF', UPLO, N, -1, -1, -1 )
00138 IF( NB.LE.1 .OR. NB.GE.N ) THEN
00139
00140
00141
00142 CALL ZPSTF2( UPLO, N, A( 1, 1 ), LDA, PIV, RANK, TOL, WORK,
00143 $ INFO )
00144 GO TO 230
00145
00146 ELSE
00147
00148
00149
00150 DO 100 I = 1, N
00151 PIV( I ) = I
00152 100 CONTINUE
00153
00154
00155
00156 DO 110 I = 1, N
00157 WORK( I ) = DBLE( A( I, I ) )
00158 110 CONTINUE
00159 PVT = MAXLOC( WORK( 1:N ), 1 )
00160 AJJ = DBLE( A( PVT, PVT ) )
00161 IF( AJJ.EQ.ZERO.OR.DISNAN( AJJ ) ) THEN
00162 RANK = 0
00163 INFO = 1
00164 GO TO 230
00165 END IF
00166
00167
00168
00169 IF( TOL.LT.ZERO ) THEN
00170 DSTOP = N * DLAMCH( 'Epsilon' ) * AJJ
00171 ELSE
00172 DSTOP = TOL
00173 END IF
00174
00175
00176 IF( UPPER ) THEN
00177
00178
00179
00180 DO 160 K = 1, N, NB
00181
00182
00183
00184 JB = MIN( NB, N-K+1 )
00185
00186
00187
00188
00189 DO 120 I = K, N
00190 WORK( I ) = 0
00191 120 CONTINUE
00192
00193 DO 150 J = K, K + JB - 1
00194
00195
00196
00197
00198
00199 DO 130 I = J, N
00200
00201 IF( J.GT.K ) THEN
00202 WORK( I ) = WORK( I ) +
00203 $ DBLE( DCONJG( A( J-1, I ) )*
00204 $ A( J-1, I ) )
00205 END IF
00206 WORK( N+I ) = DBLE( A( I, I ) ) - WORK( I )
00207
00208 130 CONTINUE
00209
00210 IF( J.GT.1 ) THEN
00211 ITEMP = MAXLOC( WORK( (N+J):(2*N) ), 1 )
00212 PVT = ITEMP + J - 1
00213 AJJ = WORK( N+PVT )
00214 IF( AJJ.LE.DSTOP.OR.DISNAN( AJJ ) ) THEN
00215 A( J, J ) = AJJ
00216 GO TO 220
00217 END IF
00218 END IF
00219
00220 IF( J.NE.PVT ) THEN
00221
00222
00223
00224 A( PVT, PVT ) = A( J, J )
00225 CALL ZSWAP( J-1, A( 1, J ), 1, A( 1, PVT ), 1 )
00226 IF( PVT.LT.N )
00227 $ CALL ZSWAP( N-PVT, A( J, PVT+1 ), LDA,
00228 $ A( PVT, PVT+1 ), LDA )
00229 DO 140 I = J + 1, PVT - 1
00230 ZTEMP = DCONJG( A( J, I ) )
00231 A( J, I ) = DCONJG( A( I, PVT ) )
00232 A( I, PVT ) = ZTEMP
00233 140 CONTINUE
00234 A( J, PVT ) = DCONJG( A( J, PVT ) )
00235
00236
00237
00238 DTEMP = WORK( J )
00239 WORK( J ) = WORK( PVT )
00240 WORK( PVT ) = DTEMP
00241 ITEMP = PIV( PVT )
00242 PIV( PVT ) = PIV( J )
00243 PIV( J ) = ITEMP
00244 END IF
00245
00246 AJJ = SQRT( AJJ )
00247 A( J, J ) = AJJ
00248
00249
00250
00251 IF( J.LT.N ) THEN
00252 CALL ZLACGV( J-1, A( 1, J ), 1 )
00253 CALL ZGEMV( 'Trans', J-K, N-J, -CONE, A( K, J+1 ),
00254 $ LDA, A( K, J ), 1, CONE, A( J, J+1 ),
00255 $ LDA )
00256 CALL ZLACGV( J-1, A( 1, J ), 1 )
00257 CALL ZDSCAL( N-J, ONE / AJJ, A( J, J+1 ), LDA )
00258 END IF
00259
00260 150 CONTINUE
00261
00262
00263
00264 IF( K+JB.LE.N ) THEN
00265 CALL ZHERK( 'Upper', 'Conj Trans', N-J+1, JB, -ONE,
00266 $ A( K, J ), LDA, ONE, A( J, J ), LDA )
00267 END IF
00268
00269 160 CONTINUE
00270
00271 ELSE
00272
00273
00274
00275 DO 210 K = 1, N, NB
00276
00277
00278
00279 JB = MIN( NB, N-K+1 )
00280
00281
00282
00283
00284 DO 170 I = K, N
00285 WORK( I ) = 0
00286 170 CONTINUE
00287
00288 DO 200 J = K, K + JB - 1
00289
00290
00291
00292
00293
00294 DO 180 I = J, N
00295
00296 IF( J.GT.K ) THEN
00297 WORK( I ) = WORK( I ) +
00298 $ DBLE( DCONJG( A( I, J-1 ) )*
00299 $ A( I, J-1 ) )
00300 END IF
00301 WORK( N+I ) = DBLE( A( I, I ) ) - WORK( I )
00302
00303 180 CONTINUE
00304
00305 IF( J.GT.1 ) THEN
00306 ITEMP = MAXLOC( WORK( (N+J):(2*N) ), 1 )
00307 PVT = ITEMP + J - 1
00308 AJJ = WORK( N+PVT )
00309 IF( AJJ.LE.DSTOP.OR.DISNAN( AJJ ) ) THEN
00310 A( J, J ) = AJJ
00311 GO TO 220
00312 END IF
00313 END IF
00314
00315 IF( J.NE.PVT ) THEN
00316
00317
00318
00319 A( PVT, PVT ) = A( J, J )
00320 CALL ZSWAP( J-1, A( J, 1 ), LDA, A( PVT, 1 ), LDA )
00321 IF( PVT.LT.N )
00322 $ CALL ZSWAP( N-PVT, A( PVT+1, J ), 1,
00323 $ A( PVT+1, PVT ), 1 )
00324 DO 190 I = J + 1, PVT - 1
00325 ZTEMP = DCONJG( A( I, J ) )
00326 A( I, J ) = DCONJG( A( PVT, I ) )
00327 A( PVT, I ) = ZTEMP
00328 190 CONTINUE
00329 A( PVT, J ) = DCONJG( A( PVT, J ) )
00330
00331
00332
00333
00334 DTEMP = WORK( J )
00335 WORK( J ) = WORK( PVT )
00336 WORK( PVT ) = DTEMP
00337 ITEMP = PIV( PVT )
00338 PIV( PVT ) = PIV( J )
00339 PIV( J ) = ITEMP
00340 END IF
00341
00342 AJJ = SQRT( AJJ )
00343 A( J, J ) = AJJ
00344
00345
00346
00347 IF( J.LT.N ) THEN
00348 CALL ZLACGV( J-1, A( J, 1 ), LDA )
00349 CALL ZGEMV( 'No Trans', N-J, J-K, -CONE,
00350 $ A( J+1, K ), LDA, A( J, K ), LDA, CONE,
00351 $ A( J+1, J ), 1 )
00352 CALL ZLACGV( J-1, A( J, 1 ), LDA )
00353 CALL ZDSCAL( N-J, ONE / AJJ, A( J+1, J ), 1 )
00354 END IF
00355
00356 200 CONTINUE
00357
00358
00359
00360 IF( K+JB.LE.N ) THEN
00361 CALL ZHERK( 'Lower', 'No Trans', N-J+1, JB, -ONE,
00362 $ A( J, K ), LDA, ONE, A( J, J ), LDA )
00363 END IF
00364
00365 210 CONTINUE
00366
00367 END IF
00368 END IF
00369
00370
00371
00372 RANK = N
00373
00374 GO TO 230
00375 220 CONTINUE
00376
00377
00378
00379
00380 RANK = J - 1
00381 INFO = 1
00382
00383 230 CONTINUE
00384 RETURN
00385
00386
00387
00388 END