LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zpstrf.f
Go to the documentation of this file.
1*> \brief \b ZPSTRF computes the Cholesky factorization with complete pivoting of a complex Hermitian positive semidefinite matrix.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZPSTRF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpstrf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpstrf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpstrf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZPSTRF( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
20*
21* .. Scalar Arguments ..
22* DOUBLE PRECISION TOL
23* INTEGER INFO, LDA, N, RANK
24* CHARACTER UPLO
25* ..
26* .. Array Arguments ..
27* COMPLEX*16 A( LDA, * )
28* DOUBLE PRECISION WORK( 2*N )
29* INTEGER PIV( N )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> ZPSTRF computes the Cholesky factorization with complete
39*> pivoting of a complex Hermitian positive semidefinite matrix A.
40*>
41*> The factorization has the form
42*> P**T * A * P = U**H * U , if UPLO = 'U',
43*> P**T * A * P = L * L**H, if UPLO = 'L',
44*> where U is an upper triangular matrix and L is lower triangular, and
45*> P is stored as vector PIV.
46*>
47*> This algorithm does not attempt to check that A is positive
48*> semidefinite. This version of the algorithm calls level 3 BLAS.
49*> \endverbatim
50*
51* Arguments:
52* ==========
53*
54*> \param[in] UPLO
55*> \verbatim
56*> UPLO is CHARACTER*1
57*> Specifies whether the upper or lower triangular part of the
58*> symmetric matrix A is stored.
59*> = 'U': Upper triangular
60*> = 'L': Lower triangular
61*> \endverbatim
62*>
63*> \param[in] N
64*> \verbatim
65*> N is INTEGER
66*> The order of the matrix A. N >= 0.
67*> \endverbatim
68*>
69*> \param[in,out] A
70*> \verbatim
71*> A is COMPLEX*16 array, dimension (LDA,N)
72*> On entry, the symmetric matrix A. If UPLO = 'U', the leading
73*> n by n upper triangular part of A contains the upper
74*> triangular part of the matrix A, and the strictly lower
75*> triangular part of A is not referenced. If UPLO = 'L', the
76*> leading n by n lower triangular part of A contains the lower
77*> triangular part of the matrix A, and the strictly upper
78*> triangular part of A is not referenced.
79*>
80*> On exit, if INFO = 0, the factor U or L from the Cholesky
81*> factorization as above.
82*> \endverbatim
83*>
84*> \param[in] LDA
85*> \verbatim
86*> LDA is INTEGER
87*> The leading dimension of the array A. LDA >= max(1,N).
88*> \endverbatim
89*>
90*> \param[out] PIV
91*> \verbatim
92*> PIV is INTEGER array, dimension (N)
93*> PIV is such that the nonzero entries are P( PIV(K), K ) = 1.
94*> \endverbatim
95*>
96*> \param[out] RANK
97*> \verbatim
98*> RANK is INTEGER
99*> The rank of A given by the number of steps the algorithm
100*> completed.
101*> \endverbatim
102*>
103*> \param[in] TOL
104*> \verbatim
105*> TOL is DOUBLE PRECISION
106*> User defined tolerance. If TOL < 0, then N*U*MAX( A(K,K) )
107*> will be used. The algorithm terminates at the (K-1)st step
108*> if the pivot <= TOL.
109*> \endverbatim
110*>
111*> \param[out] WORK
112*> \verbatim
113*> WORK is DOUBLE PRECISION array, dimension (2*N)
114*> Work space.
115*> \endverbatim
116*>
117*> \param[out] INFO
118*> \verbatim
119*> INFO is INTEGER
120*> < 0: If INFO = -K, the K-th argument had an illegal value,
121*> = 0: algorithm completed successfully, and
122*> > 0: the matrix A is either rank deficient with computed rank
123*> as returned in RANK, or is not positive semidefinite. See
124*> Section 7 of LAPACK Working Note #161 for further
125*> information.
126*> \endverbatim
127*
128* Authors:
129* ========
130*
131*> \author Univ. of Tennessee
132*> \author Univ. of California Berkeley
133*> \author Univ. of Colorado Denver
134*> \author NAG Ltd.
135*
136*> \ingroup pstrf
137*
138* =====================================================================
139 SUBROUTINE zpstrf( UPLO, N, A, LDA, PIV, RANK, TOL, WORK,
140 $ INFO )
141*
142* -- LAPACK computational routine --
143* -- LAPACK is a software package provided by Univ. of Tennessee, --
144* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
145*
146* .. Scalar Arguments ..
147 DOUBLE PRECISION TOL
148 INTEGER INFO, LDA, N, RANK
149 CHARACTER UPLO
150* ..
151* .. Array Arguments ..
152 COMPLEX*16 A( LDA, * )
153 DOUBLE PRECISION WORK( 2*N )
154 INTEGER PIV( N )
155* ..
156*
157* =====================================================================
158*
159* .. Parameters ..
160 DOUBLE PRECISION ONE, ZERO
161 parameter( one = 1.0d+0, zero = 0.0d+0 )
162 COMPLEX*16 CONE
163 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
164* ..
165* .. Local Scalars ..
166 COMPLEX*16 ZTEMP
167 DOUBLE PRECISION AJJ, DSTOP, DTEMP
168 INTEGER I, ITEMP, J, JB, K, NB, PVT
169 LOGICAL UPPER
170* ..
171* .. External Functions ..
172 DOUBLE PRECISION DLAMCH
173 INTEGER ILAENV
174 LOGICAL LSAME, DISNAN
175 EXTERNAL dlamch, ilaenv, lsame, disnan
176* ..
177* .. External Subroutines ..
178 EXTERNAL zdscal, zgemv, zherk, zlacgv, zpstf2,
179 $ zswap,
180 $ xerbla
181* ..
182* .. Intrinsic Functions ..
183 INTRINSIC dble, dconjg, max, min, 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( 'ZPSTRF', -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, 'ZPOTRF', uplo, n, -1, -1, -1 )
211 IF( nb.LE.1 .OR. nb.GE.n ) THEN
212*
213* Use unblocked code
214*
215 CALL zpstf2( 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 ) = dble( a( i, i ) )
231 110 CONTINUE
232 pvt = maxloc( work( 1:n ), 1 )
233 ajj = dble( a( pvt, pvt ) )
234 IF( ajj.LE.zero.OR.disnan( 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 dstop = n * dlamch( 'Epsilon' ) * ajj
244 ELSE
245 dstop = 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 $ dble( dconjg( a( j-1, i ) )*
277 $ a( j-1, i ) )
278 END IF
279 work( n+i ) = dble( 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.dstop.OR.disnan( 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 zswap( j-1, a( 1, j ), 1, a( 1, pvt ), 1 )
299 IF( pvt.LT.n )
300 $ CALL zswap( n-pvt, a( j, pvt+1 ), lda,
301 $ a( pvt, pvt+1 ), lda )
302 DO 140 i = j + 1, pvt - 1
303 ztemp = dconjg( a( j, i ) )
304 a( j, i ) = dconjg( a( i, pvt ) )
305 a( i, pvt ) = ztemp
306 140 CONTINUE
307 a( j, pvt ) = dconjg( a( j, pvt ) )
308*
309* Swap dot products and PIV
310*
311 dtemp = work( j )
312 work( j ) = work( pvt )
313 work( pvt ) = dtemp
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 zlacgv( j-1, a( 1, j ), 1 )
326 CALL zgemv( 'Trans', j-k, n-j, -cone, a( k,
327 $ j+1 ),
328 $ lda, a( k, j ), 1, cone, a( j, j+1 ),
329 $ lda )
330 CALL zlacgv( j-1, a( 1, j ), 1 )
331 CALL zdscal( n-j, one / ajj, a( j, j+1 ), lda )
332 END IF
333*
334 150 CONTINUE
335*
336* Update trailing matrix, J already incremented
337*
338 IF( k+jb.LE.n ) THEN
339 CALL zherk( 'Upper', 'Conj Trans', n-j+1, jb, -one,
340 $ a( k, j ), lda, one, a( j, j ), lda )
341 END IF
342*
343 160 CONTINUE
344*
345 ELSE
346*
347* Compute the Cholesky factorization P**T * A * P = L * L**H
348*
349 DO 210 k = 1, n, nb
350*
351* Account for last block not being NB wide
352*
353 jb = min( nb, n-k+1 )
354*
355* Set relevant part of first half of WORK to zero,
356* holds dot products
357*
358 DO 170 i = k, n
359 work( i ) = 0
360 170 CONTINUE
361*
362 DO 200 j = k, k + jb - 1
363*
364* Find pivot, test for exit, else swap rows and columns
365* Update dot products, compute possible pivots which are
366* stored in the second half of WORK
367*
368 DO 180 i = j, n
369*
370 IF( j.GT.k ) THEN
371 work( i ) = work( i ) +
372 $ dble( dconjg( a( i, j-1 ) )*
373 $ a( i, j-1 ) )
374 END IF
375 work( n+i ) = dble( a( i, i ) ) - work( i )
376*
377 180 CONTINUE
378*
379 IF( j.GT.1 ) THEN
380 itemp = maxloc( work( (n+j):(2*n) ), 1 )
381 pvt = itemp + j - 1
382 ajj = work( n+pvt )
383 IF( ajj.LE.dstop.OR.disnan( ajj ) ) THEN
384 a( j, j ) = ajj
385 GO TO 220
386 END IF
387 END IF
388*
389 IF( j.NE.pvt ) THEN
390*
391* Pivot OK, so can now swap pivot rows and columns
392*
393 a( pvt, pvt ) = a( j, j )
394 CALL zswap( j-1, a( j, 1 ), lda, a( pvt, 1 ),
395 $ 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*
463 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
Definition zgemv.f:160
subroutine zherk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
ZHERK
Definition zherk.f:173
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
Definition zlacgv.f:72
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:141
subroutine zpstrf(uplo, n, a, lda, piv, rank, tol, work, info)
ZPSTRF computes the Cholesky factorization with complete pivoting of a complex Hermitian positive sem...
Definition zpstrf.f:141
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
Definition zswap.f:81