001:       SUBROUTINE ZPPTRI( UPLO, N, AP, 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, N
011: *     ..
012: *     .. Array Arguments ..
013:       COMPLEX*16         AP( * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  ZPPTRI computes the inverse of a complex Hermitian positive definite
020: *  matrix A using the Cholesky factorization A = U**H*U or A = L*L**H
021: *  computed by ZPPTRF.
022: *
023: *  Arguments
024: *  =========
025: *
026: *  UPLO    (input) CHARACTER*1
027: *          = 'U':  Upper triangular factor is stored in AP;
028: *          = 'L':  Lower triangular factor is stored in AP.
029: *
030: *  N       (input) INTEGER
031: *          The order of the matrix A.  N >= 0.
032: *
033: *  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2)
034: *          On entry, the triangular factor U or L from the Cholesky
035: *          factorization A = U**H*U or A = L*L**H, packed columnwise as
036: *          a linear array.  The j-th column of U or L is stored in the
037: *          array AP as follows:
038: *          if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j;
039: *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n.
040: *
041: *          On exit, the upper or lower triangle of the (Hermitian)
042: *          inverse of A, overwriting the input factor U or L.
043: *
044: *  INFO    (output) INTEGER
045: *          = 0:  successful exit
046: *          < 0:  if INFO = -i, the i-th argument had an illegal value
047: *          > 0:  if INFO = i, the (i,i) element of the factor U or L is
048: *                zero, and the inverse could not be computed.
049: *
050: *  =====================================================================
051: *
052: *     .. Parameters ..
053:       DOUBLE PRECISION   ONE
054:       PARAMETER          ( ONE = 1.0D+0 )
055: *     ..
056: *     .. Local Scalars ..
057:       LOGICAL            UPPER
058:       INTEGER            J, JC, JJ, JJN
059:       DOUBLE PRECISION   AJJ
060: *     ..
061: *     .. External Functions ..
062:       LOGICAL            LSAME
063:       COMPLEX*16         ZDOTC
064:       EXTERNAL           LSAME, ZDOTC
065: *     ..
066: *     .. External Subroutines ..
067:       EXTERNAL           XERBLA, ZDSCAL, ZHPR, ZTPMV, ZTPTRI
068: *     ..
069: *     .. Intrinsic Functions ..
070:       INTRINSIC          DBLE
071: *     ..
072: *     .. Executable Statements ..
073: *
074: *     Test the input parameters.
075: *
076:       INFO = 0
077:       UPPER = LSAME( UPLO, 'U' )
078:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
079:          INFO = -1
080:       ELSE IF( N.LT.0 ) THEN
081:          INFO = -2
082:       END IF
083:       IF( INFO.NE.0 ) THEN
084:          CALL XERBLA( 'ZPPTRI', -INFO )
085:          RETURN
086:       END IF
087: *
088: *     Quick return if possible
089: *
090:       IF( N.EQ.0 )
091:      $   RETURN
092: *
093: *     Invert the triangular Cholesky factor U or L.
094: *
095:       CALL ZTPTRI( UPLO, 'Non-unit', N, AP, INFO )
096:       IF( INFO.GT.0 )
097:      $   RETURN
098:       IF( UPPER ) THEN
099: *
100: *        Compute the product inv(U) * inv(U)'.
101: *
102:          JJ = 0
103:          DO 10 J = 1, N
104:             JC = JJ + 1
105:             JJ = JJ + J
106:             IF( J.GT.1 )
107:      $         CALL ZHPR( 'Upper', J-1, ONE, AP( JC ), 1, AP )
108:             AJJ = AP( JJ )
109:             CALL ZDSCAL( J, AJJ, AP( JC ), 1 )
110:    10    CONTINUE
111: *
112:       ELSE
113: *
114: *        Compute the product inv(L)' * inv(L).
115: *
116:          JJ = 1
117:          DO 20 J = 1, N
118:             JJN = JJ + N - J + 1
119:             AP( JJ ) = DBLE( ZDOTC( N-J+1, AP( JJ ), 1, AP( JJ ), 1 ) )
120:             IF( J.LT.N )
121:      $         CALL ZTPMV( 'Lower', 'Conjugate transpose', 'Non-unit',
122:      $                     N-J, AP( JJN ), AP( JJ+1 ), 1 )
123:             JJ = JJN
124:    20    CONTINUE
125:       END IF
126: *
127:       RETURN
128: *
129: *     End of ZPPTRI
130: *
131:       END
132: