00001 /* dpftrf.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_b12 = 1.; 00019 static doublereal c_b15 = -1.; 00020 00021 /* Subroutine */ int dpftrf_(char *transr, char *uplo, integer *n, doublereal 00022 *a, integer *info) 00023 { 00024 /* System generated locals */ 00025 integer i__1, i__2; 00026 00027 /* Local variables */ 00028 integer k, n1, n2; 00029 logical normaltransr; 00030 extern logical lsame_(char *, char *); 00031 logical lower; 00032 extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 00033 integer *, integer *, doublereal *, doublereal *, integer *, 00034 doublereal *, integer *), dsyrk_( 00035 char *, char *, integer *, integer *, doublereal *, doublereal *, 00036 integer *, doublereal *, doublereal *, integer *), 00037 xerbla_(char *, integer *); 00038 logical nisodd; 00039 extern /* Subroutine */ int dpotrf_(char *, integer *, doublereal *, 00040 integer *, integer *); 00041 00042 00043 /* -- LAPACK routine (version 3.2) -- */ 00044 00045 /* -- Contributed by Fred Gustavson of the IBM Watson Research Center -- */ 00046 /* -- November 2008 -- */ 00047 00048 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ 00049 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ 00050 00051 /* .. */ 00052 /* .. Scalar Arguments .. */ 00053 /* .. */ 00054 /* .. Array Arguments .. */ 00055 00056 /* Purpose */ 00057 /* ======= */ 00058 00059 /* DPFTRF computes the Cholesky factorization of a real symmetric */ 00060 /* positive definite matrix A. */ 00061 00062 /* The factorization has the form */ 00063 /* A = U**T * U, if UPLO = 'U', or */ 00064 /* A = L * L**T, if UPLO = 'L', */ 00065 /* where U is an upper triangular matrix and L is lower triangular. */ 00066 00067 /* This is the block version of the algorithm, calling Level 3 BLAS. */ 00068 00069 /* Arguments */ 00070 /* ========= */ 00071 00072 /* TRANSR (input) CHARACTER */ 00073 /* = 'N': The Normal TRANSR of RFP A is stored; */ 00074 /* = 'T': The Transpose TRANSR of RFP A is stored. */ 00075 00076 /* UPLO (input) CHARACTER */ 00077 /* = 'U': Upper triangle of RFP A is stored; */ 00078 /* = 'L': Lower triangle of RFP A is stored. */ 00079 00080 /* N (input) INTEGER */ 00081 /* The order of the matrix A. N >= 0. */ 00082 00083 /* A (input/output) DOUBLE PRECISION array, dimension ( N*(N+1)/2 ); */ 00084 /* On entry, the symmetric matrix A in RFP format. RFP format is */ 00085 /* described by TRANSR, UPLO, and N as follows: If TRANSR = 'N' */ 00086 /* then RFP A is (0:N,0:k-1) when N is even; k=N/2. RFP A is */ 00087 /* (0:N-1,0:k) when N is odd; k=N/2. IF TRANSR = 'T' then RFP is */ 00088 /* the transpose of RFP A as defined when */ 00089 /* TRANSR = 'N'. The contents of RFP A are defined by UPLO as */ 00090 /* follows: If UPLO = 'U' the RFP A contains the NT elements of */ 00091 /* upper packed A. If UPLO = 'L' the RFP A contains the elements */ 00092 /* of lower packed A. The LDA of RFP A is (N+1)/2 when TRANSR = */ 00093 /* 'T'. When TRANSR is 'N' the LDA is N+1 when N is even and N */ 00094 /* is odd. See the Note below for more details. */ 00095 00096 /* On exit, if INFO = 0, the factor U or L from the Cholesky */ 00097 /* factorization RFP A = U**T*U or RFP A = L*L**T. */ 00098 00099 /* INFO (output) INTEGER */ 00100 /* = 0: successful exit */ 00101 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00102 /* > 0: if INFO = i, the leading minor of order i is not */ 00103 /* positive definite, and the factorization could not be */ 00104 /* completed. */ 00105 00106 /* Notes */ 00107 /* ===== */ 00108 00109 /* We first consider Rectangular Full Packed (RFP) Format when N is */ 00110 /* even. We give an example where N = 6. */ 00111 00112 /* AP is Upper AP is Lower */ 00113 00114 /* 00 01 02 03 04 05 00 */ 00115 /* 11 12 13 14 15 10 11 */ 00116 /* 22 23 24 25 20 21 22 */ 00117 /* 33 34 35 30 31 32 33 */ 00118 /* 44 45 40 41 42 43 44 */ 00119 /* 55 50 51 52 53 54 55 */ 00120 00121 00122 /* Let TRANSR = 'N'. RFP holds AP as follows: */ 00123 /* For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */ 00124 /* three columns of AP upper. The lower triangle A(4:6,0:2) consists of */ 00125 /* the transpose of the first three columns of AP upper. */ 00126 /* For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */ 00127 /* three columns of AP lower. The upper triangle A(0:2,0:2) consists of */ 00128 /* the transpose of the last three columns of AP lower. */ 00129 /* This covers the case N even and TRANSR = 'N'. */ 00130 00131 /* RFP A RFP A */ 00132 00133 /* 03 04 05 33 43 53 */ 00134 /* 13 14 15 00 44 54 */ 00135 /* 23 24 25 10 11 55 */ 00136 /* 33 34 35 20 21 22 */ 00137 /* 00 44 45 30 31 32 */ 00138 /* 01 11 55 40 41 42 */ 00139 /* 02 12 22 50 51 52 */ 00140 00141 /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ 00142 /* transpose of RFP A above. One therefore gets: */ 00143 00144 00145 /* RFP A RFP A */ 00146 00147 /* 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */ 00148 /* 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */ 00149 /* 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */ 00150 00151 00152 /* We first consider Rectangular Full Packed (RFP) Format when N is */ 00153 /* odd. We give an example where N = 5. */ 00154 00155 /* AP is Upper AP is Lower */ 00156 00157 /* 00 01 02 03 04 00 */ 00158 /* 11 12 13 14 10 11 */ 00159 /* 22 23 24 20 21 22 */ 00160 /* 33 34 30 31 32 33 */ 00161 /* 44 40 41 42 43 44 */ 00162 00163 00164 /* Let TRANSR = 'N'. RFP holds AP as follows: */ 00165 /* For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */ 00166 /* three columns of AP upper. The lower triangle A(3:4,0:1) consists of */ 00167 /* the transpose of the first two columns of AP upper. */ 00168 /* For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */ 00169 /* three columns of AP lower. The upper triangle A(0:1,1:2) consists of */ 00170 /* the transpose of the last two columns of AP lower. */ 00171 /* This covers the case N odd and TRANSR = 'N'. */ 00172 00173 /* RFP A RFP A */ 00174 00175 /* 02 03 04 00 33 43 */ 00176 /* 12 13 14 10 11 44 */ 00177 /* 22 23 24 20 21 22 */ 00178 /* 00 33 34 30 31 32 */ 00179 /* 01 11 44 40 41 42 */ 00180 00181 /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ 00182 /* transpose of RFP A above. One therefore gets: */ 00183 00184 /* RFP A RFP A */ 00185 00186 /* 02 12 22 00 01 00 10 20 30 40 50 */ 00187 /* 03 13 23 33 11 33 11 21 31 41 51 */ 00188 /* 04 14 24 34 44 43 44 22 32 42 52 */ 00189 00190 /* ===================================================================== */ 00191 00192 /* .. Parameters .. */ 00193 /* .. */ 00194 /* .. Local Scalars .. */ 00195 /* .. */ 00196 /* .. External Functions .. */ 00197 /* .. */ 00198 /* .. External Subroutines .. */ 00199 /* .. */ 00200 /* .. Intrinsic Functions .. */ 00201 /* .. */ 00202 /* .. Executable Statements .. */ 00203 00204 /* Test the input parameters. */ 00205 00206 *info = 0; 00207 normaltransr = lsame_(transr, "N"); 00208 lower = lsame_(uplo, "L"); 00209 if (! normaltransr && ! lsame_(transr, "T")) { 00210 *info = -1; 00211 } else if (! lower && ! lsame_(uplo, "U")) { 00212 *info = -2; 00213 } else if (*n < 0) { 00214 *info = -3; 00215 } 00216 if (*info != 0) { 00217 i__1 = -(*info); 00218 xerbla_("DPFTRF", &i__1); 00219 return 0; 00220 } 00221 00222 /* Quick return if possible */ 00223 00224 if (*n == 0) { 00225 return 0; 00226 } 00227 00228 /* If N is odd, set NISODD = .TRUE. */ 00229 /* If N is even, set K = N/2 and NISODD = .FALSE. */ 00230 00231 if (*n % 2 == 0) { 00232 k = *n / 2; 00233 nisodd = FALSE_; 00234 } else { 00235 nisodd = TRUE_; 00236 } 00237 00238 /* Set N1 and N2 depending on LOWER */ 00239 00240 if (lower) { 00241 n2 = *n / 2; 00242 n1 = *n - n2; 00243 } else { 00244 n1 = *n / 2; 00245 n2 = *n - n1; 00246 } 00247 00248 /* start execution: there are eight cases */ 00249 00250 if (nisodd) { 00251 00252 /* N is odd */ 00253 00254 if (normaltransr) { 00255 00256 /* N is odd and TRANSR = 'N' */ 00257 00258 if (lower) { 00259 00260 /* SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) ) */ 00261 /* T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0) */ 00262 /* T1 -> a(0), T2 -> a(n), S -> a(n1) */ 00263 00264 dpotrf_("L", &n1, a, n, info); 00265 if (*info > 0) { 00266 return 0; 00267 } 00268 dtrsm_("R", "L", "T", "N", &n2, &n1, &c_b12, a, n, &a[n1], n); 00269 dsyrk_("U", "N", &n2, &n1, &c_b15, &a[n1], n, &c_b12, &a[*n], 00270 n); 00271 dpotrf_("U", &n2, &a[*n], n, info); 00272 if (*info > 0) { 00273 *info += n1; 00274 } 00275 00276 } else { 00277 00278 /* SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1) */ 00279 /* T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0) */ 00280 /* T1 -> a(n2), T2 -> a(n1), S -> a(0) */ 00281 00282 dpotrf_("L", &n1, &a[n2], n, info); 00283 if (*info > 0) { 00284 return 0; 00285 } 00286 dtrsm_("L", "L", "N", "N", &n1, &n2, &c_b12, &a[n2], n, a, n); 00287 dsyrk_("U", "T", &n2, &n1, &c_b15, a, n, &c_b12, &a[n1], n); 00288 dpotrf_("U", &n2, &a[n1], n, info); 00289 if (*info > 0) { 00290 *info += n1; 00291 } 00292 00293 } 00294 00295 } else { 00296 00297 /* N is odd and TRANSR = 'T' */ 00298 00299 if (lower) { 00300 00301 /* SRPA for LOWER, TRANSPOSE and N is odd */ 00302 /* T1 -> A(0,0) , T2 -> A(1,0) , S -> A(0,n1) */ 00303 /* T1 -> a(0+0) , T2 -> a(1+0) , S -> a(0+n1*n1); lda=n1 */ 00304 00305 dpotrf_("U", &n1, a, &n1, info); 00306 if (*info > 0) { 00307 return 0; 00308 } 00309 dtrsm_("L", "U", "T", "N", &n1, &n2, &c_b12, a, &n1, &a[n1 * 00310 n1], &n1); 00311 dsyrk_("L", "T", &n2, &n1, &c_b15, &a[n1 * n1], &n1, &c_b12, & 00312 a[1], &n1); 00313 dpotrf_("L", &n2, &a[1], &n1, info); 00314 if (*info > 0) { 00315 *info += n1; 00316 } 00317 00318 } else { 00319 00320 /* SRPA for UPPER, TRANSPOSE and N is odd */ 00321 /* T1 -> A(0,n1+1), T2 -> A(0,n1), S -> A(0,0) */ 00322 /* T1 -> a(n2*n2), T2 -> a(n1*n2), S -> a(0); lda = n2 */ 00323 00324 dpotrf_("U", &n1, &a[n2 * n2], &n2, info); 00325 if (*info > 0) { 00326 return 0; 00327 } 00328 dtrsm_("R", "U", "N", "N", &n2, &n1, &c_b12, &a[n2 * n2], &n2, 00329 a, &n2); 00330 dsyrk_("L", "N", &n2, &n1, &c_b15, a, &n2, &c_b12, &a[n1 * n2] 00331 , &n2); 00332 dpotrf_("L", &n2, &a[n1 * n2], &n2, info); 00333 if (*info > 0) { 00334 *info += n1; 00335 } 00336 00337 } 00338 00339 } 00340 00341 } else { 00342 00343 /* N is even */ 00344 00345 if (normaltransr) { 00346 00347 /* N is even and TRANSR = 'N' */ 00348 00349 if (lower) { 00350 00351 /* SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) ) */ 00352 /* T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0) */ 00353 /* T1 -> a(1), T2 -> a(0), S -> a(k+1) */ 00354 00355 i__1 = *n + 1; 00356 dpotrf_("L", &k, &a[1], &i__1, info); 00357 if (*info > 0) { 00358 return 0; 00359 } 00360 i__1 = *n + 1; 00361 i__2 = *n + 1; 00362 dtrsm_("R", "L", "T", "N", &k, &k, &c_b12, &a[1], &i__1, &a[k 00363 + 1], &i__2); 00364 i__1 = *n + 1; 00365 i__2 = *n + 1; 00366 dsyrk_("U", "N", &k, &k, &c_b15, &a[k + 1], &i__1, &c_b12, a, 00367 &i__2); 00368 i__1 = *n + 1; 00369 dpotrf_("U", &k, a, &i__1, info); 00370 if (*info > 0) { 00371 *info += k; 00372 } 00373 00374 } else { 00375 00376 /* SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) ) */ 00377 /* T1 -> a(k+1,0) , T2 -> a(k,0), S -> a(0,0) */ 00378 /* T1 -> a(k+1), T2 -> a(k), S -> a(0) */ 00379 00380 i__1 = *n + 1; 00381 dpotrf_("L", &k, &a[k + 1], &i__1, info); 00382 if (*info > 0) { 00383 return 0; 00384 } 00385 i__1 = *n + 1; 00386 i__2 = *n + 1; 00387 dtrsm_("L", "L", "N", "N", &k, &k, &c_b12, &a[k + 1], &i__1, 00388 a, &i__2); 00389 i__1 = *n + 1; 00390 i__2 = *n + 1; 00391 dsyrk_("U", "T", &k, &k, &c_b15, a, &i__1, &c_b12, &a[k], & 00392 i__2); 00393 i__1 = *n + 1; 00394 dpotrf_("U", &k, &a[k], &i__1, info); 00395 if (*info > 0) { 00396 *info += k; 00397 } 00398 00399 } 00400 00401 } else { 00402 00403 /* N is even and TRANSR = 'T' */ 00404 00405 if (lower) { 00406 00407 /* SRPA for LOWER, TRANSPOSE and N is even (see paper) */ 00408 /* T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1) */ 00409 /* T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k */ 00410 00411 dpotrf_("U", &k, &a[k], &k, info); 00412 if (*info > 0) { 00413 return 0; 00414 } 00415 dtrsm_("L", "U", "T", "N", &k, &k, &c_b12, &a[k], &n1, &a[k * 00416 (k + 1)], &k); 00417 dsyrk_("L", "T", &k, &k, &c_b15, &a[k * (k + 1)], &k, &c_b12, 00418 a, &k); 00419 dpotrf_("L", &k, a, &k, info); 00420 if (*info > 0) { 00421 *info += k; 00422 } 00423 00424 } else { 00425 00426 /* SRPA for UPPER, TRANSPOSE and N is even (see paper) */ 00427 /* T1 -> B(0,k+1), T2 -> B(0,k), S -> B(0,0) */ 00428 /* T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k */ 00429 00430 dpotrf_("U", &k, &a[k * (k + 1)], &k, info); 00431 if (*info > 0) { 00432 return 0; 00433 } 00434 dtrsm_("R", "U", "N", "N", &k, &k, &c_b12, &a[k * (k + 1)], & 00435 k, a, &k); 00436 dsyrk_("L", "N", &k, &k, &c_b15, a, &k, &c_b12, &a[k * k], &k); 00437 dpotrf_("L", &k, &a[k * k], &k, info); 00438 if (*info > 0) { 00439 *info += k; 00440 } 00441 00442 } 00443 00444 } 00445 00446 } 00447 00448 return 0; 00449 00450 /* End of DPFTRF */ 00451 00452 } /* dpftrf_ */