LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
zpstf2.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine zpstf2 (UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO)
 ZPSTF2 computes the Cholesky factorization with complete pivoting of a real symmetric or complex Hermitian positive semi-definite matrix. More...
 

Function/Subroutine Documentation

subroutine zpstf2 ( character  UPLO,
integer  N,
complex*16, dimension( lda, * )  A,
integer  LDA,
integer, dimension( n )  PIV,
integer  RANK,
double precision  TOL,
double precision, dimension( 2*n )  WORK,
integer  INFO 
)

ZPSTF2 computes the Cholesky factorization with complete pivoting of a real symmetric or complex Hermitian positive semi-definite matrix.

Download ZPSTF2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 ZPSTF2 computes the Cholesky factorization with complete
 pivoting of a complex Hermitian positive semidefinite matrix A.

 The factorization has the form
    P**T * A * P = U**H * U ,  if UPLO = 'U',
    P**T * A * P = L  * L**H,  if UPLO = 'L',
 where U is an upper triangular matrix and L is lower triangular, and
 P is stored as vector PIV.

 This algorithm does not attempt to check that A is positive
 semidefinite. This version of the algorithm calls level 2 BLAS.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the upper or lower triangular part of the
          symmetric matrix A is stored.
          = 'U':  Upper triangular
          = 'L':  Lower triangular
[in]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in,out]A
          A is COMPLEX*16 array, dimension (LDA,N)
          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
          n by n upper triangular part of A contains the upper
          triangular part of the matrix A, and the strictly lower
          triangular part of A is not referenced.  If UPLO = 'L', the
          leading n by n lower triangular part of A contains the lower
          triangular part of the matrix A, and the strictly upper
          triangular part of A is not referenced.

          On exit, if INFO = 0, the factor U or L from the Cholesky
          factorization as above.
[out]PIV
          PIV is INTEGER array, dimension (N)
          PIV is such that the nonzero entries are P( PIV(K), K ) = 1.
[out]RANK
          RANK is INTEGER
          The rank of A given by the number of steps the algorithm
          completed.
[in]TOL
          TOL is DOUBLE PRECISION
          User defined tolerance. If TOL < 0, then N*U*MAX( A( K,K ) )
          will be used. The algorithm terminates at the (K-1)st step
          if the pivot <= TOL.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (2*N)
          Work space.
[out]INFO
          INFO is INTEGER
          < 0: If INFO = -K, the K-th argument had an illegal value,
          = 0: algorithm completed successfully, and
          > 0: the matrix A is either rank deficient with computed rank
               as returned in RANK, or is indefinite.  See Section 7 of
               LAPACK Working Note #161 for further information.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012

Definition at line 143 of file zpstf2.f.

