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


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