spbtrf.c
Go to the documentation of this file.
00001 /* spbtrf.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 integer c_n1 = -1;
00020 static real c_b18 = 1.f;
00021 static real c_b21 = -1.f;
00022 static integer c__33 = 33;
00023 
00024 /* Subroutine */ int spbtrf_(char *uplo, integer *n, integer *kd, real *ab, 
00025         integer *ldab, integer *info)
00026 {
00027     /* System generated locals */
00028     integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4;
00029 
00030     /* Local variables */
00031     integer i__, j, i2, i3, ib, nb, ii, jj;
00032     real work[1056]     /* was [33][32] */;
00033     extern logical lsame_(char *, char *);
00034     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00035             integer *, real *, real *, integer *, real *, integer *, real *, 
00036             real *, integer *), strsm_(char *, char *, char *, 
00037              char *, integer *, integer *, real *, real *, integer *, real *, 
00038             integer *), ssyrk_(char *, char *, 
00039              integer *, integer *, real *, real *, integer *, real *, real *, 
00040             integer *), spbtf2_(char *, integer *, integer *, 
00041             real *, integer *, integer *), spotf2_(char *, integer *, 
00042             real *, integer *, integer *), xerbla_(char *, integer *);
00043     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00044             integer *, integer *);
00045 
00046 
00047 /*  -- LAPACK routine (version 3.2) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  SPBTRF computes the Cholesky factorization of a real symmetric */
00060 /*  positive definite band 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 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*  UPLO    (input) CHARACTER*1 */
00071 /*          = 'U':  Upper triangle of A is stored; */
00072 /*          = 'L':  Lower triangle of A is stored. */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The order of the matrix A.  N >= 0. */
00076 
00077 /*  KD      (input) INTEGER */
00078 /*          The number of superdiagonals of the matrix A if UPLO = 'U', */
00079 /*          or the number of subdiagonals if UPLO = 'L'.  KD >= 0. */
00080 
00081 /*  AB      (input/output) REAL array, dimension (LDAB,N) */
00082 /*          On entry, the upper or lower triangle of the symmetric band */
00083 /*          matrix A, stored in the first KD+1 rows of the array.  The */
00084 /*          j-th column of A is stored in the j-th column of the array AB */
00085 /*          as follows: */
00086 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00087 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00088 
00089 /*          On exit, if INFO = 0, the triangular factor U or L from the */
00090 /*          Cholesky factorization A = U**T*U or A = L*L**T of the band */
00091 /*          matrix A, in the same storage format as A. */
00092 
00093 /*  LDAB    (input) INTEGER */
00094 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
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, the leading minor of order i is not */
00100 /*                positive definite, and the factorization could not be */
00101 /*                completed. */
00102 
00103 /*  Further Details */
00104 /*  =============== */
00105 
00106 /*  The band storage scheme is illustrated by the following example, when */
00107 /*  N = 6, KD = 2, and UPLO = 'U': */
00108 
00109 /*  On entry:                       On exit: */
00110 
00111 /*      *    *   a13  a24  a35  a46      *    *   u13  u24  u35  u46 */
00112 /*      *   a12  a23  a34  a45  a56      *   u12  u23  u34  u45  u56 */
00113 /*     a11  a22  a33  a44  a55  a66     u11  u22  u33  u44  u55  u66 */
00114 
00115 /*  Similarly, if UPLO = 'L' the format of A is as follows: */
00116 
00117 /*  On entry:                       On exit: */
00118 
00119 /*     a11  a22  a33  a44  a55  a66     l11  l22  l33  l44  l55  l66 */
00120 /*     a21  a32  a43  a54  a65   *      l21  l32  l43  l54  l65   * */
00121 /*     a31  a42  a53  a64   *    *      l31  l42  l53  l64   *    * */
00122 
00123 /*  Array elements marked * are not used by the routine. */
00124 
00125 /*  Contributed by */
00126 /*  Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989 */
00127 
00128 /*  ===================================================================== */
00129 
00130 /*     .. Parameters .. */
00131 /*     .. */
00132 /*     .. Local Scalars .. */
00133 /*     .. */
00134 /*     .. Local Arrays .. */
00135 /*     .. */
00136 /*     .. External Functions .. */
00137 /*     .. */
00138 /*     .. External Subroutines .. */
00139 /*     .. */
00140 /*     .. Intrinsic Functions .. */
00141 /*     .. */
00142 /*     .. Executable Statements .. */
00143 
00144 /*     Test the input parameters. */
00145 
00146     /* Parameter adjustments */
00147     ab_dim1 = *ldab;
00148     ab_offset = 1 + ab_dim1;
00149     ab -= ab_offset;
00150 
00151     /* Function Body */
00152     *info = 0;
00153     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00154         *info = -1;
00155     } else if (*n < 0) {
00156         *info = -2;
00157     } else if (*kd < 0) {
00158         *info = -3;
00159     } else if (*ldab < *kd + 1) {
00160         *info = -5;
00161     }
00162     if (*info != 0) {
00163         i__1 = -(*info);
00164         xerbla_("SPBTRF", &i__1);
00165         return 0;
00166     }
00167 
00168 /*     Quick return if possible */
00169 
00170     if (*n == 0) {
00171         return 0;
00172     }
00173 
00174 /*     Determine the block size for this environment */
00175 
00176     nb = ilaenv_(&c__1, "SPBTRF", uplo, n, kd, &c_n1, &c_n1);
00177 
00178 /*     The block size must not exceed the semi-bandwidth KD, and must not */
00179 /*     exceed the limit set by the size of the local array WORK. */
00180 
00181     nb = min(nb,32);
00182 
00183     if (nb <= 1 || nb > *kd) {
00184 
00185 /*        Use unblocked code */
00186 
00187         spbtf2_(uplo, n, kd, &ab[ab_offset], ldab, info);
00188     } else {
00189 
00190 /*        Use blocked code */
00191 
00192         if (lsame_(uplo, "U")) {
00193 
00194 /*           Compute the Cholesky factorization of a symmetric band */
00195 /*           matrix, given the upper triangle of the matrix in band */
00196 /*           storage. */
00197 
00198 /*           Zero the upper triangle of the work array. */
00199 
00200             i__1 = nb;
00201             for (j = 1; j <= i__1; ++j) {
00202                 i__2 = j - 1;
00203                 for (i__ = 1; i__ <= i__2; ++i__) {
00204                     work[i__ + j * 33 - 34] = 0.f;
00205 /* L10: */
00206                 }
00207 /* L20: */
00208             }
00209 
00210 /*           Process the band matrix one diagonal block at a time. */
00211 
00212             i__1 = *n;
00213             i__2 = nb;
00214             for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00215 /* Computing MIN */
00216                 i__3 = nb, i__4 = *n - i__ + 1;
00217                 ib = min(i__3,i__4);
00218 
00219 /*              Factorize the diagonal block */
00220 
00221                 i__3 = *ldab - 1;
00222                 spotf2_(uplo, &ib, &ab[*kd + 1 + i__ * ab_dim1], &i__3, &ii);
00223                 if (ii != 0) {
00224                     *info = i__ + ii - 1;
00225                     goto L150;
00226                 }
00227                 if (i__ + ib <= *n) {
00228 
00229 /*                 Update the relevant part of the trailing submatrix. */
00230 /*                 If A11 denotes the diagonal block which has just been */
00231 /*                 factorized, then we need to update the remaining */
00232 /*                 blocks in the diagram: */
00233 
00234 /*                    A11   A12   A13 */
00235 /*                          A22   A23 */
00236 /*                                A33 */
00237 
00238 /*                 The numbers of rows and columns in the partitioning */
00239 /*                 are IB, I2, I3 respectively. The blocks A12, A22 and */
00240 /*                 A23 are empty if IB = KD. The upper triangle of A13 */
00241 /*                 lies outside the band. */
00242 
00243 /* Computing MIN */
00244                     i__3 = *kd - ib, i__4 = *n - i__ - ib + 1;
00245                     i2 = min(i__3,i__4);
00246 /* Computing MIN */
00247                     i__3 = ib, i__4 = *n - i__ - *kd + 1;
00248                     i3 = min(i__3,i__4);
00249 
00250                     if (i2 > 0) {
00251 
00252 /*                    Update A12 */
00253 
00254                         i__3 = *ldab - 1;
00255                         i__4 = *ldab - 1;
00256                         strsm_("Left", "Upper", "Transpose", "Non-unit", &ib, 
00257                                 &i2, &c_b18, &ab[*kd + 1 + i__ * ab_dim1], &
00258                                 i__3, &ab[*kd + 1 - ib + (i__ + ib) * ab_dim1]
00259 , &i__4);
00260 
00261 /*                    Update A22 */
00262 
00263                         i__3 = *ldab - 1;
00264                         i__4 = *ldab - 1;
00265                         ssyrk_("Upper", "Transpose", &i2, &ib, &c_b21, &ab[*
00266                                 kd + 1 - ib + (i__ + ib) * ab_dim1], &i__3, &
00267                                 c_b18, &ab[*kd + 1 + (i__ + ib) * ab_dim1], &
00268                                 i__4);
00269                     }
00270 
00271                     if (i3 > 0) {
00272 
00273 /*                    Copy the lower triangle of A13 into the work array. */
00274 
00275                         i__3 = i3;
00276                         for (jj = 1; jj <= i__3; ++jj) {
00277                             i__4 = ib;
00278                             for (ii = jj; ii <= i__4; ++ii) {
00279                                 work[ii + jj * 33 - 34] = ab[ii - jj + 1 + (
00280                                         jj + i__ + *kd - 1) * ab_dim1];
00281 /* L30: */
00282                             }
00283 /* L40: */
00284                         }
00285 
00286 /*                    Update A13 (in the work array). */
00287 
00288                         i__3 = *ldab - 1;
00289                         strsm_("Left", "Upper", "Transpose", "Non-unit", &ib, 
00290                                 &i3, &c_b18, &ab[*kd + 1 + i__ * ab_dim1], &
00291                                 i__3, work, &c__33);
00292 
00293 /*                    Update A23 */
00294 
00295                         if (i2 > 0) {
00296                             i__3 = *ldab - 1;
00297                             i__4 = *ldab - 1;
00298                             sgemm_("Transpose", "No Transpose", &i2, &i3, &ib, 
00299                                      &c_b21, &ab[*kd + 1 - ib + (i__ + ib) * 
00300                                     ab_dim1], &i__3, work, &c__33, &c_b18, &
00301                                     ab[ib + 1 + (i__ + *kd) * ab_dim1], &i__4);
00302                         }
00303 
00304 /*                    Update A33 */
00305 
00306                         i__3 = *ldab - 1;
00307                         ssyrk_("Upper", "Transpose", &i3, &ib, &c_b21, work, &
00308                                 c__33, &c_b18, &ab[*kd + 1 + (i__ + *kd) * 
00309                                 ab_dim1], &i__3);
00310 
00311 /*                    Copy the lower triangle of A13 back into place. */
00312 
00313                         i__3 = i3;
00314                         for (jj = 1; jj <= i__3; ++jj) {
00315                             i__4 = ib;
00316                             for (ii = jj; ii <= i__4; ++ii) {
00317                                 ab[ii - jj + 1 + (jj + i__ + *kd - 1) * 
00318                                         ab_dim1] = work[ii + jj * 33 - 34];
00319 /* L50: */
00320                             }
00321 /* L60: */
00322                         }
00323                     }
00324                 }
00325 /* L70: */
00326             }
00327         } else {
00328 
00329 /*           Compute the Cholesky factorization of a symmetric band */
00330 /*           matrix, given the lower triangle of the matrix in band */
00331 /*           storage. */
00332 
00333 /*           Zero the lower triangle of the work array. */
00334 
00335             i__2 = nb;
00336             for (j = 1; j <= i__2; ++j) {
00337                 i__1 = nb;
00338                 for (i__ = j + 1; i__ <= i__1; ++i__) {
00339                     work[i__ + j * 33 - 34] = 0.f;
00340 /* L80: */
00341                 }
00342 /* L90: */
00343             }
00344 
00345 /*           Process the band matrix one diagonal block at a time. */
00346 
00347             i__2 = *n;
00348             i__1 = nb;
00349             for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
00350 /* Computing MIN */
00351                 i__3 = nb, i__4 = *n - i__ + 1;
00352                 ib = min(i__3,i__4);
00353 
00354 /*              Factorize the diagonal block */
00355 
00356                 i__3 = *ldab - 1;
00357                 spotf2_(uplo, &ib, &ab[i__ * ab_dim1 + 1], &i__3, &ii);
00358                 if (ii != 0) {
00359                     *info = i__ + ii - 1;
00360                     goto L150;
00361                 }
00362                 if (i__ + ib <= *n) {
00363 
00364 /*                 Update the relevant part of the trailing submatrix. */
00365 /*                 If A11 denotes the diagonal block which has just been */
00366 /*                 factorized, then we need to update the remaining */
00367 /*                 blocks in the diagram: */
00368 
00369 /*                    A11 */
00370 /*                    A21   A22 */
00371 /*                    A31   A32   A33 */
00372 
00373 /*                 The numbers of rows and columns in the partitioning */
00374 /*                 are IB, I2, I3 respectively. The blocks A21, A22 and */
00375 /*                 A32 are empty if IB = KD. The lower triangle of A31 */
00376 /*                 lies outside the band. */
00377 
00378 /* Computing MIN */
00379                     i__3 = *kd - ib, i__4 = *n - i__ - ib + 1;
00380                     i2 = min(i__3,i__4);
00381 /* Computing MIN */
00382                     i__3 = ib, i__4 = *n - i__ - *kd + 1;
00383                     i3 = min(i__3,i__4);
00384 
00385                     if (i2 > 0) {
00386 
00387 /*                    Update A21 */
00388 
00389                         i__3 = *ldab - 1;
00390                         i__4 = *ldab - 1;
00391                         strsm_("Right", "Lower", "Transpose", "Non-unit", &i2, 
00392                                  &ib, &c_b18, &ab[i__ * ab_dim1 + 1], &i__3, &
00393                                 ab[ib + 1 + i__ * ab_dim1], &i__4);
00394 
00395 /*                    Update A22 */
00396 
00397                         i__3 = *ldab - 1;
00398                         i__4 = *ldab - 1;
00399                         ssyrk_("Lower", "No Transpose", &i2, &ib, &c_b21, &ab[
00400                                 ib + 1 + i__ * ab_dim1], &i__3, &c_b18, &ab[(
00401                                 i__ + ib) * ab_dim1 + 1], &i__4);
00402                     }
00403 
00404                     if (i3 > 0) {
00405 
00406 /*                    Copy the upper triangle of A31 into the work array. */
00407 
00408                         i__3 = ib;
00409                         for (jj = 1; jj <= i__3; ++jj) {
00410                             i__4 = min(jj,i3);
00411                             for (ii = 1; ii <= i__4; ++ii) {
00412                                 work[ii + jj * 33 - 34] = ab[*kd + 1 - jj + 
00413                                         ii + (jj + i__ - 1) * ab_dim1];
00414 /* L100: */
00415                             }
00416 /* L110: */
00417                         }
00418 
00419 /*                    Update A31 (in the work array). */
00420 
00421                         i__3 = *ldab - 1;
00422                         strsm_("Right", "Lower", "Transpose", "Non-unit", &i3, 
00423                                  &ib, &c_b18, &ab[i__ * ab_dim1 + 1], &i__3, 
00424                                 work, &c__33);
00425 
00426 /*                    Update A32 */
00427 
00428                         if (i2 > 0) {
00429                             i__3 = *ldab - 1;
00430                             i__4 = *ldab - 1;
00431                             sgemm_("No transpose", "Transpose", &i3, &i2, &ib, 
00432                                      &c_b21, work, &c__33, &ab[ib + 1 + i__ * 
00433                                     ab_dim1], &i__3, &c_b18, &ab[*kd + 1 - ib 
00434                                     + (i__ + ib) * ab_dim1], &i__4);
00435                         }
00436 
00437 /*                    Update A33 */
00438 
00439                         i__3 = *ldab - 1;
00440                         ssyrk_("Lower", "No Transpose", &i3, &ib, &c_b21, 
00441                                 work, &c__33, &c_b18, &ab[(i__ + *kd) * 
00442                                 ab_dim1 + 1], &i__3);
00443 
00444 /*                    Copy the upper triangle of A31 back into place. */
00445 
00446                         i__3 = ib;
00447                         for (jj = 1; jj <= i__3; ++jj) {
00448                             i__4 = min(jj,i3);
00449                             for (ii = 1; ii <= i__4; ++ii) {
00450                                 ab[*kd + 1 - jj + ii + (jj + i__ - 1) * 
00451                                         ab_dim1] = work[ii + jj * 33 - 34];
00452 /* L120: */
00453                             }
00454 /* L130: */
00455                         }
00456                     }
00457                 }
00458 /* L140: */
00459             }
00460         }
00461     }
00462     return 0;
00463 
00464 L150:
00465     return 0;
00466 
00467 /*     End of SPBTRF */
00468 
00469 } /* spbtrf_ */


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