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