kusano 2b45e8
      SUBROUTINE ZPOTRFF( UPLO, N, A, LDA, INFO )
kusano 2b45e8
*
kusano 2b45e8
*  -- LAPACK routine (version 3.0) --
kusano 2b45e8
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
kusano 2b45e8
*     Courant Institute, Argonne National Lab, and Rice University
kusano 2b45e8
*     September 30, 1994
kusano 2b45e8
*
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      CHARACTER          UPLO
kusano 2b45e8
      INTEGER            INFO, LDA, N
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      COMPLEX*16         A( LDA, * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  Purpose
kusano 2b45e8
*  =======
kusano 2b45e8
*
kusano 2b45e8
*  ZPOTRF computes the Cholesky factorization of a complex Hermitian
kusano 2b45e8
*  positive definite matrix A.
kusano 2b45e8
*
kusano 2b45e8
*  The factorization has the form
kusano 2b45e8
*     A = U**H * U,  if UPLO = 'U', or
kusano 2b45e8
*     A = L  * L**H,  if UPLO = 'L',
kusano 2b45e8
*  where U is an upper triangular matrix and L is lower triangular.
kusano 2b45e8
*
kusano 2b45e8
*  This is the block version of the algorithm, calling Level 3 BLAS.
kusano 2b45e8
*
kusano 2b45e8
*  Arguments
kusano 2b45e8
*  =========
kusano 2b45e8
*
kusano 2b45e8
*  UPLO    (input) CHARACTER*1
kusano 2b45e8
*          = 'U':  Upper triangle of A is stored;
kusano 2b45e8
*          = 'L':  Lower triangle of A is stored.
kusano 2b45e8
*
kusano 2b45e8
*  N       (input) INTEGER
kusano 2b45e8
*          The order of the matrix A.  N >= 0.
kusano 2b45e8
*
kusano 2b45e8
*  A       (input/output) COMPLEX*16 array, dimension (LDA,N)
kusano 2b45e8
*          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
kusano 2b45e8
*          N-by-N upper triangular part of A contains the upper
kusano 2b45e8
*          triangular part of the matrix A, and the strictly lower
kusano 2b45e8
*          triangular part of A is not referenced.  If UPLO = 'L', the
kusano 2b45e8
*          leading N-by-N lower triangular part of A contains the lower
kusano 2b45e8
*          triangular part of the matrix A, and the strictly upper
kusano 2b45e8
*          triangular part of A is not referenced.
kusano 2b45e8
*
kusano 2b45e8
*          On exit, if INFO = 0, the factor U or L from the Cholesky
kusano 2b45e8
*          factorization A = U**H*U or A = L*L**H.
kusano 2b45e8
*
kusano 2b45e8
*  LDA     (input) INTEGER
kusano 2b45e8
*          The leading dimension of the array A.  LDA >= max(1,N).
kusano 2b45e8
*
kusano 2b45e8
*  INFO    (output) INTEGER
kusano 2b45e8
*          = 0:  successful exit
kusano 2b45e8
*          < 0:  if INFO = -i, the i-th argument had an illegal value
kusano 2b45e8
*          > 0:  if INFO = i, the leading minor of order i is not
kusano 2b45e8
*                positive definite, and the factorization could not be
kusano 2b45e8
*                completed.
kusano 2b45e8
*
kusano 2b45e8
*  =====================================================================
kusano 2b45e8
*
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      DOUBLE PRECISION   ONE
kusano 2b45e8
      COMPLEX*16         CONE
kusano 2b45e8
      PARAMETER          ( ONE = 1.0D+0, CONE = ( 1.0D+0, 0.0D+0 ) )
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      LOGICAL            UPPER
kusano 2b45e8
      INTEGER            J, JB, NB
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. External Functions ..
kusano 2b45e8
      LOGICAL            LSAME
kusano 2b45e8
      EXTERNAL           LSAME
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. External Subroutines ..
kusano 2b45e8
      EXTERNAL           XERBLA, ZGEMM, ZHERK, ZPOTF2, ZTRSM
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC          MAX, MIN
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
*
kusano 2b45e8
*     Test the input parameters.
kusano 2b45e8
*
kusano 2b45e8
      INFO = 0
kusano 2b45e8
      UPPER = LSAME( UPLO, 'U' )
kusano 2b45e8
      IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
kusano 2b45e8
         INFO = -1
kusano 2b45e8
      ELSE IF( N.LT.0 ) THEN
kusano 2b45e8
         INFO = -2
kusano 2b45e8
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = -4
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INFO.NE.0 ) THEN
kusano 2b45e8
         CALL XERBLA( 'ZPOTRF', -INFO )
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Quick return if possible
kusano 2b45e8
*
kusano 2b45e8
      IF( N.EQ.0 )
kusano 2b45e8
     $   RETURN
