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