00001 /* dpptri.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 doublereal c_b8 = 1.; 00019 static integer c__1 = 1; 00020 00021 /* Subroutine */ int dpptri_(char *uplo, integer *n, doublereal *ap, integer * 00022 info) 00023 { 00024 /* System generated locals */ 00025 integer i__1, i__2; 00026 00027 /* Local variables */ 00028 integer j, jc, jj; 00029 doublereal ajj; 00030 integer jjn; 00031 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 00032 integer *); 00033 extern /* Subroutine */ int dspr_(char *, integer *, doublereal *, 00034 doublereal *, integer *, doublereal *), dscal_(integer *, 00035 doublereal *, doublereal *, integer *); 00036 extern logical lsame_(char *, char *); 00037 extern /* Subroutine */ int dtpmv_(char *, char *, char *, integer *, 00038 doublereal *, doublereal *, integer *); 00039 logical upper; 00040 extern /* Subroutine */ int xerbla_(char *, integer *), dtptri_( 00041 char *, char *, integer *, doublereal *, integer *); 00042 00043 00044 /* -- LAPACK routine (version 3.2) -- */ 00045 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00046 /* November 2006 */ 00047 00048 /* .. Scalar Arguments .. */ 00049 /* .. */ 00050 /* .. Array Arguments .. */ 00051 /* .. */ 00052 00053 /* Purpose */ 00054 /* ======= */ 00055 00056 /* DPPTRI computes the inverse of a real symmetric positive definite */ 00057 /* matrix A using the Cholesky factorization A = U**T*U or A = L*L**T */ 00058 /* computed by DPPTRF. */ 00059 00060 /* Arguments */ 00061 /* ========= */ 00062 00063 /* UPLO (input) CHARACTER*1 */ 00064 /* = 'U': Upper triangular factor is stored in AP; */ 00065 /* = 'L': Lower triangular factor is stored in AP. */ 00066 00067 /* N (input) INTEGER */ 00068 /* The order of the matrix A. N >= 0. */ 00069 00070 /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ 00071 /* On entry, the triangular factor U or L from the Cholesky */ 00072 /* factorization A = U**T*U or A = L*L**T, packed columnwise as */ 00073 /* a linear array. The j-th column of U or L is stored in the */ 00074 /* array AP as follows: */ 00075 /* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */ 00076 /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */ 00077 00078 /* On exit, the upper or lower triangle of the (symmetric) */ 00079 /* inverse of A, overwriting the input factor U or L. */ 00080 00081 /* INFO (output) INTEGER */ 00082 /* = 0: successful exit */ 00083 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00084 /* > 0: if INFO = i, the (i,i) element of the factor U or L is */ 00085 /* zero, and the inverse could not be computed. */ 00086 00087 /* ===================================================================== */ 00088 00089 /* .. Parameters .. */ 00090 /* .. */ 00091 /* .. Local Scalars .. */ 00092 /* .. */ 00093 /* .. External Functions .. */ 00094 /* .. */ 00095 /* .. External Subroutines .. */ 00096 /* .. */ 00097 /* .. Executable Statements .. */ 00098 00099 /* Test the input parameters. */ 00100 00101 /* Parameter adjustments */ 00102 --ap; 00103 00104 /* Function Body */ 00105 *info = 0; 00106 upper = lsame_(uplo, "U"); 00107 if (! upper && ! lsame_(uplo, "L")) { 00108 *info = -1; 00109 } else if (*n < 0) { 00110 *info = -2; 00111 } 00112 if (*info != 0) { 00113 i__1 = -(*info); 00114 xerbla_("DPPTRI", &i__1); 00115 return 0; 00116 } 00117 00118 /* Quick return if possible */ 00119 00120 if (*n == 0) { 00121 return 0; 00122 } 00123 00124 /* Invert the triangular Cholesky factor U or L. */ 00125 00126 dtptri_(uplo, "Non-unit", n, &ap[1], info); 00127 if (*info > 0) { 00128 return 0; 00129 } 00130 00131 if (upper) { 00132 00133 /* Compute the product inv(U) * inv(U)'. */ 00134 00135 jj = 0; 00136 i__1 = *n; 00137 for (j = 1; j <= i__1; ++j) { 00138 jc = jj + 1; 00139 jj += j; 00140 if (j > 1) { 00141 i__2 = j - 1; 00142 dspr_("Upper", &i__2, &c_b8, &ap[jc], &c__1, &ap[1]); 00143 } 00144 ajj = ap[jj]; 00145 dscal_(&j, &ajj, &ap[jc], &c__1); 00146 /* L10: */ 00147 } 00148 00149 } else { 00150 00151 /* Compute the product inv(L)' * inv(L). */ 00152 00153 jj = 1; 00154 i__1 = *n; 00155 for (j = 1; j <= i__1; ++j) { 00156 jjn = jj + *n - j + 1; 00157 i__2 = *n - j + 1; 00158 ap[jj] = ddot_(&i__2, &ap[jj], &c__1, &ap[jj], &c__1); 00159 if (j < *n) { 00160 i__2 = *n - j; 00161 dtpmv_("Lower", "Transpose", "Non-unit", &i__2, &ap[jjn], &ap[ 00162 jj + 1], &c__1); 00163 } 00164 jj = jjn; 00165 /* L20: */ 00166 } 00167 } 00168 00169 return 0; 00170 00171 /* End of DPPTRI */ 00172 00173 } /* dpptri_ */