LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ zpstrf()

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 computes the Cholesky factorization with complete pivoting of a complex Hermitian positive semidefinite matrix.

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 not positive semidefinite. 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
December 2016

Definition at line 144 of file zpstrf.f.

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