1: *> \brief \b ZPSTRF
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download ZPSTRF + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpstrf.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpstrf.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpstrf.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE ZPSTRF( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
22: *
23: * .. Scalar Arguments ..
24: * DOUBLE PRECISION TOL
25: * INTEGER INFO, LDA, N, RANK
26: * CHARACTER UPLO
27: * ..
28: * .. Array Arguments ..
29: * COMPLEX*16 A( LDA, * )
30: * DOUBLE PRECISION WORK( 2*N )
31: * INTEGER PIV( N )
32: * ..
33: *
34: *
35: *> \par Purpose:
36: * =============
37: *>
38: *> \verbatim
39: *>
40: *> ZPSTRF computes the Cholesky factorization with complete
41: *> pivoting of a complex Hermitian positive semidefinite matrix A.
42: *>
43: *> The factorization has the form
44: *> P**T * A * P = U**H * U , if UPLO = 'U',
45: *> P**T * A * P = L * L**H, if UPLO = 'L',
46: *> where U is an upper triangular matrix and L is lower triangular, and
47: *> P is stored as vector PIV.
48: *>
49: *> This algorithm does not attempt to check that A is positive
50: *> semidefinite. This version of the algorithm calls level 3 BLAS.
51: *> \endverbatim
52: *
53: * Arguments:
54: * ==========
55: *
56: *> \param[in] UPLO
57: *> \verbatim
58: *> UPLO is CHARACTER*1
59: *> Specifies whether the upper or lower triangular part of the
60: *> symmetric matrix A is stored.
61: *> = 'U': Upper triangular
62: *> = 'L': Lower triangular
63: *> \endverbatim
64: *>
65: *> \param[in] N
66: *> \verbatim
67: *> N is INTEGER
68: *> The order of the matrix A. N >= 0.
69: *> \endverbatim
70: *>
71: *> \param[in,out] A
72: *> \verbatim
73: *> A is COMPLEX*16 array, dimension (LDA,N)
74: *> On entry, the symmetric matrix A. If UPLO = 'U', the leading
75: *> n by n upper triangular part of A contains the upper
76: *> triangular part of the matrix A, and the strictly lower
77: *> triangular part of A is not referenced. If UPLO = 'L', the
78: *> leading n by n lower triangular part of A contains the lower
79: *> triangular part of the matrix A, and the strictly upper
80: *> triangular part of A is not referenced.
81: *>
82: *> On exit, if INFO = 0, the factor U or L from the Cholesky
83: *> factorization as above.
84: *> \endverbatim
85: *>
86: *> \param[in] LDA
87: *> \verbatim
88: *> LDA is INTEGER
89: *> The leading dimension of the array A. LDA >= max(1,N).
90: *> \endverbatim
91: *>
92: *> \param[out] PIV
93: *> \verbatim
94: *> PIV is INTEGER array, dimension (N)
95: *> PIV is such that the nonzero entries are P( PIV(K), K ) = 1.
96: *> \endverbatim
97: *>
98: *> \param[out] RANK
99: *> \verbatim
100: *> RANK is INTEGER
101: *> The rank of A given by the number of steps the algorithm
102: *> completed.
103: *> \endverbatim
104: *>
105: *> \param[in] TOL
106: *> \verbatim
107: *> TOL is DOUBLE PRECISION
108: *> User defined tolerance. If TOL < 0, then N*U*MAX( A(K,K) )
109: *> will be used. The algorithm terminates at the (K-1)st step
110: *> if the pivot <= TOL.
111: *> \endverbatim
112: *>
113: *> \param[out] WORK
114: *> \verbatim
115: *> WORK is DOUBLE PRECISION array, dimension (2*N)
116: *> Work space.
117: *> \endverbatim
118: *>
119: *> \param[out] INFO
120: *> \verbatim
121: *> INFO is INTEGER
122: *> < 0: If INFO = -K, the K-th argument had an illegal value,
123: *> = 0: algorithm completed successfully, and
124: *> > 0: the matrix A is either rank deficient with computed rank
125: *> as returned in RANK, or is indefinite. See Section 7 of
126: *> LAPACK Working Note #161 for further information.
127: *> \endverbatim
128: *
129: * Authors:
130: * ========
131: *
132: *> \author Univ. of Tennessee
133: *> \author Univ. of California Berkeley
134: *> \author Univ. of Colorado Denver
135: *> \author NAG Ltd.
136: *
137: *> \date November 2011
138: *
139: *> \ingroup complex16OTHERcomputational
140: *
141: * =====================================================================
142: SUBROUTINE ZPSTRF( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
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: *
463: END
CVSweb interface <joel.bertrand@systella.fr>