00001 /* dpptrf.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 integer c__1 = 1; 00019 static doublereal c_b16 = -1.; 00020 00021 /* Subroutine */ int dpptrf_(char *uplo, integer *n, doublereal *ap, integer * 00022 info) 00023 { 00024 /* System generated locals */ 00025 integer i__1, i__2; 00026 doublereal d__1; 00027 00028 /* Builtin functions */ 00029 double sqrt(doublereal); 00030 00031 /* Local variables */ 00032 integer j, jc, jj; 00033 doublereal ajj; 00034 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 00035 integer *); 00036 extern /* Subroutine */ int dspr_(char *, integer *, doublereal *, 00037 doublereal *, integer *, doublereal *), dscal_(integer *, 00038 doublereal *, doublereal *, integer *); 00039 extern logical lsame_(char *, char *); 00040 logical upper; 00041 extern /* Subroutine */ int dtpsv_(char *, char *, char *, integer *, 00042 doublereal *, doublereal *, integer *), 00043 xerbla_(char *, integer *); 00044 00045 00046 /* -- LAPACK routine (version 3.2) -- */ 00047 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00048 /* November 2006 */ 00049 00050 /* .. Scalar Arguments .. */ 00051 /* .. */ 00052 /* .. Array Arguments .. */ 00053 /* .. */ 00054 00055 /* Purpose */ 00056 /* ======= */ 00057 00058 /* DPPTRF computes the Cholesky factorization of a real symmetric */ 00059 /* positive definite matrix A stored in packed format. */ 00060 00061 /* The factorization has the form */ 00062 /* A = U**T * U, if UPLO = 'U', or */ 00063 /* A = L * L**T, if UPLO = 'L', */ 00064 /* where U is an upper triangular matrix and L is lower triangular. */ 00065 00066 /* Arguments */ 00067 /* ========= */ 00068 00069 /* UPLO (input) CHARACTER*1 */ 00070 /* = 'U': Upper triangle of A is stored; */ 00071 /* = 'L': Lower triangle of A is stored. */ 00072 00073 /* N (input) INTEGER */ 00074 /* The order of the matrix A. N >= 0. */ 00075 00076 /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ 00077 /* On entry, the upper or lower triangle of the symmetric matrix */ 00078 /* A, packed columnwise in a linear array. The j-th column of A */ 00079 /* is stored in the array AP as follows: */ 00080 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00081 /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ 00082 /* See below for further details. */ 00083 00084 /* On exit, if INFO = 0, the triangular factor U or L from the */ 00085 /* Cholesky factorization A = U**T*U or A = L*L**T, in the same */ 00086 /* storage format as A. */ 00087 00088 /* INFO (output) INTEGER */ 00089 /* = 0: successful exit */ 00090 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00091 /* > 0: if INFO = i, the leading minor of order i is not */ 00092 /* positive definite, and the factorization could not be */ 00093 /* completed. */ 00094 00095 /* Further Details */ 00096 /* ======= ======= */ 00097 00098 /* The packed storage scheme is illustrated by the following example */ 00099 /* when N = 4, UPLO = 'U': */ 00100 00101 /* Two-dimensional storage of the symmetric matrix A: */ 00102 00103 /* a11 a12 a13 a14 */ 00104 /* a22 a23 a24 */ 00105 /* a33 a34 (aij = aji) */ 00106 /* a44 */ 00107 00108 /* Packed storage of the upper triangle of A: */ 00109 00110 /* AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */ 00111 00112 /* ===================================================================== */ 00113 00114 /* .. Parameters .. */ 00115 /* .. */ 00116 /* .. Local Scalars .. */ 00117 /* .. */ 00118 /* .. External Functions .. */ 00119 /* .. */ 00120 /* .. External Subroutines .. */ 00121 /* .. */ 00122 /* .. Intrinsic Functions .. */ 00123 /* .. */ 00124 /* .. Executable Statements .. */ 00125 00126 /* Test the input parameters. */ 00127 00128 /* Parameter adjustments */ 00129 --ap; 00130 00131 /* Function Body */ 00132 *info = 0; 00133 upper = lsame_(uplo, "U"); 00134 if (! upper && ! lsame_(uplo, "L")) { 00135 *info = -1; 00136 } else if (*n < 0) { 00137 *info = -2; 00138 } 00139 if (*info != 0) { 00140 i__1 = -(*info); 00141 xerbla_("DPPTRF", &i__1); 00142 return 0; 00143 } 00144 00145 /* Quick return if possible */ 00146 00147 if (*n == 0) { 00148 return 0; 00149 } 00150 00151 if (upper) { 00152 00153 /* Compute the Cholesky factorization A = U'*U. */ 00154 00155 jj = 0; 00156 i__1 = *n; 00157 for (j = 1; j <= i__1; ++j) { 00158 jc = jj + 1; 00159 jj += j; 00160 00161 /* Compute elements 1:J-1 of column J. */ 00162 00163 if (j > 1) { 00164 i__2 = j - 1; 00165 dtpsv_("Upper", "Transpose", "Non-unit", &i__2, &ap[1], &ap[ 00166 jc], &c__1); 00167 } 00168 00169 /* Compute U(J,J) and test for non-positive-definiteness. */ 00170 00171 i__2 = j - 1; 00172 ajj = ap[jj] - ddot_(&i__2, &ap[jc], &c__1, &ap[jc], &c__1); 00173 if (ajj <= 0.) { 00174 ap[jj] = ajj; 00175 goto L30; 00176 } 00177 ap[jj] = sqrt(ajj); 00178 /* L10: */ 00179 } 00180 } else { 00181 00182 /* Compute the Cholesky factorization A = L*L'. */ 00183 00184 jj = 1; 00185 i__1 = *n; 00186 for (j = 1; j <= i__1; ++j) { 00187 00188 /* Compute L(J,J) and test for non-positive-definiteness. */ 00189 00190 ajj = ap[jj]; 00191 if (ajj <= 0.) { 00192 ap[jj] = ajj; 00193 goto L30; 00194 } 00195 ajj = sqrt(ajj); 00196 ap[jj] = ajj; 00197 00198 /* Compute elements J+1:N of column J and update the trailing */ 00199 /* submatrix. */ 00200 00201 if (j < *n) { 00202 i__2 = *n - j; 00203 d__1 = 1. / ajj; 00204 dscal_(&i__2, &d__1, &ap[jj + 1], &c__1); 00205 i__2 = *n - j; 00206 dspr_("Lower", &i__2, &c_b16, &ap[jj + 1], &c__1, &ap[jj + *n 00207 - j + 1]); 00208 jj = jj + *n - j + 1; 00209 } 00210 /* L20: */ 00211 } 00212 } 00213 goto L40; 00214 00215 L30: 00216 *info = j; 00217 00218 L40: 00219 return 0; 00220 00221 /* End of DPPTRF */ 00222 00223 } /* dpptrf_ */