00001 /* spptri.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static real c_b8 = 1.f; 00019 static integer c__1 = 1; 00020 00021 /* Subroutine */ int spptri_(char *uplo, integer *n, real *ap, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer i__1, i__2; 00025 00026 /* Local variables */ 00027 integer j, jc, jj; 00028 real ajj; 00029 integer jjn; 00030 extern doublereal sdot_(integer *, real *, integer *, real *, integer *); 00031 extern /* Subroutine */ int sspr_(char *, integer *, real *, real *, 00032 integer *, real *); 00033 extern logical lsame_(char *, char *); 00034 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); 00035 logical upper; 00036 extern /* Subroutine */ int stpmv_(char *, char *, char *, integer *, 00037 real *, real *, integer *), xerbla_(char * 00038 , integer *), stptri_(char *, char *, integer *, real *, 00039 integer *); 00040 00041 00042 /* -- LAPACK routine (version 3.2) -- */ 00043 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00044 /* November 2006 */ 00045 00046 /* .. Scalar Arguments .. */ 00047 /* .. */ 00048 /* .. Array Arguments .. */ 00049 /* .. */ 00050 00051 /* Purpose */ 00052 /* ======= */ 00053 00054 /* SPPTRI computes the inverse of a real symmetric positive definite */ 00055 /* matrix A using the Cholesky factorization A = U**T*U or A = L*L**T */ 00056 /* computed by SPPTRF. */ 00057 00058 /* Arguments */ 00059 /* ========= */ 00060 00061 /* UPLO (input) CHARACTER*1 */ 00062 /* = 'U': Upper triangular factor is stored in AP; */ 00063 /* = 'L': Lower triangular factor is stored in AP. */ 00064 00065 /* N (input) INTEGER */ 00066 /* The order of the matrix A. N >= 0. */ 00067 00068 /* AP (input/output) REAL array, dimension (N*(N+1)/2) */ 00069 /* On entry, the triangular factor U or L from the Cholesky */ 00070 /* factorization A = U**T*U or A = L*L**T, packed columnwise as */ 00071 /* a linear array. The j-th column of U or L is stored in the */ 00072 /* array AP as follows: */ 00073 /* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */ 00074 /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */ 00075 00076 /* On exit, the upper or lower triangle of the (symmetric) */ 00077 /* inverse of A, overwriting the input factor U or L. */ 00078 00079 /* INFO (output) INTEGER */ 00080 /* = 0: successful exit */ 00081 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00082 /* > 0: if INFO = i, the (i,i) element of the factor U or L is */ 00083 /* zero, and the inverse could not be computed. */ 00084 00085 /* ===================================================================== */ 00086 00087 /* .. Parameters .. */ 00088 /* .. */ 00089 /* .. Local Scalars .. */ 00090 /* .. */ 00091 /* .. External Functions .. */ 00092 /* .. */ 00093 /* .. External Subroutines .. */ 00094 /* .. */ 00095 /* .. Executable Statements .. */ 00096 00097 /* Test the input parameters. */ 00098 00099 /* Parameter adjustments */ 00100 --ap; 00101 00102 /* Function Body */ 00103 *info = 0; 00104 upper = lsame_(uplo, "U"); 00105 if (! upper && ! lsame_(uplo, "L")) { 00106 *info = -1; 00107 } else if (*n < 0) { 00108 *info = -2; 00109 } 00110 if (*info != 0) { 00111 i__1 = -(*info); 00112 xerbla_("SPPTRI", &i__1); 00113 return 0; 00114 } 00115 00116 /* Quick return if possible */ 00117 00118 if (*n == 0) { 00119 return 0; 00120 } 00121 00122 /* Invert the triangular Cholesky factor U or L. */ 00123 00124 stptri_(uplo, "Non-unit", n, &ap[1], info); 00125 if (*info > 0) { 00126 return 0; 00127 } 00128 00129 if (upper) { 00130 00131 /* Compute the product inv(U) * inv(U)'. */ 00132 00133 jj = 0; 00134 i__1 = *n; 00135 for (j = 1; j <= i__1; ++j) { 00136 jc = jj + 1; 00137 jj += j; 00138 if (j > 1) { 00139 i__2 = j - 1; 00140 sspr_("Upper", &i__2, &c_b8, &ap[jc], &c__1, &ap[1]); 00141 } 00142 ajj = ap[jj]; 00143 sscal_(&j, &ajj, &ap[jc], &c__1); 00144 /* L10: */ 00145 } 00146 00147 } else { 00148 00149 /* Compute the product inv(L)' * inv(L). */ 00150 00151 jj = 1; 00152 i__1 = *n; 00153 for (j = 1; j <= i__1; ++j) { 00154 jjn = jj + *n - j + 1; 00155 i__2 = *n - j + 1; 00156 ap[jj] = sdot_(&i__2, &ap[jj], &c__1, &ap[jj], &c__1); 00157 if (j < *n) { 00158 i__2 = *n - j; 00159 stpmv_("Lower", "Transpose", "Non-unit", &i__2, &ap[jjn], &ap[ 00160 jj + 1], &c__1); 00161 } 00162 jj = jjn; 00163 /* L20: */ 00164 } 00165 } 00166 00167 return 0; 00168 00169 /* End of SPPTRI */ 00170 00171 } /* spptri_ */