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