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

Go to the source code of this file.

Functions/Subroutines

subroutine zpstrf (UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO)
 ZPSTRF More...
 

Function/Subroutine Documentation

subroutine zpstrf ( 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 
)

ZPSTRF

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

Purpose:
 ZPSTRF 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 3 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.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[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.
[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
November 2011

Definition at line 143 of file zpstrf.f.

143 *
144 * -- LAPACK computational routine (version 3.4.0) --
145 * -- LAPACK is a software package provided by Univ. of Tennessee, --
146 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
147 * November 2011
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, jb, k, nb, pvt
172  LOGICAL upper
173 * ..
174 * .. External Functions ..
175  DOUBLE PRECISION dlamch
176  INTEGER ilaenv
177  LOGICAL lsame, disnan
178  EXTERNAL dlamch, ilaenv, lsame, disnan
179 * ..
180 * .. External Subroutines ..
181  EXTERNAL zdscal, zgemv, zherk, zlacgv, zpstf2, zswap,
182  $ xerbla
183 * ..
184 * .. Intrinsic Functions ..
185  INTRINSIC dble, dconjg, max, min, sqrt, maxloc
186 * ..
187 * .. Executable Statements ..
188 *
189 * Test the input parameters.
190 *
191  info = 0
192  upper = lsame( uplo, 'U' )
193  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
194  info = -1
195  ELSE IF( n.LT.0 ) THEN
196  info = -2
197  ELSE IF( lda.LT.max( 1, n ) ) THEN
198  info = -4
199  END IF
200  IF( info.NE.0 ) THEN
201  CALL xerbla( 'ZPSTRF', -info )
202  RETURN
203  END IF
204 *
205 * Quick return if possible
206 *
207  IF( n.EQ.0 )
208  $ RETURN
209 *
210 * Get block size
211 *
212  nb = ilaenv( 1, 'ZPOTRF', uplo, n, -1, -1, -1 )
213  IF( nb.LE.1 .OR. nb.GE.n ) THEN
214 *
215 * Use unblocked code
216 *
217  CALL zpstf2( uplo, n, a( 1, 1 ), lda, piv, rank, tol, work,
218  $ info )
219  GO TO 230
220 *
221  ELSE
222 *
223 * Initialize PIV
224 *
225  DO 100 i = 1, n
226  piv( i ) = i
227  100 CONTINUE
228 *
229 * Compute stopping value
230 *
231  DO 110 i = 1, n
232  work( i ) = dble( a( i, i ) )
233  110 CONTINUE
234  pvt = maxloc( work( 1:n ), 1 )
235  ajj = dble( a( pvt, pvt ) )
236  IF( ajj.EQ.zero.OR.disnan( ajj ) ) THEN
237  rank = 0
238  info = 1
239  GO TO 230
240  END IF
241 *
242 * Compute stopping value if not supplied
243 *
244  IF( tol.LT.zero ) THEN
245  dstop = n * dlamch( 'Epsilon' ) * ajj
246  ELSE
247  dstop = tol
248  END IF
249 *
250 *
251  IF( upper ) THEN
252 *
253 * Compute the Cholesky factorization P**T * A * P = U**H * U
254 *
255  DO 160 k = 1, n, nb
256 *
257 * Account for last block not being NB wide
258 *
259  jb = min( nb, n-k+1 )
260 *
261 * Set relevant part of first half of WORK to zero,
262 * holds dot products
263 *
264  DO 120 i = k, n
265  work( i ) = 0
266  120 CONTINUE
267 *
268  DO 150 j = k, k + jb - 1
269 *
270 * Find pivot, test for exit, else swap rows and columns
271 * Update dot products, compute possible pivots which are
272 * stored in the second half of WORK
273 *
274  DO 130 i = j, n
275 *
276  IF( j.GT.k ) THEN
277  work( i ) = work( i ) +
278  $ dble( dconjg( a( j-1, i ) )*
279  $ a( j-1, i ) )
280  END IF
281  work( n+i ) = dble( a( i, i ) ) - work( i )
282 *
283  130 CONTINUE
284 *
285  IF( j.GT.1 ) THEN
286  itemp = maxloc( work( (n+j):(2*n) ), 1 )
287  pvt = itemp + j - 1
288  ajj = work( n+pvt )
289  IF( ajj.LE.dstop.OR.disnan( ajj ) ) THEN
290  a( j, j ) = ajj
291  GO TO 220
292  END IF
293  END IF
294 *
295  IF( j.NE.pvt ) THEN
296 *
297 * Pivot OK, so can now swap pivot rows and columns
298 *
299  a( pvt, pvt ) = a( j, j )
300  CALL zswap( j-1, a( 1, j ), 1, a( 1, pvt ), 1 )
301  IF( pvt.LT.n )
302  $ CALL zswap( n-pvt, a( j, pvt+1 ), lda,
303  $ a( pvt, pvt+1 ), lda )
304  DO 140 i = j + 1, pvt - 1
305  ztemp = dconjg( a( j, i ) )
306  a( j, i ) = dconjg( a( i, pvt ) )
307  a( i, pvt ) = ztemp
308  140 CONTINUE
309  a( j, pvt ) = dconjg( a( j, pvt ) )
310 *
311 * Swap dot products and PIV
312 *
313  dtemp = work( j )
314  work( j ) = work( pvt )
315  work( pvt ) = dtemp
316  itemp = piv( pvt )
317  piv( pvt ) = piv( j )
318  piv( j ) = itemp
319  END IF
320 *
321  ajj = sqrt( ajj )
322  a( j, j ) = ajj
323 *
324 * Compute elements J+1:N of row J.
325 *
326  IF( j.LT.n ) THEN
327  CALL zlacgv( j-1, a( 1, j ), 1 )
328  CALL zgemv( 'Trans', j-k, n-j, -cone, a( k, j+1 ),
329  $ lda, a( k, j ), 1, cone, a( j, j+1 ),
330  $ lda )
331  CALL zlacgv( j-1, a( 1, j ), 1 )
332  CALL zdscal( n-j, one / ajj, a( j, j+1 ), lda )
333  END IF
334 *
335  150 CONTINUE
336 *
337 * Update trailing matrix, J already incremented
338 *
339  IF( k+jb.LE.n ) THEN
340  CALL zherk( 'Upper', 'Conj Trans', n-j+1, jb, -one,
341  $ a( k, j ), lda, one, a( j, j ), lda )
342  END IF
343 *
344  160 CONTINUE
345 *
346  ELSE
347 *
348 * Compute the Cholesky factorization P**T * A * P = L * L**H
349 *
350  DO 210 k = 1, n, nb
351 *
352 * Account for last block not being NB wide
353 *
354  jb = min( nb, n-k+1 )
355 *
356 * Set relevant part of first half of WORK to zero,
357 * holds dot products
358 *
359  DO 170 i = k, n
360  work( i ) = 0
361  170 CONTINUE
362 *
363  DO 200 j = k, k + jb - 1
364 *
365 * Find pivot, test for exit, else swap rows and columns
366 * Update dot products, compute possible pivots which are
367 * stored in the second half of WORK
368 *
369  DO 180 i = j, n
370 *
371  IF( j.GT.k ) THEN
372  work( i ) = work( i ) +
373  $ dble( dconjg( a( i, j-1 ) )*
374  $ a( i, j-1 ) )
375  END IF
376  work( n+i ) = dble( a( i, i ) ) - work( i )
377 *
378  180 CONTINUE
379 *
380  IF( j.GT.1 ) THEN
381  itemp = maxloc( work( (n+j):(2*n) ), 1 )
382  pvt = itemp + j - 1
383  ajj = work( n+pvt )
384  IF( ajj.LE.dstop.OR.disnan( ajj ) ) THEN
385  a( j, j ) = ajj
386  GO TO 220
387  END IF
388  END IF
389 *
390  IF( j.NE.pvt ) THEN
391 *
392 * Pivot OK, so can now swap pivot rows and columns
393 *
394  a( pvt, pvt ) = a( j, j )
395  CALL zswap( j-1, a( j, 1 ), lda, a( pvt, 1 ), lda )
396  IF( pvt.LT.n )
397  $ CALL zswap( n-pvt, a( pvt+1, j ), 1,
398  $ a( pvt+1, pvt ), 1 )
399  DO 190 i = j + 1, pvt - 1
400  ztemp = dconjg( a( i, j ) )
401  a( i, j ) = dconjg( a( pvt, i ) )
402  a( pvt, i ) = ztemp
403  190 CONTINUE
404  a( pvt, j ) = dconjg( a( pvt, j ) )
405 *
406 *
407 * Swap dot products and PIV
408 *
409  dtemp = work( j )
410  work( j ) = work( pvt )
411  work( pvt ) = dtemp
412  itemp = piv( pvt )
413  piv( pvt ) = piv( j )
414  piv( j ) = itemp
415  END IF
416 *
417  ajj = sqrt( ajj )
418  a( j, j ) = ajj
419 *
420 * Compute elements J+1:N of column J.
421 *
422  IF( j.LT.n ) THEN
423  CALL zlacgv( j-1, a( j, 1 ), lda )
424  CALL zgemv( 'No Trans', n-j, j-k, -cone,
425  $ a( j+1, k ), lda, a( j, k ), lda, cone,
426  $ a( j+1, j ), 1 )
427  CALL zlacgv( j-1, a( j, 1 ), lda )
428  CALL zdscal( n-j, one / ajj, a( j+1, j ), 1 )
429  END IF
430 *
431  200 CONTINUE
432 *
433 * Update trailing matrix, J already incremented
434 *
435  IF( k+jb.LE.n ) THEN
436  CALL zherk( 'Lower', 'No Trans', n-j+1, jb, -one,
437  $ a( j, k ), lda, one, a( j, j ), lda )
438  END IF
439 *
440  210 CONTINUE
441 *
442  END IF
443  END IF
444 *
445 * Ran to completion, A has full rank
446 *
447  rank = n
448 *
449  GO TO 230
450  220 CONTINUE
451 *
452 * Rank is the number of steps completed. Set INFO = 1 to signal
453 * that the factorization cannot be used to solve a system.
454 *
455  rank = j - 1
456  info = 1
457 *
458  230 CONTINUE
459  RETURN
460 *
461 * End of ZPSTRF
462 *
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
Definition: zswap.f:52
subroutine zherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
ZHERK
Definition: zherk.f:175
subroutine zgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
ZGEMV
Definition: zgemv.f:160
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 Herm...
Definition: zpstf2.f:143
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
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
Definition: tstiee.f:83
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: