csytf2.c
Go to the documentation of this file.
00001 /* csytf2.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 
00021 /* Subroutine */ int csytf2_(char *uplo, integer *n, complex *a, integer *lda, 
00022          integer *ipiv, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00026     real r__1, r__2, r__3, r__4;
00027     complex q__1, q__2, q__3, q__4;
00028 
00029     /* Builtin functions */
00030     double sqrt(doublereal), r_imag(complex *);
00031     void c_div(complex *, complex *, complex *);
00032 
00033     /* Local variables */
00034     integer i__, j, k;
00035     complex t, r1, d11, d12, d21, d22;
00036     integer kk, kp;
00037     complex wk, wkm1, wkp1;
00038     integer imax, jmax;
00039     extern /* Subroutine */ int csyr_(char *, integer *, complex *, complex *, 
00040              integer *, complex *, integer *);
00041     real alpha;
00042     extern /* Subroutine */ int cscal_(integer *, complex *, complex *, 
00043             integer *);
00044     extern logical lsame_(char *, char *);
00045     extern /* Subroutine */ int cswap_(integer *, complex *, integer *, 
00046             complex *, integer *);
00047     integer kstep;
00048     logical upper;
00049     real absakk;
00050     extern integer icamax_(integer *, complex *, integer *);
00051     extern /* Subroutine */ int xerbla_(char *, integer *);
00052     real colmax;
00053     extern logical sisnan_(real *);
00054     real rowmax;
00055 
00056 
00057 /*  -- LAPACK routine (version 3.2) -- */
00058 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00059 /*     November 2006 */
00060 
00061 /*     .. Scalar Arguments .. */
00062 /*     .. */
00063 /*     .. Array Arguments .. */
00064 /*     .. */
00065 
00066 /*  Purpose */
00067 /*  ======= */
00068 
00069 /*  CSYTF2 computes the factorization of a complex symmetric matrix A */
00070 /*  using the Bunch-Kaufman diagonal pivoting method: */
00071 
00072 /*     A = U*D*U'  or  A = L*D*L' */
00073 
00074 /*  where U (or L) is a product of permutation and unit upper (lower) */
00075 /*  triangular matrices, U' is the transpose of U, and D is symmetric and */
00076 /*  block diagonal with 1-by-1 and 2-by-2 diagonal blocks. */
00077 
00078 /*  This is the unblocked version of the algorithm, calling Level 2 BLAS. */
00079 
00080 /*  Arguments */
00081 /*  ========= */
00082 
00083 /*  UPLO    (input) CHARACTER*1 */
00084 /*          Specifies whether the upper or lower triangular part of the */
00085 /*          symmetric matrix A is stored: */
00086 /*          = 'U':  Upper triangular */
00087 /*          = 'L':  Lower triangular */
00088 
00089 /*  N       (input) INTEGER */
00090 /*          The order of the matrix A.  N >= 0. */
00091 
00092 /*  A       (input/output) COMPLEX array, dimension (LDA,N) */
00093 /*          On entry, the symmetric matrix A.  If UPLO = 'U', the leading */
00094 /*          n-by-n upper triangular part of A contains the upper */
00095 /*          triangular part of the matrix A, and the strictly lower */
00096 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00097 /*          leading n-by-n lower triangular part of A contains the lower */
00098 /*          triangular part of the matrix A, and the strictly upper */
00099 /*          triangular part of A is not referenced. */
00100 
00101 /*          On exit, the block diagonal matrix D and the multipliers used */
00102 /*          to obtain the factor U or L (see below for further details). */
00103 
00104 /*  LDA     (input) INTEGER */
00105 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00106 
00107 /*  IPIV    (output) INTEGER array, dimension (N) */
00108 /*          Details of the interchanges and the block structure of D. */
00109 /*          If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
00110 /*          interchanged and D(k,k) is a 1-by-1 diagonal block. */
00111 /*          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
00112 /*          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
00113 /*          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) = */
00114 /*          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
00115 /*          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
00116 
00117 /*  INFO    (output) INTEGER */
00118 /*          = 0: successful exit */
00119 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00120 /*          > 0: if INFO = k, D(k,k) is exactly zero.  The factorization */
00121 /*               has been completed, but the block diagonal matrix D is */
00122 /*               exactly singular, and division by zero will occur if it */
00123 /*               is used to solve a system of equations. */
00124 
00125 /*  Further Details */
00126 /*  =============== */
00127 
00128 /*  09-29-06 - patch from */
00129 /*    Bobby Cheng, MathWorks */
00130 
00131 /*    Replace l.209 and l.377 */
00132 /*         IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN */
00133 /*    by */
00134 /*         IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN */
00135 
00136 /*  1-96 - Based on modifications by J. Lewis, Boeing Computer Services */
00137 /*         Company */
00138 
00139 /*  If UPLO = 'U', then A = U*D*U', where */
00140 /*     U = P(n)*U(n)* ... *P(k)U(k)* ..., */
00141 /*  i.e., U is a product of terms P(k)*U(k), where k decreases from n to */
00142 /*  1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
00143 /*  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as */
00144 /*  defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */
00145 /*  that if the diagonal block D(k) is of order s (s = 1 or 2), then */
00146 
00147 /*             (   I    v    0   )   k-s */
00148 /*     U(k) =  (   0    I    0   )   s */
00149 /*             (   0    0    I   )   n-k */
00150 /*                k-s   s   n-k */
00151 
00152 /*  If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */
00153 /*  If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */
00154 /*  and A(k,k), and v overwrites A(1:k-2,k-1:k). */
00155 
00156 /*  If UPLO = 'L', then A = L*D*L', where */
00157 /*     L = P(1)*L(1)* ... *P(k)*L(k)* ..., */
00158 /*  i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */
00159 /*  n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
00160 /*  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as */
00161 /*  defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */
00162 /*  that if the diagonal block D(k) is of order s (s = 1 or 2), then */
00163 
00164 /*             (   I    0     0   )  k-1 */
00165 /*     L(k) =  (   0    I     0   )  s */
00166 /*             (   0    v     I   )  n-k-s+1 */
00167 /*                k-1   s  n-k-s+1 */
00168 
00169 /*  If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */
00170 /*  If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */
00171 /*  and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */
00172 
00173 /*  ===================================================================== */
00174 
00175 /*     .. Parameters .. */
00176 /*     .. */
00177 /*     .. Local Scalars .. */
00178 /*     .. */
00179 /*     .. External Functions .. */
00180 /*     .. */
00181 /*     .. External Subroutines .. */
00182 /*     .. */
00183 /*     .. Intrinsic Functions .. */
00184 /*     .. */
00185 /*     .. Statement Functions .. */
00186 /*     .. */
00187 /*     .. Statement Function definitions .. */
00188 /*     .. */
00189 /*     .. Executable Statements .. */
00190 
00191 /*     Test the input parameters. */
00192 
00193     /* Parameter adjustments */
00194     a_dim1 = *lda;
00195     a_offset = 1 + a_dim1;
00196     a -= a_offset;
00197     --ipiv;
00198 
00199     /* Function Body */
00200     *info = 0;
00201     upper = lsame_(uplo, "U");
00202     if (! upper && ! lsame_(uplo, "L")) {
00203         *info = -1;
00204     } else if (*n < 0) {
00205         *info = -2;
00206     } else if (*lda < max(1,*n)) {
00207         *info = -4;
00208     }
00209     if (*info != 0) {
00210         i__1 = -(*info);
00211         xerbla_("CSYTF2", &i__1);
00212         return 0;
00213     }
00214 
00215 /*     Initialize ALPHA for use in choosing pivot block size. */
00216 
00217     alpha = (sqrt(17.f) + 1.f) / 8.f;
00218 
00219     if (upper) {
00220 
00221 /*        Factorize A as U*D*U' using the upper triangle of A */
00222 
00223 /*        K is the main loop index, decreasing from N to 1 in steps of */
00224 /*        1 or 2 */
00225 
00226         k = *n;
00227 L10:
00228 
00229 /*        If K < 1, exit from loop */
00230 
00231         if (k < 1) {
00232             goto L70;
00233         }
00234         kstep = 1;
00235 
00236 /*        Determine rows and columns to be interchanged and whether */
00237 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00238 
00239         i__1 = k + k * a_dim1;
00240         absakk = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[k + k * 
00241                 a_dim1]), dabs(r__2));
00242 
00243 /*        IMAX is the row-index of the largest off-diagonal element in */
00244 /*        column K, and COLMAX is its absolute value */
00245 
00246         if (k > 1) {
00247             i__1 = k - 1;
00248             imax = icamax_(&i__1, &a[k * a_dim1 + 1], &c__1);
00249             i__1 = imax + k * a_dim1;
00250             colmax = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[imax 
00251                     + k * a_dim1]), dabs(r__2));
00252         } else {
00253             colmax = 0.f;
00254         }
00255 
00256         if (dmax(absakk,colmax) == 0.f || sisnan_(&absakk)) {
00257 
00258 /*           Column K is zero or NaN: set INFO and continue */
00259 
00260             if (*info == 0) {
00261                 *info = k;
00262             }
00263             kp = k;
00264         } else {
00265             if (absakk >= alpha * colmax) {
00266 
00267 /*              no interchange, use 1-by-1 pivot block */
00268 
00269                 kp = k;
00270             } else {
00271 
00272 /*              JMAX is the column-index of the largest off-diagonal */
00273 /*              element in row IMAX, and ROWMAX is its absolute value */
00274 
00275                 i__1 = k - imax;
00276                 jmax = imax + icamax_(&i__1, &a[imax + (imax + 1) * a_dim1], 
00277                         lda);
00278                 i__1 = imax + jmax * a_dim1;
00279                 rowmax = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[
00280                         imax + jmax * a_dim1]), dabs(r__2));
00281                 if (imax > 1) {
00282                     i__1 = imax - 1;
00283                     jmax = icamax_(&i__1, &a[imax * a_dim1 + 1], &c__1);
00284 /* Computing MAX */
00285                     i__1 = jmax + imax * a_dim1;
00286                     r__3 = rowmax, r__4 = (r__1 = a[i__1].r, dabs(r__1)) + (
00287                             r__2 = r_imag(&a[jmax + imax * a_dim1]), dabs(
00288                             r__2));
00289                     rowmax = dmax(r__3,r__4);
00290                 }
00291 
00292                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00293 
00294 /*                 no interchange, use 1-by-1 pivot block */
00295 
00296                     kp = k;
00297                 } else /* if(complicated condition) */ {
00298                     i__1 = imax + imax * a_dim1;
00299                     if ((r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[
00300                             imax + imax * a_dim1]), dabs(r__2)) >= alpha * 
00301                             rowmax) {
00302 
00303 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00304 /*                 pivot block */
00305 
00306                         kp = imax;
00307                     } else {
00308 
00309 /*                 interchange rows and columns K-1 and IMAX, use 2-by-2 */
00310 /*                 pivot block */
00311 
00312                         kp = imax;
00313                         kstep = 2;
00314                     }
00315                 }
00316             }
00317 
00318             kk = k - kstep + 1;
00319             if (kp != kk) {
00320 
00321 /*              Interchange rows and columns KK and KP in the leading */
00322 /*              submatrix A(1:k,1:k) */
00323 
00324                 i__1 = kp - 1;
00325                 cswap_(&i__1, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1 + 1], 
00326                          &c__1);
00327                 i__1 = kk - kp - 1;
00328                 cswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (kp + 
00329                         1) * a_dim1], lda);
00330                 i__1 = kk + kk * a_dim1;
00331                 t.r = a[i__1].r, t.i = a[i__1].i;
00332                 i__1 = kk + kk * a_dim1;
00333                 i__2 = kp + kp * a_dim1;
00334                 a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
00335                 i__1 = kp + kp * a_dim1;
00336                 a[i__1].r = t.r, a[i__1].i = t.i;
00337                 if (kstep == 2) {
00338                     i__1 = k - 1 + k * a_dim1;
00339                     t.r = a[i__1].r, t.i = a[i__1].i;
00340                     i__1 = k - 1 + k * a_dim1;
00341                     i__2 = kp + k * a_dim1;
00342                     a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
00343                     i__1 = kp + k * a_dim1;
00344                     a[i__1].r = t.r, a[i__1].i = t.i;
00345                 }
00346             }
00347 
00348 /*           Update the leading submatrix */
00349 
00350             if (kstep == 1) {
00351 
00352 /*              1-by-1 pivot block D(k): column k now holds */
00353 
00354 /*              W(k) = U(k)*D(k) */
00355 
00356 /*              where U(k) is the k-th column of U */
00357 
00358 /*              Perform a rank-1 update of A(1:k-1,1:k-1) as */
00359 
00360 /*              A := A - U(k)*D(k)*U(k)' = A - W(k)*1/D(k)*W(k)' */
00361 
00362                 c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
00363                 r1.r = q__1.r, r1.i = q__1.i;
00364                 i__1 = k - 1;
00365                 q__1.r = -r1.r, q__1.i = -r1.i;
00366                 csyr_(uplo, &i__1, &q__1, &a[k * a_dim1 + 1], &c__1, &a[
00367                         a_offset], lda);
00368 
00369 /*              Store U(k) in column k */
00370 
00371                 i__1 = k - 1;
00372                 cscal_(&i__1, &r1, &a[k * a_dim1 + 1], &c__1);
00373             } else {
00374 
00375 /*              2-by-2 pivot block D(k): columns k and k-1 now hold */
00376 
00377 /*              ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
00378 
00379 /*              where U(k) and U(k-1) are the k-th and (k-1)-th columns */
00380 /*              of U */
00381 
00382 /*              Perform a rank-2 update of A(1:k-2,1:k-2) as */
00383 
00384 /*              A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )' */
00385 /*                 = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )' */
00386 
00387                 if (k > 2) {
00388 
00389                     i__1 = k - 1 + k * a_dim1;
00390                     d12.r = a[i__1].r, d12.i = a[i__1].i;
00391                     c_div(&q__1, &a[k - 1 + (k - 1) * a_dim1], &d12);
00392                     d22.r = q__1.r, d22.i = q__1.i;
00393                     c_div(&q__1, &a[k + k * a_dim1], &d12);
00394                     d11.r = q__1.r, d11.i = q__1.i;
00395                     q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r * 
00396                             d22.i + d11.i * d22.r;
00397                     q__2.r = q__3.r - 1.f, q__2.i = q__3.i - 0.f;
00398                     c_div(&q__1, &c_b1, &q__2);
00399                     t.r = q__1.r, t.i = q__1.i;
00400                     c_div(&q__1, &t, &d12);
00401                     d12.r = q__1.r, d12.i = q__1.i;
00402 
00403                     for (j = k - 2; j >= 1; --j) {
00404                         i__1 = j + (k - 1) * a_dim1;
00405                         q__3.r = d11.r * a[i__1].r - d11.i * a[i__1].i, 
00406                                 q__3.i = d11.r * a[i__1].i + d11.i * a[i__1]
00407                                 .r;
00408                         i__2 = j + k * a_dim1;
00409                         q__2.r = q__3.r - a[i__2].r, q__2.i = q__3.i - a[i__2]
00410                                 .i;
00411                         q__1.r = d12.r * q__2.r - d12.i * q__2.i, q__1.i = 
00412                                 d12.r * q__2.i + d12.i * q__2.r;
00413                         wkm1.r = q__1.r, wkm1.i = q__1.i;
00414                         i__1 = j + k * a_dim1;
00415                         q__3.r = d22.r * a[i__1].r - d22.i * a[i__1].i, 
00416                                 q__3.i = d22.r * a[i__1].i + d22.i * a[i__1]
00417                                 .r;
00418                         i__2 = j + (k - 1) * a_dim1;
00419                         q__2.r = q__3.r - a[i__2].r, q__2.i = q__3.i - a[i__2]
00420                                 .i;
00421                         q__1.r = d12.r * q__2.r - d12.i * q__2.i, q__1.i = 
00422                                 d12.r * q__2.i + d12.i * q__2.r;
00423                         wk.r = q__1.r, wk.i = q__1.i;
00424                         for (i__ = j; i__ >= 1; --i__) {
00425                             i__1 = i__ + j * a_dim1;
00426                             i__2 = i__ + j * a_dim1;
00427                             i__3 = i__ + k * a_dim1;
00428                             q__3.r = a[i__3].r * wk.r - a[i__3].i * wk.i, 
00429                                     q__3.i = a[i__3].r * wk.i + a[i__3].i * 
00430                                     wk.r;
00431                             q__2.r = a[i__2].r - q__3.r, q__2.i = a[i__2].i - 
00432                                     q__3.i;
00433                             i__4 = i__ + (k - 1) * a_dim1;
00434                             q__4.r = a[i__4].r * wkm1.r - a[i__4].i * wkm1.i, 
00435                                     q__4.i = a[i__4].r * wkm1.i + a[i__4].i * 
00436                                     wkm1.r;
00437                             q__1.r = q__2.r - q__4.r, q__1.i = q__2.i - 
00438                                     q__4.i;
00439                             a[i__1].r = q__1.r, a[i__1].i = q__1.i;
00440 /* L20: */
00441                         }
00442                         i__1 = j + k * a_dim1;
00443                         a[i__1].r = wk.r, a[i__1].i = wk.i;
00444                         i__1 = j + (k - 1) * a_dim1;
00445                         a[i__1].r = wkm1.r, a[i__1].i = wkm1.i;
00446 /* L30: */
00447                     }
00448 
00449                 }
00450 
00451             }
00452         }
00453 
00454 /*        Store details of the interchanges in IPIV */
00455 
00456         if (kstep == 1) {
00457             ipiv[k] = kp;
00458         } else {
00459             ipiv[k] = -kp;
00460             ipiv[k - 1] = -kp;
00461         }
00462 
00463 /*        Decrease K and return to the start of the main loop */
00464 
00465         k -= kstep;
00466         goto L10;
00467 
00468     } else {
00469 
00470 /*        Factorize A as L*D*L' using the lower triangle of A */
00471 
00472 /*        K is the main loop index, increasing from 1 to N in steps of */
00473 /*        1 or 2 */
00474 
00475         k = 1;
00476 L40:
00477 
00478 /*        If K > N, exit from loop */
00479 
00480         if (k > *n) {
00481             goto L70;
00482         }
00483         kstep = 1;
00484 
00485 /*        Determine rows and columns to be interchanged and whether */
00486 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00487 
00488         i__1 = k + k * a_dim1;
00489         absakk = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[k + k * 
00490                 a_dim1]), dabs(r__2));
00491 
00492 /*        IMAX is the row-index of the largest off-diagonal element in */
00493 /*        column K, and COLMAX is its absolute value */
00494 
00495         if (k < *n) {
00496             i__1 = *n - k;
00497             imax = k + icamax_(&i__1, &a[k + 1 + k * a_dim1], &c__1);
00498             i__1 = imax + k * a_dim1;
00499             colmax = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[imax 
00500                     + k * a_dim1]), dabs(r__2));
00501         } else {
00502             colmax = 0.f;
00503         }
00504 
00505         if (dmax(absakk,colmax) == 0.f || sisnan_(&absakk)) {
00506 
00507 /*           Column K is zero or NaN: set INFO and continue */
00508 
00509             if (*info == 0) {
00510                 *info = k;
00511             }
00512             kp = k;
00513         } else {
00514             if (absakk >= alpha * colmax) {
00515 
00516 /*              no interchange, use 1-by-1 pivot block */
00517 
00518                 kp = k;
00519             } else {
00520 
00521 /*              JMAX is the column-index of the largest off-diagonal */
00522 /*              element in row IMAX, and ROWMAX is its absolute value */
00523 
00524                 i__1 = imax - k;
00525                 jmax = k - 1 + icamax_(&i__1, &a[imax + k * a_dim1], lda);
00526                 i__1 = imax + jmax * a_dim1;
00527                 rowmax = (r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[
00528                         imax + jmax * a_dim1]), dabs(r__2));
00529                 if (imax < *n) {
00530                     i__1 = *n - imax;
00531                     jmax = imax + icamax_(&i__1, &a[imax + 1 + imax * a_dim1], 
00532                              &c__1);
00533 /* Computing MAX */
00534                     i__1 = jmax + imax * a_dim1;
00535                     r__3 = rowmax, r__4 = (r__1 = a[i__1].r, dabs(r__1)) + (
00536                             r__2 = r_imag(&a[jmax + imax * a_dim1]), dabs(
00537                             r__2));
00538                     rowmax = dmax(r__3,r__4);
00539                 }
00540 
00541                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00542 
00543 /*                 no interchange, use 1-by-1 pivot block */
00544 
00545                     kp = k;
00546                 } else /* if(complicated condition) */ {
00547                     i__1 = imax + imax * a_dim1;
00548                     if ((r__1 = a[i__1].r, dabs(r__1)) + (r__2 = r_imag(&a[
00549                             imax + imax * a_dim1]), dabs(r__2)) >= alpha * 
00550                             rowmax) {
00551 
00552 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00553 /*                 pivot block */
00554 
00555                         kp = imax;
00556                     } else {
00557 
00558 /*                 interchange rows and columns K+1 and IMAX, use 2-by-2 */
00559 /*                 pivot block */
00560 
00561                         kp = imax;
00562                         kstep = 2;
00563                     }
00564                 }
00565             }
00566 
00567             kk = k + kstep - 1;
00568             if (kp != kk) {
00569 
00570 /*              Interchange rows and columns KK and KP in the trailing */
00571 /*              submatrix A(k:n,k:n) */
00572 
00573                 if (kp < *n) {
00574                     i__1 = *n - kp;
00575                     cswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + 1 
00576                             + kp * a_dim1], &c__1);
00577                 }
00578                 i__1 = kp - kk - 1;
00579                 cswap_(&i__1, &a[kk + 1 + kk * a_dim1], &c__1, &a[kp + (kk + 
00580                         1) * a_dim1], lda);
00581                 i__1 = kk + kk * a_dim1;
00582                 t.r = a[i__1].r, t.i = a[i__1].i;
00583                 i__1 = kk + kk * a_dim1;
00584                 i__2 = kp + kp * a_dim1;
00585                 a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
00586                 i__1 = kp + kp * a_dim1;
00587                 a[i__1].r = t.r, a[i__1].i = t.i;
00588                 if (kstep == 2) {
00589                     i__1 = k + 1 + k * a_dim1;
00590                     t.r = a[i__1].r, t.i = a[i__1].i;
00591                     i__1 = k + 1 + k * a_dim1;
00592                     i__2 = kp + k * a_dim1;
00593                     a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
00594                     i__1 = kp + k * a_dim1;
00595                     a[i__1].r = t.r, a[i__1].i = t.i;
00596                 }
00597             }
00598 
00599 /*           Update the trailing submatrix */
00600 
00601             if (kstep == 1) {
00602 
00603 /*              1-by-1 pivot block D(k): column k now holds */
00604 
00605 /*              W(k) = L(k)*D(k) */
00606 
00607 /*              where L(k) is the k-th column of L */
00608 
00609                 if (k < *n) {
00610 
00611 /*                 Perform a rank-1 update of A(k+1:n,k+1:n) as */
00612 
00613 /*                 A := A - L(k)*D(k)*L(k)' = A - W(k)*(1/D(k))*W(k)' */
00614 
00615                     c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
00616                     r1.r = q__1.r, r1.i = q__1.i;
00617                     i__1 = *n - k;
00618                     q__1.r = -r1.r, q__1.i = -r1.i;
00619                     csyr_(uplo, &i__1, &q__1, &a[k + 1 + k * a_dim1], &c__1, &
00620                             a[k + 1 + (k + 1) * a_dim1], lda);
00621 
00622 /*                 Store L(k) in column K */
00623 
00624                     i__1 = *n - k;
00625                     cscal_(&i__1, &r1, &a[k + 1 + k * a_dim1], &c__1);
00626                 }
00627             } else {
00628 
00629 /*              2-by-2 pivot block D(k) */
00630 
00631                 if (k < *n - 1) {
00632 
00633 /*                 Perform a rank-2 update of A(k+2:n,k+2:n) as */
00634 
00635 /*                 A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )' */
00636 /*                    = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )' */
00637 
00638 /*                 where L(k) and L(k+1) are the k-th and (k+1)-th */
00639 /*                 columns of L */
00640 
00641                     i__1 = k + 1 + k * a_dim1;
00642                     d21.r = a[i__1].r, d21.i = a[i__1].i;
00643                     c_div(&q__1, &a[k + 1 + (k + 1) * a_dim1], &d21);
00644                     d11.r = q__1.r, d11.i = q__1.i;
00645                     c_div(&q__1, &a[k + k * a_dim1], &d21);
00646                     d22.r = q__1.r, d22.i = q__1.i;
00647                     q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r * 
00648                             d22.i + d11.i * d22.r;
00649                     q__2.r = q__3.r - 1.f, q__2.i = q__3.i - 0.f;
00650                     c_div(&q__1, &c_b1, &q__2);
00651                     t.r = q__1.r, t.i = q__1.i;
00652                     c_div(&q__1, &t, &d21);
00653                     d21.r = q__1.r, d21.i = q__1.i;
00654 
00655                     i__1 = *n;
00656                     for (j = k + 2; j <= i__1; ++j) {
00657                         i__2 = j + k * a_dim1;
00658                         q__3.r = d11.r * a[i__2].r - d11.i * a[i__2].i, 
00659                                 q__3.i = d11.r * a[i__2].i + d11.i * a[i__2]
00660                                 .r;
00661                         i__3 = j + (k + 1) * a_dim1;
00662                         q__2.r = q__3.r - a[i__3].r, q__2.i = q__3.i - a[i__3]
00663                                 .i;
00664                         q__1.r = d21.r * q__2.r - d21.i * q__2.i, q__1.i = 
00665                                 d21.r * q__2.i + d21.i * q__2.r;
00666                         wk.r = q__1.r, wk.i = q__1.i;
00667                         i__2 = j + (k + 1) * a_dim1;
00668                         q__3.r = d22.r * a[i__2].r - d22.i * a[i__2].i, 
00669                                 q__3.i = d22.r * a[i__2].i + d22.i * a[i__2]
00670                                 .r;
00671                         i__3 = j + k * a_dim1;
00672                         q__2.r = q__3.r - a[i__3].r, q__2.i = q__3.i - a[i__3]
00673                                 .i;
00674                         q__1.r = d21.r * q__2.r - d21.i * q__2.i, q__1.i = 
00675                                 d21.r * q__2.i + d21.i * q__2.r;
00676                         wkp1.r = q__1.r, wkp1.i = q__1.i;
00677                         i__2 = *n;
00678                         for (i__ = j; i__ <= i__2; ++i__) {
00679                             i__3 = i__ + j * a_dim1;
00680                             i__4 = i__ + j * a_dim1;
00681                             i__5 = i__ + k * a_dim1;
00682                             q__3.r = a[i__5].r * wk.r - a[i__5].i * wk.i, 
00683                                     q__3.i = a[i__5].r * wk.i + a[i__5].i * 
00684                                     wk.r;
00685                             q__2.r = a[i__4].r - q__3.r, q__2.i = a[i__4].i - 
00686                                     q__3.i;
00687                             i__6 = i__ + (k + 1) * a_dim1;
00688                             q__4.r = a[i__6].r * wkp1.r - a[i__6].i * wkp1.i, 
00689                                     q__4.i = a[i__6].r * wkp1.i + a[i__6].i * 
00690                                     wkp1.r;
00691                             q__1.r = q__2.r - q__4.r, q__1.i = q__2.i - 
00692                                     q__4.i;
00693                             a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00694 /* L50: */
00695                         }
00696                         i__2 = j + k * a_dim1;
00697                         a[i__2].r = wk.r, a[i__2].i = wk.i;
00698                         i__2 = j + (k + 1) * a_dim1;
00699                         a[i__2].r = wkp1.r, a[i__2].i = wkp1.i;
00700 /* L60: */
00701                     }
00702                 }
00703             }
00704         }
00705 
00706 /*        Store details of the interchanges in IPIV */
00707 
00708         if (kstep == 1) {
00709             ipiv[k] = kp;
00710         } else {
00711             ipiv[k] = -kp;
00712             ipiv[k + 1] = -kp;
00713         }
00714 
00715 /*        Increase K and return to the start of the main loop */
00716 
00717         k += kstep;
00718         goto L40;
00719 
00720     }
00721 
00722 L70:
00723     return 0;
00724 
00725 /*     End of CSYTF2 */
00726 
00727 } /* csytf2_ */


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