143 *
144 * -- LAPACK computational routine (version 3.4.2) --
145 * -- LAPACK is a software package provided by Univ. of Tennessee, --
146 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
147 * September 2012
148 *
149 * .. Scalar Arguments ..
150  DOUBLE PRECISION tol
151  INTEGER info, lda, n, rank
152  CHARACTER uplo
153 * ..
154 * .. Array Arguments ..
155  COMPLEX*16 a( lda, * )
156  DOUBLE PRECISION work( 2*n )
157  INTEGER piv( n )
158 * ..
159 *
160 * =====================================================================
161 *
162 * .. Parameters ..
163  DOUBLE PRECISION one, zero
164  parameter( one = 1.0d+0, zero = 0.0d+0 )
165  COMPLEX*16 cone
166  parameter( cone = ( 1.0d+0, 0.0d+0 ) )
167 * ..
168 * .. Local Scalars ..
169  COMPLEX*16 ztemp
170  DOUBLE PRECISION ajj, dstop, dtemp
171  INTEGER i, itemp, j, pvt
172  LOGICAL upper
173 * ..
174 * .. External Functions ..
175  DOUBLE PRECISION dlamch
176  LOGICAL lsame, disnan
177  EXTERNAL dlamch, lsame, disnan
178 * ..
179 * .. External Subroutines ..
180  EXTERNAL zdscal, zgemv, zlacgv, zswap, xerbla
181 * ..
182 * .. Intrinsic Functions ..
183  INTRINSIC dble, dconjg, max, sqrt
184 * ..
185 * .. Executable Statements ..
186 *
187 * Test the input parameters
188 *
189  info = 0
190  upper = lsame( uplo, 'U' )
191  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
192  info = -1
193  ELSE IF( n.LT.0 ) THEN
194  info = -2
195  ELSE IF( lda.LT.max( 1, n ) ) THEN
196  info = -4
197  END IF
198  IF( info.NE.0 ) THEN
199  CALL xerbla( 'ZPSTF2', -info )
200  RETURN
201  END IF
202 *
203 * Quick return if possible
204 *
205  IF( n.EQ.0 )
206  $ RETURN
207 *
208 * Initialize PIV
209 *
210  DO 100 i = 1, n
211  piv( i ) = i
212  100 CONTINUE
213 *
214 * Compute stopping value
215 *
216  DO 110 i = 1, n
217  work( i ) = dble( a( i, i ) )
218  110 CONTINUE
219  pvt = maxloc( work( 1:n ), 1 )
220  ajj = dble( a( pvt, pvt ) )
221  IF( ajj.EQ.zero.OR.disnan( ajj ) ) THEN
222  rank = 0
223  info = 1
224  GO TO 200
225  END IF
226 *
227 * Compute stopping value if not supplied
228 *
229  IF( tol.LT.zero ) THEN
230  dstop = n * dlamch( 'Epsilon' ) * ajj
231  ELSE
232  dstop = tol
233  END IF
234 *
235 * Set first half of WORK to zero, holds dot products
236 *
237  DO 120 i = 1, n
238  work( i ) = 0
239  120 CONTINUE
240 *
241  IF( upper ) THEN
242 *
243 * Compute the Cholesky factorization P**T * A * P = U**H* U
244 *
245  DO 150 j = 1, n
246 *
247 * Find pivot, test for exit, else swap rows and columns
248 * Update dot products, compute possible pivots which are
249 * stored in the second half of WORK
250 *
251  DO 130 i = j, n
252 *
253  IF( j.GT.1 ) THEN
254  work( i ) = work( i ) +
255  $ dble( dconjg( a( j-1, i ) )*
256  $ a( j-1, i ) )
257  END IF
258  work( n+i ) = dble( a( i, i ) ) - work( i )
259 *
260  130 CONTINUE
261 *
262  IF( j.GT.1 ) THEN
263  itemp = maxloc( work( (n+j):(2*n) ), 1 )
264  pvt = itemp + j - 1
265  ajj = work( n+pvt )
266  IF( ajj.LE.dstop.OR.disnan( ajj ) ) THEN
267  a( j, j ) = ajj
268  GO TO 190
269  END IF
270  END IF
271 *
272  IF( j.NE.pvt ) THEN
273 *
274 * Pivot OK, so can now swap pivot rows and columns
275 *
276  a( pvt, pvt ) = a( j, j )
277  CALL zswap( j-1, a( 1, j ), 1, a( 1, pvt ), 1 )
278  IF( pvt.LT.n )
279  $ CALL zswap( n-pvt, a( j, pvt+1 ), lda,
280  $ a( pvt, pvt+1 ), lda )
281  DO 140 i = j + 1, pvt - 1
282  ztemp = dconjg( a( j, i ) )
283  a( j, i ) = dconjg( a( i, pvt ) )
284  a( i, pvt ) = ztemp
285  140 CONTINUE
286  a( j, pvt ) = dconjg( a( j, pvt ) )
287 *
288 * Swap dot products and PIV
289 *
290  dtemp = work( j )
291  work( j ) = work( pvt )
292  work( pvt ) = dtemp
293  itemp = piv( pvt )
294  piv( pvt ) = piv( j )
295  piv( j ) = itemp
296  END IF
297 *
298  ajj = sqrt( ajj )
299  a( j, j ) = ajj
300 *
301 * Compute elements J+1:N of row J
302 *
303  IF( j.LT.n ) THEN
304  CALL zlacgv( j-1, a( 1, j ), 1 )
305  CALL zgemv( 'Trans', j-1, n-j, -cone, a( 1, j+1 ), lda,
306  $ a( 1, j ), 1, cone, a( j, j+1 ), lda )
307  CALL zlacgv( j-1, a( 1, j ), 1 )
308  CALL zdscal( n-j, one / ajj, a( j, j+1 ), lda )
309  END IF
310 *
311  150 CONTINUE
312 *
313  ELSE
314 *
315 * Compute the Cholesky factorization P**T * A * P = L * L**H
316 *
317  DO 180 j = 1, n
318 *
319 * Find pivot, test for exit, else swap rows and columns
320 * Update dot products, compute possible pivots which are
321 * stored in the second half of WORK
322 *
323  DO 160 i = j, n
324 *
325  IF( j.GT.1 ) THEN
326  work( i ) = work( i ) +
327  $ dble( dconjg( a( i, j-1 ) )*
328  $ a( i, j-1 ) )
329  END IF
330  work( n+i ) = dble( a( i, i ) ) - work( i )
331 *
332  160 CONTINUE
333 *
334  IF( j.GT.1 ) THEN
335  itemp = maxloc( work( (n+j):(2*n) ), 1 )
336  pvt = itemp + j - 1
337  ajj = work( n+pvt )
338  IF( ajj.LE.dstop.OR.disnan( ajj ) ) THEN
339  a( j, j ) = ajj
340  GO TO 190
341  END IF
342  END IF
343 *
344  IF( j.NE.pvt ) THEN
345 *
346 * Pivot OK, so can now swap pivot rows and columns
347 *
348  a( pvt, pvt ) = a( j, j )
349  CALL zswap( j-1, a( j, 1 ), lda, a( pvt, 1 ), lda )
350  IF( pvt.LT.n )
351  $ CALL zswap( n-pvt, a( pvt+1, j ), 1, a( pvt+1, pvt ),
352  $ 1 )
353  DO 170 i = j + 1, pvt - 1
354  ztemp = dconjg( a( i, j ) )
355  a( i, j ) = dconjg( a( pvt, i ) )
356  a( pvt, i ) = ztemp
357  170 CONTINUE
358  a( pvt, j ) = dconjg( a( pvt, j ) )
359 *
360 * Swap dot products and PIV
361 *
362  dtemp = work( j )
363  work( j ) = work( pvt )
364  work( pvt ) = dtemp
365  itemp = piv( pvt )
366  piv( pvt ) = piv( j )
367  piv( j ) = itemp
368  END IF
369 *
370  ajj = sqrt( ajj )
371  a( j, j ) = ajj
372 *
373 * Compute elements J+1:N of column J
374 *
375  IF( j.LT.n ) THEN
376  CALL zlacgv( j-1, a( j, 1 ), lda )
377  CALL zgemv( '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 zlacgv( j-1, a( j, 1 ), lda )
380  CALL zdscal( n-j, one / ajj, a( j+1, j ), 1 )
381  END IF
382 *
383  180 CONTINUE
384 *
385  END IF
386 *
387 * Ran to completion, A has full rank
388 *
389  rank = n
390 *
391  GO TO 200
392  190 CONTINUE
393 *
394 * Rank is number of steps completed. Set INFO = 1 to signal
395 * that the factorization cannot be used to solve a system.
396 *
397  rank = j - 1
398  info = 1
399 *
400  200 CONTINUE
401  RETURN
402 *
403 * End of ZPSTF2
404 *
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
Definition: zswap.f:52
subroutine zgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
ZGEMV
Definition: zgemv.f:160
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
Definition: zdscal.f:54
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine zlacgv(N, X, INCX)
ZLACGV conjugates a complex vector.
Definition: zlacgv.f:76
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
logical function disnan(DIN)
DISNAN tests input for NaN.
Definition: disnan.f:61

Here is the call graph for this function:

Here is the caller graph for this function: