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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:47