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


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