 LAPACK  3.10.1 LAPACK: Linear Algebra PACKage

## ◆ cpstrf()

 subroutine cpstrf ( character UPLO, integer N, complex, dimension( lda, * ) A, integer LDA, integer, dimension( n ) PIV, integer RANK, real TOL, real, dimension( 2*n ) WORK, integer INFO )

CPSTRF computes the Cholesky factorization with complete pivoting of complex Hermitian positive semidefinite matrix.

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

Purpose:
``` CPSTRF 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 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 REAL 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 REAL 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.```

Definition at line 141 of file cpstrf.f.

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