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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:12