kusano 2b45e8
*
kusano 2b45e8
*     Determine the block size for this environment.
kusano 2b45e8
*
kusano 2b45e8
      NB = 56
kusano 2b45e8
kusano 2b45e8
      IF( NB.LE.1 .OR. NB.GE.N ) THEN
kusano 2b45e8
*
kusano 2b45e8
*        Use unblocked code.
kusano 2b45e8
*
kusano 2b45e8
         CALL ZPOTF2( UPLO, N, A, LDA, INFO )
kusano 2b45e8
      ELSE
kusano 2b45e8
*
kusano 2b45e8
*        Use blocked code.
kusano 2b45e8
*
kusano 2b45e8
         IF( UPPER ) THEN
kusano 2b45e8
*
kusano 2b45e8
*           Compute the Cholesky factorization A = U'*U.
kusano 2b45e8
*
kusano 2b45e8
            DO 10 J = 1, N, NB
kusano 2b45e8
*
kusano 2b45e8
*              Update and factorize the current diagonal block and test
kusano 2b45e8
*              for non-positive-definiteness.
kusano 2b45e8
*
kusano 2b45e8
               JB = MIN( NB, N-J+1 )
kusano 2b45e8
               CALL ZHERK( 'Upper', 'Conjugate transpose', JB, J-1,
kusano 2b45e8
     $                     -ONE, A( 1, J ), LDA, ONE, A( J, J ), LDA )
kusano 2b45e8
               CALL ZPOTF2( 'Upper', JB, A( J, J ), LDA, INFO )
kusano 2b45e8
               IF( INFO.NE.0 )
kusano 2b45e8
     $            GO TO 30
kusano 2b45e8
               IF( J+JB.LE.N ) THEN
kusano 2b45e8
*
kusano 2b45e8
*                 Compute the current block row.
kusano 2b45e8
*
kusano 2b45e8
                  CALL ZGEMM( 'Conjugate transpose', 'No transpose', JB,
kusano 2b45e8
     $                        N-J-JB+1, J-1, -CONE, A( 1, J ), LDA,
kusano 2b45e8
     $                        A( 1, J+JB ), LDA, CONE, A( J, J+JB ),
kusano 2b45e8
     $                        LDA )
kusano 2b45e8
                  CALL ZTRSM( 'Left', 'Upper', 'Conjugate transpose',
kusano 2b45e8
     $                        'Non-unit', JB, N-J-JB+1, CONE, A( J, J ),
kusano 2b45e8
     $                        LDA, A( J, J+JB ), LDA )
kusano 2b45e8
               END IF
kusano 2b45e8
   10       CONTINUE
kusano 2b45e8
*
kusano 2b45e8
         ELSE
kusano 2b45e8
*
kusano 2b45e8
*           Compute the Cholesky factorization A = L*L'.
kusano 2b45e8
*
kusano 2b45e8
            DO 20 J = 1, N, NB
kusano 2b45e8
*
kusano 2b45e8
*              Update and factorize the current diagonal block and test
kusano 2b45e8
*              for non-positive-definiteness.
kusano 2b45e8
*
kusano 2b45e8
               JB = MIN( NB, N-J+1 )
kusano 2b45e8
               CALL ZHERK( 'Lower', 'No transpose', JB, J-1, -ONE,
kusano 2b45e8
     $                     A( J, 1 ), LDA, ONE, A( J, J ), LDA )
kusano 2b45e8
               CALL ZPOTF2( 'Lower', JB, A( J, J ), LDA, INFO )
kusano 2b45e8
               IF( INFO.NE.0 )
kusano 2b45e8
     $            GO TO 30
kusano 2b45e8
               IF( J+JB.LE.N ) THEN
kusano 2b45e8
*
kusano 2b45e8
*                 Compute the current block column.
kusano 2b45e8
*
kusano 2b45e8
                  CALL ZGEMM( 'No transpose', 'Conjugate transpose',
kusano 2b45e8
     $                        N-J-JB+1, JB, J-1, -CONE, A( J+JB, 1 ),
kusano 2b45e8
     $                        LDA, A( J, 1 ), LDA, CONE, A( J+JB, J ),
kusano 2b45e8
     $                        LDA )
kusano 2b45e8
                  CALL ZTRSM( 'Right', 'Lower', 'Conjugate transpose',
kusano 2b45e8
     $                        'Non-unit', N-J-JB+1, JB, CONE, A( J, J ),
kusano 2b45e8
     $                        LDA, A( J+JB, J ), LDA )
kusano 2b45e8
               END IF
kusano 2b45e8
   20       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      END IF
kusano 2b45e8
      GO TO 40
kusano 2b45e8
*
kusano 2b45e8
   30 CONTINUE
kusano 2b45e8
      INFO = INFO + J - 1
kusano 2b45e8
*
kusano 2b45e8
   40 CONTINUE
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of ZPOTRF
kusano 2b45e8
*
kusano 2b45e8
      END