```001:       SUBROUTINE ZPOTRF( UPLO, N, A, LDA, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          UPLO
010:       INTEGER            INFO, LDA, N
011: *     ..
012: *     .. Array Arguments ..
013:       COMPLEX*16         A( LDA, * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  ZPOTRF computes the Cholesky factorization of a complex Hermitian
020: *  positive definite matrix A.
021: *
022: *  The factorization has the form
023: *     A = U**H * U,  if UPLO = 'U', or
024: *     A = L  * L**H,  if UPLO = 'L',
025: *  where U is an upper triangular matrix and L is lower triangular.
026: *
027: *  This is the block version of the algorithm, calling Level 3 BLAS.
028: *
029: *  Arguments
030: *  =========
031: *
032: *  UPLO    (input) CHARACTER*1
033: *          = 'U':  Upper triangle of A is stored;
034: *          = 'L':  Lower triangle of A is stored.
035: *
036: *  N       (input) INTEGER
037: *          The order of the matrix A.  N >= 0.
038: *
039: *  A       (input/output) COMPLEX*16 array, dimension (LDA,N)
040: *          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
041: *          N-by-N upper triangular part of A contains the upper
042: *          triangular part of the matrix A, and the strictly lower
043: *          triangular part of A is not referenced.  If UPLO = 'L', the
044: *          leading N-by-N lower triangular part of A contains the lower
045: *          triangular part of the matrix A, and the strictly upper
046: *          triangular part of A is not referenced.
047: *
048: *          On exit, if INFO = 0, the factor U or L from the Cholesky
049: *          factorization A = U**H*U or A = L*L**H.
050: *
051: *  LDA     (input) INTEGER
052: *          The leading dimension of the array A.  LDA >= max(1,N).
053: *
054: *  INFO    (output) INTEGER
055: *          = 0:  successful exit
056: *          < 0:  if INFO = -i, the i-th argument had an illegal value
057: *          > 0:  if INFO = i, the leading minor of order i is not
058: *                positive definite, and the factorization could not be
059: *                completed.
060: *
061: *  =====================================================================
062: *
063: *     .. Parameters ..
064:       DOUBLE PRECISION   ONE
065:       COMPLEX*16         CONE
066:       PARAMETER          ( ONE = 1.0D+0, CONE = ( 1.0D+0, 0.0D+0 ) )
067: *     ..
068: *     .. Local Scalars ..
069:       LOGICAL            UPPER
070:       INTEGER            J, JB, NB
071: *     ..
072: *     .. External Functions ..
073:       LOGICAL            LSAME
074:       INTEGER            ILAENV
075:       EXTERNAL           LSAME, ILAENV
076: *     ..
077: *     .. External Subroutines ..
078:       EXTERNAL           XERBLA, ZGEMM, ZHERK, ZPOTF2, ZTRSM
079: *     ..
080: *     .. Intrinsic Functions ..
081:       INTRINSIC          MAX, MIN
082: *     ..
083: *     .. Executable Statements ..
084: *
085: *     Test the input parameters.
086: *
087:       INFO = 0
088:       UPPER = LSAME( UPLO, 'U' )
089:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
090:          INFO = -1
091:       ELSE IF( N.LT.0 ) THEN
092:          INFO = -2
093:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
094:          INFO = -4
095:       END IF
096:       IF( INFO.NE.0 ) THEN
097:          CALL XERBLA( 'ZPOTRF', -INFO )
098:          RETURN
099:       END IF
100: *
101: *     Quick return if possible
102: *
103:       IF( N.EQ.0 )
104:      \$   RETURN
105: *
106: *     Determine the block size for this environment.
107: *
108:       NB = ILAENV( 1, 'ZPOTRF', UPLO, N, -1, -1, -1 )
109:       IF( NB.LE.1 .OR. NB.GE.N ) THEN
110: *
111: *        Use unblocked code.
112: *
113:          CALL ZPOTF2( UPLO, N, A, LDA, INFO )
114:       ELSE
115: *
116: *        Use blocked code.
117: *
118:          IF( UPPER ) THEN
119: *
120: *           Compute the Cholesky factorization A = U'*U.
121: *
122:             DO 10 J = 1, N, NB
123: *
124: *              Update and factorize the current diagonal block and test
125: *              for non-positive-definiteness.
126: *
127:                JB = MIN( NB, N-J+1 )
128:                CALL ZHERK( 'Upper', 'Conjugate transpose', JB, J-1,
129:      \$                     -ONE, A( 1, J ), LDA, ONE, A( J, J ), LDA )
130:                CALL ZPOTF2( 'Upper', JB, A( J, J ), LDA, INFO )
131:                IF( INFO.NE.0 )
132:      \$            GO TO 30
133:                IF( J+JB.LE.N ) THEN
134: *
135: *                 Compute the current block row.
136: *
137:                   CALL ZGEMM( 'Conjugate transpose', 'No transpose', JB,
138:      \$                        N-J-JB+1, J-1, -CONE, A( 1, J ), LDA,
139:      \$                        A( 1, J+JB ), LDA, CONE, A( J, J+JB ),
140:      \$                        LDA )
141:                   CALL ZTRSM( 'Left', 'Upper', 'Conjugate transpose',
142:      \$                        'Non-unit', JB, N-J-JB+1, CONE, A( J, J ),
143:      \$                        LDA, A( J, J+JB ), LDA )
144:                END IF
145:    10       CONTINUE
146: *
147:          ELSE
148: *
149: *           Compute the Cholesky factorization A = L*L'.
150: *
151:             DO 20 J = 1, N, NB
152: *
153: *              Update and factorize the current diagonal block and test
154: *              for non-positive-definiteness.
155: *
156:                JB = MIN( NB, N-J+1 )
157:                CALL ZHERK( 'Lower', 'No transpose', JB, J-1, -ONE,
158:      \$                     A( J, 1 ), LDA, ONE, A( J, J ), LDA )
159:                CALL ZPOTF2( 'Lower', JB, A( J, J ), LDA, INFO )
160:                IF( INFO.NE.0 )
161:      \$            GO TO 30
162:                IF( J+JB.LE.N ) THEN
163: *
164: *                 Compute the current block column.
165: *
166:                   CALL ZGEMM( 'No transpose', 'Conjugate transpose',
167:      \$                        N-J-JB+1, JB, J-1, -CONE, A( J+JB, 1 ),
168:      \$                        LDA, A( J, 1 ), LDA, CONE, A( J+JB, J ),
169:      \$                        LDA )
170:                   CALL ZTRSM( 'Right', 'Lower', 'Conjugate transpose',
171:      \$                        'Non-unit', N-J-JB+1, JB, CONE, A( J, J ),
172:      \$                        LDA, A( J+JB, J ), LDA )
173:                END IF
174:    20       CONTINUE
175:          END IF
176:       END IF
177:       GO TO 40
178: *
179:    30 CONTINUE
180:       INFO = INFO + J - 1
181: *
182:    40 CONTINUE
183:       RETURN
184: *
185: *     End of ZPOTRF
186: *
187:       END
188: ```