slasyf.c
Go to the documentation of this file.
00001 /* slasyf.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static real c_b8 = -1.f;
00020 static real c_b9 = 1.f;
00021 
00022 /* Subroutine */ int slasyf_(char *uplo, integer *n, integer *nb, integer *kb, 
00023          real *a, integer *lda, integer *ipiv, real *w, integer *ldw, integer 
00024         *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, w_dim1, w_offset, i__1, i__2, i__3, i__4, i__5;
00028     real r__1, r__2, r__3;
00029 
00030     /* Builtin functions */
00031     double sqrt(doublereal);
00032 
00033     /* Local variables */
00034     integer j, k;
00035     real t, r1, d11, d21, d22;
00036     integer jb, jj, kk, jp, kp, kw, kkw, imax, jmax;
00037     real alpha;
00038     extern logical lsame_(char *, char *);
00039     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00040             sgemm_(char *, char *, integer *, integer *, integer *, real *, 
00041             real *, integer *, real *, integer *, real *, real *, integer *), sgemv_(char *, integer *, integer *, real *, 
00042             real *, integer *, real *, integer *, real *, real *, integer *);
00043     integer kstep;
00044     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00045             integer *), sswap_(integer *, real *, integer *, real *, integer *
00046 );
00047     real absakk;
00048     extern integer isamax_(integer *, real *, integer *);
00049     real colmax, rowmax;
00050 
00051 
00052 /*  -- LAPACK routine (version 3.2) -- */
00053 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00054 /*     November 2006 */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  SLASYF computes a partial factorization of a real symmetric matrix A */
00065 /*  using the Bunch-Kaufman diagonal pivoting method. The partial */
00066 /*  factorization has the form: */
00067 
00068 /*  A  =  ( I  U12 ) ( A11  0  ) (  I    0   )  if UPLO = 'U', or: */
00069 /*        ( 0  U22 ) (  0   D  ) ( U12' U22' ) */
00070 
00071 /*  A  =  ( L11  0 ) (  D   0  ) ( L11' L21' )  if UPLO = 'L' */
00072 /*        ( L21  I ) (  0  A22 ) (  0    I   ) */
00073 
00074 /*  where the order of D is at most NB. The actual order is returned in */
00075 /*  the argument KB, and is either NB or NB-1, or N if N <= NB. */
00076 
00077 /*  SLASYF is an auxiliary routine called by SSYTRF. It uses blocked code */
00078 /*  (calling Level 3 BLAS) to update the submatrix A11 (if UPLO = 'U') or */
00079 /*  A22 (if UPLO = 'L'). */
00080 
00081 /*  Arguments */
00082 /*  ========= */
00083 
00084 /*  UPLO    (input) CHARACTER*1 */
00085 /*          Specifies whether the upper or lower triangular part of the */
00086 /*          symmetric matrix A is stored: */
00087 /*          = 'U':  Upper triangular */
00088 /*          = 'L':  Lower triangular */
00089 
00090 /*  N       (input) INTEGER */
00091 /*          The order of the matrix A.  N >= 0. */
00092 
00093 /*  NB      (input) INTEGER */
00094 /*          The maximum number of columns of the matrix A that should be */
00095 /*          factored.  NB should be at least 2 to allow for 2-by-2 pivot */
00096 /*          blocks. */
00097 
00098 /*  KB      (output) INTEGER */
00099 /*          The number of columns of A that were actually factored. */
00100 /*          KB is either NB-1 or NB, or N if N <= NB. */
00101 
00102 /*  A       (input/output) REAL array, dimension (LDA,N) */
00103 /*          On entry, the symmetric matrix A.  If UPLO = 'U', the leading */
00104 /*          n-by-n upper triangular part of A contains the upper */
00105 /*          triangular part of the matrix A, and the strictly lower */
00106 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00107 /*          leading n-by-n lower triangular part of A contains the lower */
00108 /*          triangular part of the matrix A, and the strictly upper */
00109 /*          triangular part of A is not referenced. */
00110 /*          On exit, A contains details of the partial factorization. */
00111 
00112 /*  LDA     (input) INTEGER */
00113 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00114 
00115 /*  IPIV    (output) INTEGER array, dimension (N) */
00116 /*          Details of the interchanges and the block structure of D. */
00117 /*          If UPLO = 'U', only the last KB elements of IPIV are set; */
00118 /*          if UPLO = 'L', only the first KB elements are set. */
00119 
00120 /*          If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
00121 /*          interchanged and D(k,k) is a 1-by-1 diagonal block. */
00122 /*          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
00123 /*          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
00124 /*          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) = */
00125 /*          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
00126 /*          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
00127 
00128 /*  W       (workspace) REAL array, dimension (LDW,NB) */
00129 
00130 /*  LDW     (input) INTEGER */
00131 /*          The leading dimension of the array W.  LDW >= max(1,N). */
00132 
00133 /*  INFO    (output) INTEGER */
00134 /*          = 0: successful exit */
00135 /*          > 0: if INFO = k, D(k,k) is exactly zero.  The factorization */
00136 /*               has been completed, but the block diagonal matrix D is */
00137 /*               exactly singular. */
00138 
00139 /*  ===================================================================== */
00140 
00141 /*     .. Parameters .. */
00142 /*     .. */
00143 /*     .. Local Scalars .. */
00144 /*     .. */
00145 /*     .. External Functions .. */
00146 /*     .. */
00147 /*     .. External Subroutines .. */
00148 /*     .. */
00149 /*     .. Intrinsic Functions .. */
00150 /*     .. */
00151 /*     .. Executable Statements .. */
00152 
00153     /* Parameter adjustments */
00154     a_dim1 = *lda;
00155     a_offset = 1 + a_dim1;
00156     a -= a_offset;
00157     --ipiv;
00158     w_dim1 = *ldw;
00159     w_offset = 1 + w_dim1;
00160     w -= w_offset;
00161 
00162     /* Function Body */
00163     *info = 0;
00164 
00165 /*     Initialize ALPHA for use in choosing pivot block size. */
00166 
00167     alpha = (sqrt(17.f) + 1.f) / 8.f;
00168 
00169     if (lsame_(uplo, "U")) {
00170 
00171 /*        Factorize the trailing columns of A using the upper triangle */
00172 /*        of A and working backwards, and compute the matrix W = U12*D */
00173 /*        for use in updating A11 */
00174 
00175 /*        K is the main loop index, decreasing from N in steps of 1 or 2 */
00176 
00177 /*        KW is the column of W which corresponds to column K of A */
00178 
00179         k = *n;
00180 L10:
00181         kw = *nb + k - *n;
00182 
00183 /*        Exit from loop */
00184 
00185         if (k <= *n - *nb + 1 && *nb < *n || k < 1) {
00186             goto L30;
00187         }
00188 
00189 /*        Copy column K of A to column KW of W and update it */
00190 
00191         scopy_(&k, &a[k * a_dim1 + 1], &c__1, &w[kw * w_dim1 + 1], &c__1);
00192         if (k < *n) {
00193             i__1 = *n - k;
00194             sgemv_("No transpose", &k, &i__1, &c_b8, &a[(k + 1) * a_dim1 + 1], 
00195                      lda, &w[k + (kw + 1) * w_dim1], ldw, &c_b9, &w[kw * 
00196                     w_dim1 + 1], &c__1);
00197         }
00198 
00199         kstep = 1;
00200 
00201 /*        Determine rows and columns to be interchanged and whether */
00202 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00203 
00204         absakk = (r__1 = w[k + kw * w_dim1], dabs(r__1));
00205 
00206 /*        IMAX is the row-index of the largest off-diagonal element in */
00207 /*        column K, and COLMAX is its absolute value */
00208 
00209         if (k > 1) {
00210             i__1 = k - 1;
00211             imax = isamax_(&i__1, &w[kw * w_dim1 + 1], &c__1);
00212             colmax = (r__1 = w[imax + kw * w_dim1], dabs(r__1));
00213         } else {
00214             colmax = 0.f;
00215         }
00216 
00217         if (dmax(absakk,colmax) == 0.f) {
00218 
00219 /*           Column K is zero: set INFO and continue */
00220 
00221             if (*info == 0) {
00222                 *info = k;
00223             }
00224             kp = k;
00225         } else {
00226             if (absakk >= alpha * colmax) {
00227 
00228 /*              no interchange, use 1-by-1 pivot block */
00229 
00230                 kp = k;
00231             } else {
00232 
00233 /*              Copy column IMAX to column KW-1 of W and update it */
00234 
00235                 scopy_(&imax, &a[imax * a_dim1 + 1], &c__1, &w[(kw - 1) * 
00236                         w_dim1 + 1], &c__1);
00237                 i__1 = k - imax;
00238                 scopy_(&i__1, &a[imax + (imax + 1) * a_dim1], lda, &w[imax + 
00239                         1 + (kw - 1) * w_dim1], &c__1);
00240                 if (k < *n) {
00241                     i__1 = *n - k;
00242                     sgemv_("No transpose", &k, &i__1, &c_b8, &a[(k + 1) * 
00243                             a_dim1 + 1], lda, &w[imax + (kw + 1) * w_dim1], 
00244                             ldw, &c_b9, &w[(kw - 1) * w_dim1 + 1], &c__1);
00245                 }
00246 
00247 /*              JMAX is the column-index of the largest off-diagonal */
00248 /*              element in row IMAX, and ROWMAX is its absolute value */
00249 
00250                 i__1 = k - imax;
00251                 jmax = imax + isamax_(&i__1, &w[imax + 1 + (kw - 1) * w_dim1], 
00252                          &c__1);
00253                 rowmax = (r__1 = w[jmax + (kw - 1) * w_dim1], dabs(r__1));
00254                 if (imax > 1) {
00255                     i__1 = imax - 1;
00256                     jmax = isamax_(&i__1, &w[(kw - 1) * w_dim1 + 1], &c__1);
00257 /* Computing MAX */
00258                     r__2 = rowmax, r__3 = (r__1 = w[jmax + (kw - 1) * w_dim1],
00259                              dabs(r__1));
00260                     rowmax = dmax(r__2,r__3);
00261                 }
00262 
00263                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00264 
00265 /*                 no interchange, use 1-by-1 pivot block */
00266 
00267                     kp = k;
00268                 } else if ((r__1 = w[imax + (kw - 1) * w_dim1], dabs(r__1)) >=
00269                          alpha * rowmax) {
00270 
00271 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00272 /*                 pivot block */
00273 
00274                     kp = imax;
00275 
00276 /*                 copy column KW-1 of W to column KW */
00277 
00278                     scopy_(&k, &w[(kw - 1) * w_dim1 + 1], &c__1, &w[kw * 
00279                             w_dim1 + 1], &c__1);
00280                 } else {
00281 
00282 /*                 interchange rows and columns K-1 and IMAX, use 2-by-2 */
00283 /*                 pivot block */
00284 
00285                     kp = imax;
00286                     kstep = 2;
00287                 }
00288             }
00289 
00290             kk = k - kstep + 1;
00291             kkw = *nb + kk - *n;
00292 
00293 /*           Updated column KP is already stored in column KKW of W */
00294 
00295             if (kp != kk) {
00296 
00297 /*              Copy non-updated column KK to column KP */
00298 
00299                 a[kp + k * a_dim1] = a[kk + k * a_dim1];
00300                 i__1 = k - 1 - kp;
00301                 scopy_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (kp + 
00302                         1) * a_dim1], lda);
00303                 scopy_(&kp, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1 + 1], &
00304                         c__1);
00305 
00306 /*              Interchange rows KK and KP in last KK columns of A and W */
00307 
00308                 i__1 = *n - kk + 1;
00309                 sswap_(&i__1, &a[kk + kk * a_dim1], lda, &a[kp + kk * a_dim1], 
00310                          lda);
00311                 i__1 = *n - kk + 1;
00312                 sswap_(&i__1, &w[kk + kkw * w_dim1], ldw, &w[kp + kkw * 
00313                         w_dim1], ldw);
00314             }
00315 
00316             if (kstep == 1) {
00317 
00318 /*              1-by-1 pivot block D(k): column KW of W now holds */
00319 
00320 /*              W(k) = U(k)*D(k) */
00321 
00322 /*              where U(k) is the k-th column of U */
00323 
00324 /*              Store U(k) in column k of A */
00325 
00326                 scopy_(&k, &w[kw * w_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &
00327                         c__1);
00328                 r1 = 1.f / a[k + k * a_dim1];
00329                 i__1 = k - 1;
00330                 sscal_(&i__1, &r1, &a[k * a_dim1 + 1], &c__1);
00331             } else {
00332 
00333 /*              2-by-2 pivot block D(k): columns KW and KW-1 of W now */
00334 /*              hold */
00335 
00336 /*              ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
00337 
00338 /*              where U(k) and U(k-1) are the k-th and (k-1)-th columns */
00339 /*              of U */
00340 
00341                 if (k > 2) {
00342 
00343 /*                 Store U(k) and U(k-1) in columns k and k-1 of A */
00344 
00345                     d21 = w[k - 1 + kw * w_dim1];
00346                     d11 = w[k + kw * w_dim1] / d21;
00347                     d22 = w[k - 1 + (kw - 1) * w_dim1] / d21;
00348                     t = 1.f / (d11 * d22 - 1.f);
00349                     d21 = t / d21;
00350                     i__1 = k - 2;
00351                     for (j = 1; j <= i__1; ++j) {
00352                         a[j + (k - 1) * a_dim1] = d21 * (d11 * w[j + (kw - 1) 
00353                                 * w_dim1] - w[j + kw * w_dim1]);
00354                         a[j + k * a_dim1] = d21 * (d22 * w[j + kw * w_dim1] - 
00355                                 w[j + (kw - 1) * w_dim1]);
00356 /* L20: */
00357                     }
00358                 }
00359 
00360 /*              Copy D(k) to A */
00361 
00362                 a[k - 1 + (k - 1) * a_dim1] = w[k - 1 + (kw - 1) * w_dim1];
00363                 a[k - 1 + k * a_dim1] = w[k - 1 + kw * w_dim1];
00364                 a[k + k * a_dim1] = w[k + kw * w_dim1];
00365             }
00366         }
00367 
00368 /*        Store details of the interchanges in IPIV */
00369 
00370         if (kstep == 1) {
00371             ipiv[k] = kp;
00372         } else {
00373             ipiv[k] = -kp;
00374             ipiv[k - 1] = -kp;
00375         }
00376 
00377 /*        Decrease K and return to the start of the main loop */
00378 
00379         k -= kstep;
00380         goto L10;
00381 
00382 L30:
00383 
00384 /*        Update the upper triangle of A11 (= A(1:k,1:k)) as */
00385 
00386 /*        A11 := A11 - U12*D*U12' = A11 - U12*W' */
00387 
00388 /*        computing blocks of NB columns at a time */
00389 
00390         i__1 = -(*nb);
00391         for (j = (k - 1) / *nb * *nb + 1; i__1 < 0 ? j >= 1 : j <= 1; j += 
00392                 i__1) {
00393 /* Computing MIN */
00394             i__2 = *nb, i__3 = k - j + 1;
00395             jb = min(i__2,i__3);
00396 
00397 /*           Update the upper triangle of the diagonal block */
00398 
00399             i__2 = j + jb - 1;
00400             for (jj = j; jj <= i__2; ++jj) {
00401                 i__3 = jj - j + 1;
00402                 i__4 = *n - k;
00403                 sgemv_("No transpose", &i__3, &i__4, &c_b8, &a[j + (k + 1) * 
00404                         a_dim1], lda, &w[jj + (kw + 1) * w_dim1], ldw, &c_b9, 
00405                         &a[j + jj * a_dim1], &c__1);
00406 /* L40: */
00407             }
00408 
00409 /*           Update the rectangular superdiagonal block */
00410 
00411             i__2 = j - 1;
00412             i__3 = *n - k;
00413             sgemm_("No transpose", "Transpose", &i__2, &jb, &i__3, &c_b8, &a[(
00414                     k + 1) * a_dim1 + 1], lda, &w[j + (kw + 1) * w_dim1], ldw, 
00415                      &c_b9, &a[j * a_dim1 + 1], lda);
00416 /* L50: */
00417         }
00418 
00419 /*        Put U12 in standard form by partially undoing the interchanges */
00420 /*        in columns k+1:n */
00421 
00422         j = k + 1;
00423 L60:
00424         jj = j;
00425         jp = ipiv[j];
00426         if (jp < 0) {
00427             jp = -jp;
00428             ++j;
00429         }
00430         ++j;
00431         if (jp != jj && j <= *n) {
00432             i__1 = *n - j + 1;
00433             sswap_(&i__1, &a[jp + j * a_dim1], lda, &a[jj + j * a_dim1], lda);
00434         }
00435         if (j <= *n) {
00436             goto L60;
00437         }
00438 
00439 /*        Set KB to the number of columns factorized */
00440 
00441         *kb = *n - k;
00442 
00443     } else {
00444 
00445 /*        Factorize the leading columns of A using the lower triangle */
00446 /*        of A and working forwards, and compute the matrix W = L21*D */
00447 /*        for use in updating A22 */
00448 
00449 /*        K is the main loop index, increasing from 1 in steps of 1 or 2 */
00450 
00451         k = 1;
00452 L70:
00453 
00454 /*        Exit from loop */
00455 
00456         if (k >= *nb && *nb < *n || k > *n) {
00457             goto L90;
00458         }
00459 
00460 /*        Copy column K of A to column K of W and update it */
00461 
00462         i__1 = *n - k + 1;
00463         scopy_(&i__1, &a[k + k * a_dim1], &c__1, &w[k + k * w_dim1], &c__1);
00464         i__1 = *n - k + 1;
00465         i__2 = k - 1;
00466         sgemv_("No transpose", &i__1, &i__2, &c_b8, &a[k + a_dim1], lda, &w[k 
00467                 + w_dim1], ldw, &c_b9, &w[k + k * w_dim1], &c__1);
00468 
00469         kstep = 1;
00470 
00471 /*        Determine rows and columns to be interchanged and whether */
00472 /*        a 1-by-1 or 2-by-2 pivot block will be used */
00473 
00474         absakk = (r__1 = w[k + k * w_dim1], dabs(r__1));
00475 
00476 /*        IMAX is the row-index of the largest off-diagonal element in */
00477 /*        column K, and COLMAX is its absolute value */
00478 
00479         if (k < *n) {
00480             i__1 = *n - k;
00481             imax = k + isamax_(&i__1, &w[k + 1 + k * w_dim1], &c__1);
00482             colmax = (r__1 = w[imax + k * w_dim1], dabs(r__1));
00483         } else {
00484             colmax = 0.f;
00485         }
00486 
00487         if (dmax(absakk,colmax) == 0.f) {
00488 
00489 /*           Column K is zero: set INFO and continue */
00490 
00491             if (*info == 0) {
00492                 *info = k;
00493             }
00494             kp = k;
00495         } else {
00496             if (absakk >= alpha * colmax) {
00497 
00498 /*              no interchange, use 1-by-1 pivot block */
00499 
00500                 kp = k;
00501             } else {
00502 
00503 /*              Copy column IMAX to column K+1 of W and update it */
00504 
00505                 i__1 = imax - k;
00506                 scopy_(&i__1, &a[imax + k * a_dim1], lda, &w[k + (k + 1) * 
00507                         w_dim1], &c__1);
00508                 i__1 = *n - imax + 1;
00509                 scopy_(&i__1, &a[imax + imax * a_dim1], &c__1, &w[imax + (k + 
00510                         1) * w_dim1], &c__1);
00511                 i__1 = *n - k + 1;
00512                 i__2 = k - 1;
00513                 sgemv_("No transpose", &i__1, &i__2, &c_b8, &a[k + a_dim1], 
00514                         lda, &w[imax + w_dim1], ldw, &c_b9, &w[k + (k + 1) * 
00515                         w_dim1], &c__1);
00516 
00517 /*              JMAX is the column-index of the largest off-diagonal */
00518 /*              element in row IMAX, and ROWMAX is its absolute value */
00519 
00520                 i__1 = imax - k;
00521                 jmax = k - 1 + isamax_(&i__1, &w[k + (k + 1) * w_dim1], &c__1)
00522                         ;
00523                 rowmax = (r__1 = w[jmax + (k + 1) * w_dim1], dabs(r__1));
00524                 if (imax < *n) {
00525                     i__1 = *n - imax;
00526                     jmax = imax + isamax_(&i__1, &w[imax + 1 + (k + 1) * 
00527                             w_dim1], &c__1);
00528 /* Computing MAX */
00529                     r__2 = rowmax, r__3 = (r__1 = w[jmax + (k + 1) * w_dim1], 
00530                             dabs(r__1));
00531                     rowmax = dmax(r__2,r__3);
00532                 }
00533 
00534                 if (absakk >= alpha * colmax * (colmax / rowmax)) {
00535 
00536 /*                 no interchange, use 1-by-1 pivot block */
00537 
00538                     kp = k;
00539                 } else if ((r__1 = w[imax + (k + 1) * w_dim1], dabs(r__1)) >= 
00540                         alpha * rowmax) {
00541 
00542 /*                 interchange rows and columns K and IMAX, use 1-by-1 */
00543 /*                 pivot block */
00544 
00545                     kp = imax;
00546 
00547 /*                 copy column K+1 of W to column K */
00548 
00549                     i__1 = *n - k + 1;
00550                     scopy_(&i__1, &w[k + (k + 1) * w_dim1], &c__1, &w[k + k * 
00551                             w_dim1], &c__1);
00552                 } else {
00553 
00554 /*                 interchange rows and columns K+1 and IMAX, use 2-by-2 */
00555 /*                 pivot block */
00556 
00557                     kp = imax;
00558                     kstep = 2;
00559                 }
00560             }
00561 
00562             kk = k + kstep - 1;
00563 
00564 /*           Updated column KP is already stored in column KK of W */
00565 
00566             if (kp != kk) {
00567 
00568 /*              Copy non-updated column KK to column KP */
00569 
00570                 a[kp + k * a_dim1] = a[kk + k * a_dim1];
00571                 i__1 = kp - k - 1;
00572                 scopy_(&i__1, &a[k + 1 + kk * a_dim1], &c__1, &a[kp + (k + 1) 
00573                         * a_dim1], lda);
00574                 i__1 = *n - kp + 1;
00575                 scopy_(&i__1, &a[kp + kk * a_dim1], &c__1, &a[kp + kp * 
00576                         a_dim1], &c__1);
00577 
00578 /*              Interchange rows KK and KP in first KK columns of A and W */
00579 
00580                 sswap_(&kk, &a[kk + a_dim1], lda, &a[kp + a_dim1], lda);
00581                 sswap_(&kk, &w[kk + w_dim1], ldw, &w[kp + w_dim1], ldw);
00582             }
00583 
00584             if (kstep == 1) {
00585 
00586 /*              1-by-1 pivot block D(k): column k of W now holds */
00587 
00588 /*              W(k) = L(k)*D(k) */
00589 
00590 /*              where L(k) is the k-th column of L */
00591 
00592 /*              Store L(k) in column k of A */
00593 
00594                 i__1 = *n - k + 1;
00595                 scopy_(&i__1, &w[k + k * w_dim1], &c__1, &a[k + k * a_dim1], &
00596                         c__1);
00597                 if (k < *n) {
00598                     r1 = 1.f / a[k + k * a_dim1];
00599                     i__1 = *n - k;
00600                     sscal_(&i__1, &r1, &a[k + 1 + k * a_dim1], &c__1);
00601                 }
00602             } else {
00603 
00604 /*              2-by-2 pivot block D(k): columns k and k+1 of W now hold */
00605 
00606 /*              ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
00607 
00608 /*              where L(k) and L(k+1) are the k-th and (k+1)-th columns */
00609 /*              of L */
00610 
00611                 if (k < *n - 1) {
00612 
00613 /*                 Store L(k) and L(k+1) in columns k and k+1 of A */
00614 
00615                     d21 = w[k + 1 + k * w_dim1];
00616                     d11 = w[k + 1 + (k + 1) * w_dim1] / d21;
00617                     d22 = w[k + k * w_dim1] / d21;
00618                     t = 1.f / (d11 * d22 - 1.f);
00619                     d21 = t / d21;
00620                     i__1 = *n;
00621                     for (j = k + 2; j <= i__1; ++j) {
00622                         a[j + k * a_dim1] = d21 * (d11 * w[j + k * w_dim1] - 
00623                                 w[j + (k + 1) * w_dim1]);
00624                         a[j + (k + 1) * a_dim1] = d21 * (d22 * w[j + (k + 1) *
00625                                  w_dim1] - w[j + k * w_dim1]);
00626 /* L80: */
00627                     }
00628                 }
00629 
00630 /*              Copy D(k) to A */
00631 
00632                 a[k + k * a_dim1] = w[k + k * w_dim1];
00633                 a[k + 1 + k * a_dim1] = w[k + 1 + k * w_dim1];
00634                 a[k + 1 + (k + 1) * a_dim1] = w[k + 1 + (k + 1) * w_dim1];
00635             }
00636         }
00637 
00638 /*        Store details of the interchanges in IPIV */
00639 
00640         if (kstep == 1) {
00641             ipiv[k] = kp;
00642         } else {
00643             ipiv[k] = -kp;
00644             ipiv[k + 1] = -kp;
00645         }
00646 
00647 /*        Increase K and return to the start of the main loop */
00648 
00649         k += kstep;
00650         goto L70;
00651 
00652 L90:
00653 
00654 /*        Update the lower triangle of A22 (= A(k:n,k:n)) as */
00655 
00656 /*        A22 := A22 - L21*D*L21' = A22 - L21*W' */
00657 
00658 /*        computing blocks of NB columns at a time */
00659 
00660         i__1 = *n;
00661         i__2 = *nb;
00662         for (j = k; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00663 /* Computing MIN */
00664             i__3 = *nb, i__4 = *n - j + 1;
00665             jb = min(i__3,i__4);
00666 
00667 /*           Update the lower triangle of the diagonal block */
00668 
00669             i__3 = j + jb - 1;
00670             for (jj = j; jj <= i__3; ++jj) {
00671                 i__4 = j + jb - jj;
00672                 i__5 = k - 1;
00673                 sgemv_("No transpose", &i__4, &i__5, &c_b8, &a[jj + a_dim1], 
00674                         lda, &w[jj + w_dim1], ldw, &c_b9, &a[jj + jj * a_dim1]
00675 , &c__1);
00676 /* L100: */
00677             }
00678 
00679 /*           Update the rectangular subdiagonal block */
00680 
00681             if (j + jb <= *n) {
00682                 i__3 = *n - j - jb + 1;
00683                 i__4 = k - 1;
00684                 sgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &c_b8, 
00685                         &a[j + jb + a_dim1], lda, &w[j + w_dim1], ldw, &c_b9, 
00686                         &a[j + jb + j * a_dim1], lda);
00687             }
00688 /* L110: */
00689         }
00690 
00691 /*        Put L21 in standard form by partially undoing the interchanges */
00692 /*        in columns 1:k-1 */
00693 
00694         j = k - 1;
00695 L120:
00696         jj = j;
00697         jp = ipiv[j];
00698         if (jp < 0) {
00699             jp = -jp;
00700             --j;
00701         }
00702         --j;
00703         if (jp != jj && j >= 1) {
00704             sswap_(&j, &a[jp + a_dim1], lda, &a[jj + a_dim1], lda);
00705         }
00706         if (j >= 1) {
00707             goto L120;
00708         }
00709 
00710 /*        Set KB to the number of columns factorized */
00711 
00712         *kb = k - 1;
00713 
00714     }
00715     return 0;
00716 
00717 /*     End of SLASYF */
00718 
00719 } /* slasyf_ */


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