zlahef.c
Go to the documentation of this file.
00001 /* zlahef.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 
00021 /* Subroutine */ int zlahef_(char *uplo, integer *n, integer *nb, integer *kb, 
00022          doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *w, 
00023         integer *ldw, integer *info)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, w_dim1, w_offset, i__1, i__2, i__3, i__4, i__5;
00027     doublereal d__1, d__2, d__3, d__4;
00028     doublecomplex z__1, z__2, z__3, z__4;
00029 
00030     /* Builtin functions */
00031     double sqrt(doublereal), d_imag(doublecomplex *);
00032     void d_cnjg(doublecomplex *, doublecomplex *), z_div(doublecomplex *, 
00033             doublecomplex *, doublecomplex *);
00034 
00035     /* Local variables */
00036     integer j, k;
00037     doublereal t, r1;
00038     doublecomplex d11, d21, d22;
00039     integer jb, jj, kk, jp, kp, kw, kkw, imax, jmax;
00040     doublereal alpha;
00041     extern logical lsame_(char *, char *);
00042     extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, 
00043             integer *, doublecomplex *, doublecomplex *, integer *, 
00044             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00045             integer *);
00046     integer kstep;
00047     extern /* Subroutine */ int zgemv_(char *, integer *, integer *, 
00048             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00049             integer *, doublecomplex *, doublecomplex *, integer *), 
00050             zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, 
00051             integer *), zswap_(integer *, doublecomplex *, integer *, 
00052             doublecomplex *, integer *);
00053     doublereal absakk;
00054     extern /* Subroutine */ int zdscal_(integer *, doublereal *, 
00055             doublecomplex *, integer *);
00056     doublereal colmax;
00057     extern /* Subroutine */ int zlacgv_(integer *, doublecomplex *, integer *)
00058             ;
00059     extern integer izamax_(integer *, doublecomplex *, integer *);
00060     doublereal rowmax;
00061 
00062 
00063 /*  -- LAPACK routine (version 3.2) -- */
00064 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00065 /*     November 2006 */
00066 
00067 /*     .. Scalar Arguments .. */
00068 /*     .. */
00069 /*     .. Array Arguments .. */
00070 /*     .. */
00071 
00072 /*  Purpose */
00073 /*  ======= */
00074 
00075 /*  ZLAHEF computes a partial factorization of a complex Hermitian */
00076 /*  matrix A using the Bunch-Kaufman diagonal pivoting method. The */
00077 /*  partial factorization has the form: */
00078 
00079 /*  A  =  ( I  U12 ) ( A11  0  ) (  I    0   )  if UPLO = 'U', or: */
00080 /*        ( 0  U22 ) (  0   D  ) ( U12' U22' ) */
00081 
00082 /*  A  =  ( L11  0 ) (  D   0  ) ( L11' L21' )  if UPLO = 'L' */
00083 /*        ( L21  I ) (  0  A22 ) (  0    I   ) */
00084 
00085 /*  where the order of D is at most NB. The actual order is returned in */
00086 /*  the argument KB, and is either NB or NB-1, or N if N <= NB. */
00087 /*  Note that U' denotes the conjugate transpose of U. */
00088 
00089 /*  ZLAHEF is an auxiliary routine called by ZHETRF. It uses blocked code */
00090 /*  (calling Level 3 BLAS) to update the submatrix A11 (if UPLO = 'U') or */
00091 /*  A22 (if UPLO = 'L'). */
00092 
00093 /*  Arguments */
00094 /*  ========= */
00095 
00096 /*  UPLO    (input) CHARACTER*1 */
00097 /*          Specifies whether the upper or lower triangular part of the */
00098 /*          Hermitian matrix A is stored: */
00099 /*          = 'U':  Upper triangular */
00100 /*          = 'L':  Lower triangular */
00101 
00102 /*  N       (input) INTEGER */
00103 /*          The order of the matrix A.  N >= 0. */
00104 
00105 /*  NB      (input) INTEGER */
00106 /*          The maximum number of columns of the matrix A that should be */
00107 /*          factored.  NB should be at least 2 to allow for 2-by-2 pivot */
00108 /*          blocks. */
00109 
00110 /*  KB      (output) INTEGER */
00111 /*          The number of columns of A that were actually factored. */
00112 /*          KB is either NB-1 or NB, or N if N <= NB. */
00113 
00114 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00115 /*          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading */
00116 /*          n-by-n upper triangular part of A contains the upper */
00117 /*          triangular part of the matrix A, and the strictly lower */
00118 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00119 /*          leading n-by-n lower triangular part of A contains the lower */
00120 /*          triangular part of the matrix A, and the strictly upper */
00121 /*          triangular part of A is not referenced. */
00122 /*          On exit, A contains details of the partial factorization. */
00123 
00124 /*  LDA     (input) INTEGER */
00125 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00126 
00127 /*  IPIV    (output) INTEGER array, dimension (N) */
00128 /*          Details of the interchanges and the block structure of D. */
00129 /*          If UPLO = 'U', only the last KB elements of IPIV are set; */
00130 /*          if UPLO = 'L', only the first KB elements are set. */
00131 
00132 /*          If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
00133 /*          interchanged and D(k,k) is a 1-by-1 diagonal block. */
00134 /*          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
00135 /*          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
00136 /*          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) = */
00137 /*          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
00138 /*          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
00139 
00140 /*  W       (workspace) COMPLEX*16 array, dimension (LDW,NB) */
00141 
00142 /*  LDW     (input) INTEGER */
00143 /*          The leading dimension of the array W.  LDW >= max(1,N). */
00144 
00145 /*  INFO    (output) INTEGER */
00146 /*          = 0: successful exit */
00147 /*          > 0: if INFO = k, D(k,k) is exactly zero.  The factorization */
00148 /*               has been completed, but the block diagonal matrix D is */
00149 /*               exactly singular. */
00150 
00151 /*  ===================================================================== */
00152 
00153 /*     .. Parameters .. */
00154 /*     .. */
00155 /*     .. Local Scalars .. */
00156 /*     .. */
00157 /*     .. External Functions .. */
00158 /*     .. */
00159 /*     .. External Subroutines .. */
00160 /*     .. */
00161 /*     .. Intrinsic Functions .. */
00162 /*     .. */
00163 /*     .. Statement Functions .. */
00164 /*     .. */
00165 /*     .. Statement Function definitions .. */
00166 /*     .. */
00167 /*     .. Executable Statements .. */
00168 
00169     /* Parameter adjustments */
00170     a_dim1 = *lda;
00171     a_offset = 1 + a_dim1;
00172     a -= a_offset;
00173     --ipiv;
00174     w_dim1 = *ldw;
00175     w_offset = 1 + w_dim1;
00176     w -= w_offset;
00177 
00178     /* Function Body */
00179     *info = 0;
00180 
00181 /*     Initialize ALPHA for use in choosing pivot block size. */
00182 
00183     alpha = (sqrt(17.) + 1.) / 8.;
00184 
00185     if (lsame_(uplo, "U")) {
00186 
00187 /*        Factorize the trailing columns of A using the upper triangle */
00188 /*        of A and working backwards, and compute the matrix W = U12*D */
00189 /*        for use in updating A11 (note that conjg(W) is actually stored) */
00190 
00191 /*        K is the main loop index, decreasing from N in steps of 1 or 2 */
00192 
00193 /*        KW is the column of W which corresponds to column K of A */
00194 
00195         k = *n;
00196 L10:
00197         kw = *nb + k - *n;
00198 
00199 /*        Exit from loop */
00200 
00201         if (k <= *n - *nb + 1 && *nb < *n || k < 1) {
00202             goto L30;
00203         }
00204 
00205 /*        Copy column K of A to column KW of W and update it */
00206 
00207         i__1 = k - 1;
00208         zcopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &w[kw * w_dim1 + 1], &c__1);
00209         i__1 = k + kw * w_dim1;
00210         i__2 = k + k * a_dim1;
00211         d__1 = a[i__2].r;
00212         w[i__1].r = d__1, w[i__1].i = 0.;
00213         if (k < *n) {
00214             i__1 = *n - k;
00215             z__1.r = -1., z__1.i = -0.;
00216             zgemv_("No transpose", &k, &i__1, &z__1, &a[(k + 1) * a_dim1 + 1], 
00217                      lda, &w[k + (kw + 1) * w_dim1], ldw, &c_b1, &w[kw * 
00218                     w_dim1 + 1], &c__1);
00219             i__1 = k + kw * w_dim1;
00220             i__2 = k + kw * w_dim1;
00221             d__1 = w[i__2].r;
00222             w[i__1].r = d__1, w[i__1].i = 0.;
00223         }
00224 
00225         kstep = 1;
00226 
00227 /*        Determine rows and columns to be interchanged and whether */
00228 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00229 
00230         i__1 = k + kw * w_dim1;
00231         absakk = (d__1 = w[i__1].r, abs(d__1));
00232 
00233 /*        IMAX is the row-index of the largest off-diagonal element in */
00234 /*        column K, and COLMAX is its absolute value */
00235 
00236         if (k > 1) {
00237             i__1 = k - 1;
00238             imax = izamax_(&i__1, &w[kw * w_dim1 + 1], &c__1);
00239             i__1 = imax + kw * w_dim1;
00240             colmax = (d__1 = w[i__1].r, abs(d__1)) + (d__2 = d_imag(&w[imax + 
00241                     kw * w_dim1]), abs(d__2));
00242         } else {
00243             colmax = 0.;
00244         }
00245 
00246         if (max(absakk,colmax) == 0.) {
00247 
00248 /*           Column K is zero: set INFO and continue */
00249 
00250             if (*info == 0) {
00251                 *info = k;
00252             }
00253             kp = k;
00254             i__1 = k + k * a_dim1;
00255             i__2 = k + k * a_dim1;
00256             d__1 = a[i__2].r;
00257             a[i__1].r = d__1, a[i__1].i = 0.;
00258         } else {
00259             if (absakk >= alpha * colmax) {
00260 
00261 /*              no interchange, use 1-by-1 pivot block */
00262 
00263                 kp = k;
00264             } else {
00265 
00266 /*              Copy column IMAX to column KW-1 of W and update it */
00267 
00268                 i__1 = imax - 1;
00269                 zcopy_(&i__1, &a[imax * a_dim1 + 1], &c__1, &w[(kw - 1) * 
00270                         w_dim1 + 1], &c__1);
00271                 i__1 = imax + (kw - 1) * w_dim1;
00272                 i__2 = imax + imax * a_dim1;
00273                 d__1 = a[i__2].r;
00274                 w[i__1].r = d__1, w[i__1].i = 0.;
00275                 i__1 = k - imax;
00276                 zcopy_(&i__1, &a[imax + (imax + 1) * a_dim1], lda, &w[imax + 
00277                         1 + (kw - 1) * w_dim1], &c__1);
00278                 i__1 = k - imax;
00279                 zlacgv_(&i__1, &w[imax + 1 + (kw - 1) * w_dim1], &c__1);
00280                 if (k < *n) {
00281                     i__1 = *n - k;
00282                     z__1.r = -1., z__1.i = -0.;
00283                     zgemv_("No transpose", &k, &i__1, &z__1, &a[(k + 1) * 
00284                             a_dim1 + 1], lda, &w[imax + (kw + 1) * w_dim1], 
00285                             ldw, &c_b1, &w[(kw - 1) * w_dim1 + 1], &c__1);
00286                     i__1 = imax + (kw - 1) * w_dim1;
00287                     i__2 = imax + (kw - 1) * w_dim1;
00288                     d__1 = w[i__2].r;
00289                     w[i__1].r = d__1, w[i__1].i = 0.;
00290                 }
00291 
00292 /*              JMAX is the column-index of the largest off-diagonal */
00293 /*              element in row IMAX, and ROWMAX is its absolute value */
00294 
00295                 i__1 = k - imax;
00296                 jmax = imax + izamax_(&i__1, &w[imax + 1 + (kw - 1) * w_dim1], 
00297                          &c__1);
00298                 i__1 = jmax + (kw - 1) * w_dim1;
00299                 rowmax = (d__1 = w[i__1].r, abs(d__1)) + (d__2 = d_imag(&w[
00300                         jmax + (kw - 1) * w_dim1]), abs(d__2));
00301                 if (imax > 1) {
00302                     i__1 = imax - 1;
00303                     jmax = izamax_(&i__1, &w[(kw - 1) * w_dim1 + 1], &c__1);
00304 /* Computing MAX */
00305                     i__1 = jmax + (kw - 1) * w_dim1;
00306                     d__3 = rowmax, d__4 = (d__1 = w[i__1].r, abs(d__1)) + (
00307                             d__2 = d_imag(&w[jmax + (kw - 1) * w_dim1]), abs(
00308                             d__2));
00309                     rowmax = max(d__3,d__4);
00310                 }
00311 
00312                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00313 
00314 /*                 no interchange, use 1-by-1 pivot block */
00315 
00316                     kp = k;
00317                 } else /* if(complicated condition) */ {
00318                     i__1 = imax + (kw - 1) * w_dim1;
00319                     if ((d__1 = w[i__1].r, abs(d__1)) >= alpha * rowmax) {
00320 
00321 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00322 /*                 pivot block */
00323 
00324                         kp = imax;
00325 
00326 /*                 copy column KW-1 of W to column KW */
00327 
00328                         zcopy_(&k, &w[(kw - 1) * w_dim1 + 1], &c__1, &w[kw * 
00329                                 w_dim1 + 1], &c__1);
00330                     } else {
00331 
00332 /*                 interchange rows and columns K-1 and IMAX, use 2-by-2 */
00333 /*                 pivot block */
00334 
00335                         kp = imax;
00336                         kstep = 2;
00337                     }
00338                 }
00339             }
00340 
00341             kk = k - kstep + 1;
00342             kkw = *nb + kk - *n;
00343 
00344 /*           Updated column KP is already stored in column KKW of W */
00345 
00346             if (kp != kk) {
00347 
00348 /*              Copy non-updated column KK to column KP */
00349 
00350                 i__1 = kp + kp * a_dim1;
00351                 i__2 = kk + kk * a_dim1;
00352                 d__1 = a[i__2].r;
00353                 a[i__1].r = d__1, a[i__1].i = 0.;
00354                 i__1 = kk - 1 - kp;
00355                 zcopy_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (kp + 
00356                         1) * a_dim1], lda);
00357                 i__1 = kk - 1 - kp;
00358                 zlacgv_(&i__1, &a[kp + (kp + 1) * a_dim1], lda);
00359                 i__1 = kp - 1;
00360                 zcopy_(&i__1, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1 + 1], 
00361                          &c__1);
00362 
00363 /*              Interchange rows KK and KP in last KK columns of A and W */
00364 
00365                 if (kk < *n) {
00366                     i__1 = *n - kk;
00367                     zswap_(&i__1, &a[kk + (kk + 1) * a_dim1], lda, &a[kp + (
00368                             kk + 1) * a_dim1], lda);
00369                 }
00370                 i__1 = *n - kk + 1;
00371                 zswap_(&i__1, &w[kk + kkw * w_dim1], ldw, &w[kp + kkw * 
00372                         w_dim1], ldw);
00373             }
00374 
00375             if (kstep == 1) {
00376 
00377 /*              1-by-1 pivot block D(k): column KW of W now holds */
00378 
00379 /*              W(k) = U(k)*D(k) */
00380 
00381 /*              where U(k) is the k-th column of U */
00382 
00383 /*              Store U(k) in column k of A */
00384 
00385                 zcopy_(&k, &w[kw * w_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &
00386                         c__1);
00387                 i__1 = k + k * a_dim1;
00388                 r1 = 1. / a[i__1].r;
00389                 i__1 = k - 1;
00390                 zdscal_(&i__1, &r1, &a[k * a_dim1 + 1], &c__1);
00391 
00392 /*              Conjugate W(k) */
00393 
00394                 i__1 = k - 1;
00395                 zlacgv_(&i__1, &w[kw * w_dim1 + 1], &c__1);
00396             } else {
00397 
00398 /*              2-by-2 pivot block D(k): columns KW and KW-1 of W now */
00399 /*              hold */
00400 
00401 /*              ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
00402 
00403 /*              where U(k) and U(k-1) are the k-th and (k-1)-th columns */
00404 /*              of U */
00405 
00406                 if (k > 2) {
00407 
00408 /*                 Store U(k) and U(k-1) in columns k and k-1 of A */
00409 
00410                     i__1 = k - 1 + kw * w_dim1;
00411                     d21.r = w[i__1].r, d21.i = w[i__1].i;
00412                     d_cnjg(&z__2, &d21);
00413                     z_div(&z__1, &w[k + kw * w_dim1], &z__2);
00414                     d11.r = z__1.r, d11.i = z__1.i;
00415                     z_div(&z__1, &w[k - 1 + (kw - 1) * w_dim1], &d21);
00416                     d22.r = z__1.r, d22.i = z__1.i;
00417                     z__1.r = d11.r * d22.r - d11.i * d22.i, z__1.i = d11.r * 
00418                             d22.i + d11.i * d22.r;
00419                     t = 1. / (z__1.r - 1.);
00420                     z__2.r = t, z__2.i = 0.;
00421                     z_div(&z__1, &z__2, &d21);
00422                     d21.r = z__1.r, d21.i = z__1.i;
00423                     i__1 = k - 2;
00424                     for (j = 1; j <= i__1; ++j) {
00425                         i__2 = j + (k - 1) * a_dim1;
00426                         i__3 = j + (kw - 1) * w_dim1;
00427                         z__3.r = d11.r * w[i__3].r - d11.i * w[i__3].i, 
00428                                 z__3.i = d11.r * w[i__3].i + d11.i * w[i__3]
00429                                 .r;
00430                         i__4 = j + kw * w_dim1;
00431                         z__2.r = z__3.r - w[i__4].r, z__2.i = z__3.i - w[i__4]
00432                                 .i;
00433                         z__1.r = d21.r * z__2.r - d21.i * z__2.i, z__1.i = 
00434                                 d21.r * z__2.i + d21.i * z__2.r;
00435                         a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00436                         i__2 = j + k * a_dim1;
00437                         d_cnjg(&z__2, &d21);
00438                         i__3 = j + kw * w_dim1;
00439                         z__4.r = d22.r * w[i__3].r - d22.i * w[i__3].i, 
00440                                 z__4.i = d22.r * w[i__3].i + d22.i * w[i__3]
00441                                 .r;
00442                         i__4 = j + (kw - 1) * w_dim1;
00443                         z__3.r = z__4.r - w[i__4].r, z__3.i = z__4.i - w[i__4]
00444                                 .i;
00445                         z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = 
00446                                 z__2.r * z__3.i + z__2.i * z__3.r;
00447                         a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00448 /* L20: */
00449                     }
00450                 }
00451 
00452 /*              Copy D(k) to A */
00453 
00454                 i__1 = k - 1 + (k - 1) * a_dim1;
00455                 i__2 = k - 1 + (kw - 1) * w_dim1;
00456                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00457                 i__1 = k - 1 + k * a_dim1;
00458                 i__2 = k - 1 + kw * w_dim1;
00459                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00460                 i__1 = k + k * a_dim1;
00461                 i__2 = k + kw * w_dim1;
00462                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00463 
00464 /*              Conjugate W(k) and W(k-1) */
00465 
00466                 i__1 = k - 1;
00467                 zlacgv_(&i__1, &w[kw * w_dim1 + 1], &c__1);
00468                 i__1 = k - 2;
00469                 zlacgv_(&i__1, &w[(kw - 1) * w_dim1 + 1], &c__1);
00470             }
00471         }
00472 
00473 /*        Store details of the interchanges in IPIV */
00474 
00475         if (kstep == 1) {
00476             ipiv[k] = kp;
00477         } else {
00478             ipiv[k] = -kp;
00479             ipiv[k - 1] = -kp;
00480         }
00481 
00482 /*        Decrease K and return to the start of the main loop */
00483 
00484         k -= kstep;
00485         goto L10;
00486 
00487 L30:
00488 
00489 /*        Update the upper triangle of A11 (= A(1:k,1:k)) as */
00490 
00491 /*        A11 := A11 - U12*D*U12' = A11 - U12*W' */
00492 
00493 /*        computing blocks of NB columns at a time (note that conjg(W) is */
00494 /*        actually stored) */
00495 
00496         i__1 = -(*nb);
00497         for (j = (k - 1) / *nb * *nb + 1; i__1 < 0 ? j >= 1 : j <= 1; j += 
00498                 i__1) {
00499 /* Computing MIN */
00500             i__2 = *nb, i__3 = k - j + 1;
00501             jb = min(i__2,i__3);
00502 
00503 /*           Update the upper triangle of the diagonal block */
00504 
00505             i__2 = j + jb - 1;
00506             for (jj = j; jj <= i__2; ++jj) {
00507                 i__3 = jj + jj * a_dim1;
00508                 i__4 = jj + jj * a_dim1;
00509                 d__1 = a[i__4].r;
00510                 a[i__3].r = d__1, a[i__3].i = 0.;
00511                 i__3 = jj - j + 1;
00512                 i__4 = *n - k;
00513                 z__1.r = -1., z__1.i = -0.;
00514                 zgemv_("No transpose", &i__3, &i__4, &z__1, &a[j + (k + 1) * 
00515                         a_dim1], lda, &w[jj + (kw + 1) * w_dim1], ldw, &c_b1, 
00516                         &a[j + jj * a_dim1], &c__1);
00517                 i__3 = jj + jj * a_dim1;
00518                 i__4 = jj + jj * a_dim1;
00519                 d__1 = a[i__4].r;
00520                 a[i__3].r = d__1, a[i__3].i = 0.;
00521 /* L40: */
00522             }
00523 
00524 /*           Update the rectangular superdiagonal block */
00525 
00526             i__2 = j - 1;
00527             i__3 = *n - k;
00528             z__1.r = -1., z__1.i = -0.;
00529             zgemm_("No transpose", "Transpose", &i__2, &jb, &i__3, &z__1, &a[(
00530                     k + 1) * a_dim1 + 1], lda, &w[j + (kw + 1) * w_dim1], ldw, 
00531                      &c_b1, &a[j * a_dim1 + 1], lda);
00532 /* L50: */
00533         }
00534 
00535 /*        Put U12 in standard form by partially undoing the interchanges */
00536 /*        in columns k+1:n */
00537 
00538         j = k + 1;
00539 L60:
00540         jj = j;
00541         jp = ipiv[j];
00542         if (jp < 0) {
00543             jp = -jp;
00544             ++j;
00545         }
00546         ++j;
00547         if (jp != jj && j <= *n) {
00548             i__1 = *n - j + 1;
00549             zswap_(&i__1, &a[jp + j * a_dim1], lda, &a[jj + j * a_dim1], lda);
00550         }
00551         if (j <= *n) {
00552             goto L60;
00553         }
00554 
00555 /*        Set KB to the number of columns factorized */
00556 
00557         *kb = *n - k;
00558 
00559     } else {
00560 
00561 /*        Factorize the leading columns of A using the lower triangle */
00562 /*        of A and working forwards, and compute the matrix W = L21*D */
00563 /*        for use in updating A22 (note that conjg(W) is actually stored) */
00564 
00565 /*        K is the main loop index, increasing from 1 in steps of 1 or 2 */
00566 
00567         k = 1;
00568 L70:
00569 
00570 /*        Exit from loop */
00571 
00572         if (k >= *nb && *nb < *n || k > *n) {
00573             goto L90;
00574         }
00575 
00576 /*        Copy column K of A to column K of W and update it */
00577 
00578         i__1 = k + k * w_dim1;
00579         i__2 = k + k * a_dim1;
00580         d__1 = a[i__2].r;
00581         w[i__1].r = d__1, w[i__1].i = 0.;
00582         if (k < *n) {
00583             i__1 = *n - k;
00584             zcopy_(&i__1, &a[k + 1 + k * a_dim1], &c__1, &w[k + 1 + k * 
00585                     w_dim1], &c__1);
00586         }
00587         i__1 = *n - k + 1;
00588         i__2 = k - 1;
00589         z__1.r = -1., z__1.i = -0.;
00590         zgemv_("No transpose", &i__1, &i__2, &z__1, &a[k + a_dim1], lda, &w[k 
00591                 + w_dim1], ldw, &c_b1, &w[k + k * w_dim1], &c__1);
00592         i__1 = k + k * w_dim1;
00593         i__2 = k + k * w_dim1;
00594         d__1 = w[i__2].r;
00595         w[i__1].r = d__1, w[i__1].i = 0.;
00596 
00597         kstep = 1;
00598 
00599 /*        Determine rows and columns to be interchanged and whether */
00600 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00601 
00602         i__1 = k + k * w_dim1;
00603         absakk = (d__1 = w[i__1].r, abs(d__1));
00604 
00605 /*        IMAX is the row-index of the largest off-diagonal element in */
00606 /*        column K, and COLMAX is its absolute value */
00607 
00608         if (k < *n) {
00609             i__1 = *n - k;
00610             imax = k + izamax_(&i__1, &w[k + 1 + k * w_dim1], &c__1);
00611             i__1 = imax + k * w_dim1;
00612             colmax = (d__1 = w[i__1].r, abs(d__1)) + (d__2 = d_imag(&w[imax + 
00613                     k * w_dim1]), abs(d__2));
00614         } else {
00615             colmax = 0.;
00616         }
00617 
00618         if (max(absakk,colmax) == 0.) {
00619 
00620 /*           Column K is zero: set INFO and continue */
00621 
00622             if (*info == 0) {
00623                 *info = k;
00624             }
00625             kp = k;
00626             i__1 = k + k * a_dim1;
00627             i__2 = k + k * a_dim1;
00628             d__1 = a[i__2].r;
00629             a[i__1].r = d__1, a[i__1].i = 0.;
00630         } else {
00631             if (absakk >= alpha * colmax) {
00632 
00633 /*              no interchange, use 1-by-1 pivot block */
00634 
00635                 kp = k;
00636             } else {
00637 
00638 /*              Copy column IMAX to column K+1 of W and update it */
00639 
00640                 i__1 = imax - k;
00641                 zcopy_(&i__1, &a[imax + k * a_dim1], lda, &w[k + (k + 1) * 
00642                         w_dim1], &c__1);
00643                 i__1 = imax - k;
00644                 zlacgv_(&i__1, &w[k + (k + 1) * w_dim1], &c__1);
00645                 i__1 = imax + (k + 1) * w_dim1;
00646                 i__2 = imax + imax * a_dim1;
00647                 d__1 = a[i__2].r;
00648                 w[i__1].r = d__1, w[i__1].i = 0.;
00649                 if (imax < *n) {
00650                     i__1 = *n - imax;
00651                     zcopy_(&i__1, &a[imax + 1 + imax * a_dim1], &c__1, &w[
00652                             imax + 1 + (k + 1) * w_dim1], &c__1);
00653                 }
00654                 i__1 = *n - k + 1;
00655                 i__2 = k - 1;
00656                 z__1.r = -1., z__1.i = -0.;
00657                 zgemv_("No transpose", &i__1, &i__2, &z__1, &a[k + a_dim1], 
00658                         lda, &w[imax + w_dim1], ldw, &c_b1, &w[k + (k + 1) * 
00659                         w_dim1], &c__1);
00660                 i__1 = imax + (k + 1) * w_dim1;
00661                 i__2 = imax + (k + 1) * w_dim1;
00662                 d__1 = w[i__2].r;
00663                 w[i__1].r = d__1, w[i__1].i = 0.;
00664 
00665 /*              JMAX is the column-index of the largest off-diagonal */
00666 /*              element in row IMAX, and ROWMAX is its absolute value */
00667 
00668                 i__1 = imax - k;
00669                 jmax = k - 1 + izamax_(&i__1, &w[k + (k + 1) * w_dim1], &c__1)
00670                         ;
00671                 i__1 = jmax + (k + 1) * w_dim1;
00672                 rowmax = (d__1 = w[i__1].r, abs(d__1)) + (d__2 = d_imag(&w[
00673                         jmax + (k + 1) * w_dim1]), abs(d__2));
00674                 if (imax < *n) {
00675                     i__1 = *n - imax;
00676                     jmax = imax + izamax_(&i__1, &w[imax + 1 + (k + 1) * 
00677                             w_dim1], &c__1);
00678 /* Computing MAX */
00679                     i__1 = jmax + (k + 1) * w_dim1;
00680                     d__3 = rowmax, d__4 = (d__1 = w[i__1].r, abs(d__1)) + (
00681                             d__2 = d_imag(&w[jmax + (k + 1) * w_dim1]), abs(
00682                             d__2));
00683                     rowmax = max(d__3,d__4);
00684                 }
00685 
00686                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00687 
00688 /*                 no interchange, use 1-by-1 pivot block */
00689 
00690                     kp = k;
00691                 } else /* if(complicated condition) */ {
00692                     i__1 = imax + (k + 1) * w_dim1;
00693                     if ((d__1 = w[i__1].r, abs(d__1)) >= alpha * rowmax) {
00694 
00695 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00696 /*                 pivot block */
00697 
00698                         kp = imax;
00699 
00700 /*                 copy column K+1 of W to column K */
00701 
00702                         i__1 = *n - k + 1;
00703                         zcopy_(&i__1, &w[k + (k + 1) * w_dim1], &c__1, &w[k + 
00704                                 k * w_dim1], &c__1);
00705                     } else {
00706 
00707 /*                 interchange rows and columns K+1 and IMAX, use 2-by-2 */
00708 /*                 pivot block */
00709 
00710                         kp = imax;
00711                         kstep = 2;
00712                     }
00713                 }
00714             }
00715 
00716             kk = k + kstep - 1;
00717 
00718 /*           Updated column KP is already stored in column KK of W */
00719 
00720             if (kp != kk) {
00721 
00722 /*              Copy non-updated column KK to column KP */
00723 
00724                 i__1 = kp + kp * a_dim1;
00725                 i__2 = kk + kk * a_dim1;
00726                 d__1 = a[i__2].r;
00727                 a[i__1].r = d__1, a[i__1].i = 0.;
00728                 i__1 = kp - kk - 1;
00729                 zcopy_(&i__1, &a[kk + 1 + kk * a_dim1], &c__1, &a[kp + (kk + 
00730                         1) * a_dim1], lda);
00731                 i__1 = kp - kk - 1;
00732                 zlacgv_(&i__1, &a[kp + (kk + 1) * a_dim1], lda);
00733                 if (kp < *n) {
00734                     i__1 = *n - kp;
00735                     zcopy_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + 1 
00736                             + kp * a_dim1], &c__1);
00737                 }
00738 
00739 /*              Interchange rows KK and KP in first KK columns of A and W */
00740 
00741                 i__1 = kk - 1;
00742                 zswap_(&i__1, &a[kk + a_dim1], lda, &a[kp + a_dim1], lda);
00743                 zswap_(&kk, &w[kk + w_dim1], ldw, &w[kp + w_dim1], ldw);
00744             }
00745 
00746             if (kstep == 1) {
00747 
00748 /*              1-by-1 pivot block D(k): column k of W now holds */
00749 
00750 /*              W(k) = L(k)*D(k) */
00751 
00752 /*              where L(k) is the k-th column of L */
00753 
00754 /*              Store L(k) in column k of A */
00755 
00756                 i__1 = *n - k + 1;
00757                 zcopy_(&i__1, &w[k + k * w_dim1], &c__1, &a[k + k * a_dim1], &
00758                         c__1);
00759                 if (k < *n) {
00760                     i__1 = k + k * a_dim1;
00761                     r1 = 1. / a[i__1].r;
00762                     i__1 = *n - k;
00763                     zdscal_(&i__1, &r1, &a[k + 1 + k * a_dim1], &c__1);
00764 
00765 /*                 Conjugate W(k) */
00766 
00767                     i__1 = *n - k;
00768                     zlacgv_(&i__1, &w[k + 1 + k * w_dim1], &c__1);
00769                 }
00770             } else {
00771 
00772 /*              2-by-2 pivot block D(k): columns k and k+1 of W now hold */
00773 
00774 /*              ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
00775 
00776 /*              where L(k) and L(k+1) are the k-th and (k+1)-th columns */
00777 /*              of L */
00778 
00779                 if (k < *n - 1) {
00780 
00781 /*                 Store L(k) and L(k+1) in columns k and k+1 of A */
00782 
00783                     i__1 = k + 1 + k * w_dim1;
00784                     d21.r = w[i__1].r, d21.i = w[i__1].i;
00785                     z_div(&z__1, &w[k + 1 + (k + 1) * w_dim1], &d21);
00786                     d11.r = z__1.r, d11.i = z__1.i;
00787                     d_cnjg(&z__2, &d21);
00788                     z_div(&z__1, &w[k + k * w_dim1], &z__2);
00789                     d22.r = z__1.r, d22.i = z__1.i;
00790                     z__1.r = d11.r * d22.r - d11.i * d22.i, z__1.i = d11.r * 
00791                             d22.i + d11.i * d22.r;
00792                     t = 1. / (z__1.r - 1.);
00793                     z__2.r = t, z__2.i = 0.;
00794                     z_div(&z__1, &z__2, &d21);
00795                     d21.r = z__1.r, d21.i = z__1.i;
00796                     i__1 = *n;
00797                     for (j = k + 2; j <= i__1; ++j) {
00798                         i__2 = j + k * a_dim1;
00799                         d_cnjg(&z__2, &d21);
00800                         i__3 = j + k * w_dim1;
00801                         z__4.r = d11.r * w[i__3].r - d11.i * w[i__3].i, 
00802                                 z__4.i = d11.r * w[i__3].i + d11.i * w[i__3]
00803                                 .r;
00804                         i__4 = j + (k + 1) * w_dim1;
00805                         z__3.r = z__4.r - w[i__4].r, z__3.i = z__4.i - w[i__4]
00806                                 .i;
00807                         z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = 
00808                                 z__2.r * z__3.i + z__2.i * z__3.r;
00809                         a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00810                         i__2 = j + (k + 1) * a_dim1;
00811                         i__3 = j + (k + 1) * w_dim1;
00812                         z__3.r = d22.r * w[i__3].r - d22.i * w[i__3].i, 
00813                                 z__3.i = d22.r * w[i__3].i + d22.i * w[i__3]
00814                                 .r;
00815                         i__4 = j + k * w_dim1;
00816                         z__2.r = z__3.r - w[i__4].r, z__2.i = z__3.i - w[i__4]
00817                                 .i;
00818                         z__1.r = d21.r * z__2.r - d21.i * z__2.i, z__1.i = 
00819                                 d21.r * z__2.i + d21.i * z__2.r;
00820                         a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00821 /* L80: */
00822                     }
00823                 }
00824 
00825 /*              Copy D(k) to A */
00826 
00827                 i__1 = k + k * a_dim1;
00828                 i__2 = k + k * w_dim1;
00829                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00830                 i__1 = k + 1 + k * a_dim1;
00831                 i__2 = k + 1 + k * w_dim1;
00832                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00833                 i__1 = k + 1 + (k + 1) * a_dim1;
00834                 i__2 = k + 1 + (k + 1) * w_dim1;
00835                 a[i__1].r = w[i__2].r, a[i__1].i = w[i__2].i;
00836 
00837 /*              Conjugate W(k) and W(k+1) */
00838 
00839                 i__1 = *n - k;
00840                 zlacgv_(&i__1, &w[k + 1 + k * w_dim1], &c__1);
00841                 i__1 = *n - k - 1;
00842                 zlacgv_(&i__1, &w[k + 2 + (k + 1) * w_dim1], &c__1);
00843             }
00844         }
00845 
00846 /*        Store details of the interchanges in IPIV */
00847 
00848         if (kstep == 1) {
00849             ipiv[k] = kp;
00850         } else {
00851             ipiv[k] = -kp;
00852             ipiv[k + 1] = -kp;
00853         }
00854 
00855 /*        Increase K and return to the start of the main loop */
00856 
00857         k += kstep;
00858         goto L70;
00859 
00860 L90:
00861 
00862 /*        Update the lower triangle of A22 (= A(k:n,k:n)) as */
00863 
00864 /*        A22 := A22 - L21*D*L21' = A22 - L21*W' */
00865 
00866 /*        computing blocks of NB columns at a time (note that conjg(W) is */
00867 /*        actually stored) */
00868 
00869         i__1 = *n;
00870         i__2 = *nb;
00871         for (j = k; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00872 /* Computing MIN */
00873             i__3 = *nb, i__4 = *n - j + 1;
00874             jb = min(i__3,i__4);
00875 
00876 /*           Update the lower triangle of the diagonal block */
00877 
00878             i__3 = j + jb - 1;
00879             for (jj = j; jj <= i__3; ++jj) {
00880                 i__4 = jj + jj * a_dim1;
00881                 i__5 = jj + jj * a_dim1;
00882                 d__1 = a[i__5].r;
00883                 a[i__4].r = d__1, a[i__4].i = 0.;
00884                 i__4 = j + jb - jj;
00885                 i__5 = k - 1;
00886                 z__1.r = -1., z__1.i = -0.;
00887                 zgemv_("No transpose", &i__4, &i__5, &z__1, &a[jj + a_dim1], 
00888                         lda, &w[jj + w_dim1], ldw, &c_b1, &a[jj + jj * a_dim1]
00889 , &c__1);
00890                 i__4 = jj + jj * a_dim1;
00891                 i__5 = jj + jj * a_dim1;
00892                 d__1 = a[i__5].r;
00893                 a[i__4].r = d__1, a[i__4].i = 0.;
00894 /* L100: */
00895             }
00896 
00897 /*           Update the rectangular subdiagonal block */
00898 
00899             if (j + jb <= *n) {
00900                 i__3 = *n - j - jb + 1;
00901                 i__4 = k - 1;
00902                 z__1.r = -1., z__1.i = -0.;
00903                 zgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &z__1, 
00904                         &a[j + jb + a_dim1], lda, &w[j + w_dim1], ldw, &c_b1, 
00905                         &a[j + jb + j * a_dim1], lda);
00906             }
00907 /* L110: */
00908         }
00909 
00910 /*        Put L21 in standard form by partially undoing the interchanges */
00911 /*        in columns 1:k-1 */
00912 
00913         j = k - 1;
00914 L120:
00915         jj = j;
00916         jp = ipiv[j];
00917         if (jp < 0) {
00918             jp = -jp;
00919             --j;
00920         }
00921         --j;
00922         if (jp != jj && j >= 1) {
00923             zswap_(&j, &a[jp + a_dim1], lda, &a[jj + a_dim1], lda);
00924         }
00925         if (j >= 1) {
00926             goto L120;
00927         }
00928 
00929 /*        Set KB to the number of columns factorized */
00930 
00931         *kb = k - 1;
00932 
00933     }
00934     return 0;
00935 
00936 /*     End of ZLAHEF */
00937 
00938 } /* zlahef_ */


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