dlavsy.c
Go to the documentation of this file.
00001 /* dlavsy.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 doublereal c_b15 = 1.;
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int dlavsy_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal 
00023         *b, integer *ldb, integer *info)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
00027 
00028     /* Local variables */
00029     integer j, k;
00030     doublereal t1, t2, d11, d12, d21, d22;
00031     integer kp;
00032     extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, 
00033             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00034             integer *), dscal_(integer *, doublereal *, doublereal *, integer 
00035             *);
00036     extern logical lsame_(char *, char *);
00037     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00038             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00039             doublereal *, doublereal *, integer *), dswap_(integer *, 
00040             doublereal *, integer *, doublereal *, integer *), xerbla_(char *, 
00041              integer *);
00042     logical nounit;
00043 
00044 
00045 /*  -- LAPACK auxiliary routine (version 3.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  DLAVSY  performs one of the matrix-vector operations */
00058 /*     x := A*x  or  x := A'*x, */
00059 /*  where x is an N element vector and A is one of the factors */
00060 /*  from the block U*D*U' or L*D*L' factorization computed by DSYTRF. */
00061 
00062 /*  If TRANS = 'N', multiplies by U  or U * D  (or L  or L * D) */
00063 /*  If TRANS = 'T', multiplies by U' or D * U' (or L' or D * L') */
00064 /*  If TRANS = 'C', multiplies by U' or D * U' (or L' or D * L') */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  UPLO    (input) CHARACTER*1 */
00070 /*          Specifies whether the factor stored in A is upper or lower */
00071 /*          triangular. */
00072 /*          = 'U':  Upper triangular */
00073 /*          = 'L':  Lower triangular */
00074 
00075 /*  TRANS   (input) CHARACTER*1 */
00076 /*          Specifies the operation to be performed: */
00077 /*          = 'N':  x := A*x */
00078 /*          = 'T':  x := A'*x */
00079 /*          = 'C':  x := A'*x */
00080 
00081 /*  DIAG    (input) CHARACTER*1 */
00082 /*          Specifies whether or not the diagonal blocks are unit */
00083 /*          matrices.  If the diagonal blocks are assumed to be unit, */
00084 /*          then A = U or A = L, otherwise A = U*D or A = L*D. */
00085 /*          = 'U':  Diagonal blocks are assumed to be unit matrices. */
00086 /*          = 'N':  Diagonal blocks are assumed to be non-unit matrices. */
00087 
00088 /*  N       (input) INTEGER */
00089 /*          The number of rows and columns of the matrix A.  N >= 0. */
00090 
00091 /*  NRHS    (input) INTEGER */
00092 /*          The number of right hand sides, i.e., the number of vectors */
00093 /*          x to be multiplied by A.  NRHS >= 0. */
00094 
00095 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00096 /*          The block diagonal matrix D and the multipliers used to */
00097 /*          obtain the factor U or L as computed by DSYTRF. */
00098 
00099 /*  LDA     (input) INTEGER */
00100 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00101 
00102 /*  IPIV    (input) INTEGER array, dimension (N) */
00103 /*          The pivot indices from DSYTRF. */
00104 
00105 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00106 /*          On entry, B contains NRHS vectors of length N. */
00107 /*          On exit, B is overwritten with the product A * B. */
00108 
00109 /*  LDB     (input) INTEGER */
00110 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00111 
00112 /*  INFO    (output) INTEGER */
00113 /*          = 0: successful exit */
00114 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00115 
00116 /*  ===================================================================== */
00117 
00118 /*     .. Parameters .. */
00119 /*     .. */
00120 /*     .. Local Scalars .. */
00121 /*     .. */
00122 /*     .. External Functions .. */
00123 /*     .. */
00124 /*     .. External Subroutines .. */
00125 /*     .. */
00126 /*     .. Intrinsic Functions .. */
00127 /*     .. */
00128 /*     .. Executable Statements .. */
00129 
00130 /*     Test the input parameters. */
00131 
00132     /* Parameter adjustments */
00133     a_dim1 = *lda;
00134     a_offset = 1 + a_dim1;
00135     a -= a_offset;
00136     --ipiv;
00137     b_dim1 = *ldb;
00138     b_offset = 1 + b_dim1;
00139     b -= b_offset;
00140 
00141     /* Function Body */
00142     *info = 0;
00143     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00144         *info = -1;
00145     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00146             "T") && ! lsame_(trans, "C")) {
00147         *info = -2;
00148     } else if (! lsame_(diag, "U") && ! lsame_(diag, 
00149             "N")) {
00150         *info = -3;
00151     } else if (*n < 0) {
00152         *info = -4;
00153     } else if (*lda < max(1,*n)) {
00154         *info = -6;
00155     } else if (*ldb < max(1,*n)) {
00156         *info = -9;
00157     }
00158     if (*info != 0) {
00159         i__1 = -(*info);
00160         xerbla_("DLAVSY ", &i__1);
00161         return 0;
00162     }
00163 
00164 /*     Quick return if possible. */
00165 
00166     if (*n == 0) {
00167         return 0;
00168     }
00169 
00170     nounit = lsame_(diag, "N");
00171 /* ------------------------------------------ */
00172 
00173 /*     Compute  B := A * B  (No transpose) */
00174 
00175 /* ------------------------------------------ */
00176     if (lsame_(trans, "N")) {
00177 
00178 /*        Compute  B := U*B */
00179 /*        where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) */
00180 
00181         if (lsame_(uplo, "U")) {
00182 
00183 /*        Loop forward applying the transformations. */
00184 
00185             k = 1;
00186 L10:
00187             if (k > *n) {
00188                 goto L30;
00189             }
00190             if (ipiv[k] > 0) {
00191 
00192 /*              1 x 1 pivot block */
00193 
00194 /*              Multiply by the diagonal element if forming U * D. */
00195 
00196                 if (nounit) {
00197                     dscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00198                 }
00199 
00200 /*              Multiply by  P(K) * inv(U(K))  if K > 1. */
00201 
00202                 if (k > 1) {
00203 
00204 /*                 Apply the transformation. */
00205 
00206                     i__1 = k - 1;
00207                     dger_(&i__1, nrhs, &c_b15, &a[k * a_dim1 + 1], &c__1, &b[
00208                             k + b_dim1], ldb, &b[b_dim1 + 1], ldb);
00209 
00210 /*                 Interchange if P(K) .ne. I. */
00211 
00212                     kp = ipiv[k];
00213                     if (kp != k) {
00214                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00215                                 ldb);
00216                     }
00217                 }
00218                 ++k;
00219             } else {
00220 
00221 /*              2 x 2 pivot block */
00222 
00223 /*              Multiply by the diagonal block if forming U * D. */
00224 
00225                 if (nounit) {
00226                     d11 = a[k + k * a_dim1];
00227                     d22 = a[k + 1 + (k + 1) * a_dim1];
00228                     d12 = a[k + (k + 1) * a_dim1];
00229                     d21 = d12;
00230                     i__1 = *nrhs;
00231                     for (j = 1; j <= i__1; ++j) {
00232                         t1 = b[k + j * b_dim1];
00233                         t2 = b[k + 1 + j * b_dim1];
00234                         b[k + j * b_dim1] = d11 * t1 + d12 * t2;
00235                         b[k + 1 + j * b_dim1] = d21 * t1 + d22 * t2;
00236 /* L20: */
00237                     }
00238                 }
00239 
00240 /*              Multiply by  P(K) * inv(U(K))  if K > 1. */
00241 
00242                 if (k > 1) {
00243 
00244 /*                 Apply the transformations. */
00245 
00246                     i__1 = k - 1;
00247                     dger_(&i__1, nrhs, &c_b15, &a[k * a_dim1 + 1], &c__1, &b[
00248                             k + b_dim1], ldb, &b[b_dim1 + 1], ldb);
00249                     i__1 = k - 1;
00250                     dger_(&i__1, nrhs, &c_b15, &a[(k + 1) * a_dim1 + 1], &
00251                             c__1, &b[k + 1 + b_dim1], ldb, &b[b_dim1 + 1], 
00252                             ldb);
00253 
00254 /*                 Interchange if P(K) .ne. I. */
00255 
00256                     kp = (i__1 = ipiv[k], abs(i__1));
00257                     if (kp != k) {
00258                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00259                                 ldb);
00260                     }
00261                 }
00262                 k += 2;
00263             }
00264             goto L10;
00265 L30:
00266 
00267 /*        Compute  B := L*B */
00268 /*        where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) . */
00269 
00270             ;
00271         } else {
00272 
00273 /*           Loop backward applying the transformations to B. */
00274 
00275             k = *n;
00276 L40:
00277             if (k < 1) {
00278                 goto L60;
00279             }
00280 
00281 /*           Test the pivot index.  If greater than zero, a 1 x 1 */
00282 /*           pivot was used, otherwise a 2 x 2 pivot was used. */
00283 
00284             if (ipiv[k] > 0) {
00285 
00286 /*              1 x 1 pivot block: */
00287 
00288 /*              Multiply by the diagonal element if forming L * D. */
00289 
00290                 if (nounit) {
00291                     dscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00292                 }
00293 
00294 /*              Multiply by  P(K) * inv(L(K))  if K < N. */
00295 
00296                 if (k != *n) {
00297                     kp = ipiv[k];
00298 
00299 /*                 Apply the transformation. */
00300 
00301                     i__1 = *n - k;
00302                     dger_(&i__1, nrhs, &c_b15, &a[k + 1 + k * a_dim1], &c__1, 
00303                             &b[k + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00304 
00305 /*                 Interchange if a permutation was applied at the */
00306 /*                 K-th step of the factorization. */
00307 
00308                     if (kp != k) {
00309                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00310                                 ldb);
00311                     }
00312                 }
00313                 --k;
00314 
00315             } else {
00316 
00317 /*              2 x 2 pivot block: */
00318 
00319 /*              Multiply by the diagonal block if forming L * D. */
00320 
00321                 if (nounit) {
00322                     d11 = a[k - 1 + (k - 1) * a_dim1];
00323                     d22 = a[k + k * a_dim1];
00324                     d21 = a[k + (k - 1) * a_dim1];
00325                     d12 = d21;
00326                     i__1 = *nrhs;
00327                     for (j = 1; j <= i__1; ++j) {
00328                         t1 = b[k - 1 + j * b_dim1];
00329                         t2 = b[k + j * b_dim1];
00330                         b[k - 1 + j * b_dim1] = d11 * t1 + d12 * t2;
00331                         b[k + j * b_dim1] = d21 * t1 + d22 * t2;
00332 /* L50: */
00333                     }
00334                 }
00335 
00336 /*              Multiply by  P(K) * inv(L(K))  if K < N. */
00337 
00338                 if (k != *n) {
00339 
00340 /*                 Apply the transformation. */
00341 
00342                     i__1 = *n - k;
00343                     dger_(&i__1, nrhs, &c_b15, &a[k + 1 + k * a_dim1], &c__1, 
00344                             &b[k + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00345                     i__1 = *n - k;
00346                     dger_(&i__1, nrhs, &c_b15, &a[k + 1 + (k - 1) * a_dim1], &
00347                             c__1, &b[k - 1 + b_dim1], ldb, &b[k + 1 + b_dim1], 
00348                              ldb);
00349 
00350 /*                 Interchange if a permutation was applied at the */
00351 /*                 K-th step of the factorization. */
00352 
00353                     kp = (i__1 = ipiv[k], abs(i__1));
00354                     if (kp != k) {
00355                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00356                                 ldb);
00357                     }
00358                 }
00359                 k += -2;
00360             }
00361             goto L40;
00362 L60:
00363             ;
00364         }
00365 /* ---------------------------------------- */
00366 
00367 /*     Compute  B := A' * B  (transpose) */
00368 
00369 /* ---------------------------------------- */
00370     } else {
00371 
00372 /*        Form  B := U'*B */
00373 /*        where U  = P(m)*inv(U(m))* ... *P(1)*inv(U(1)) */
00374 /*        and   U' = inv(U'(1))*P(1)* ... *inv(U'(m))*P(m) */
00375 
00376         if (lsame_(uplo, "U")) {
00377 
00378 /*           Loop backward applying the transformations. */
00379 
00380             k = *n;
00381 L70:
00382             if (k < 1) {
00383                 goto L90;
00384             }
00385 
00386 /*           1 x 1 pivot block. */
00387 
00388             if (ipiv[k] > 0) {
00389                 if (k > 1) {
00390 
00391 /*                 Interchange if P(K) .ne. I. */
00392 
00393                     kp = ipiv[k];
00394                     if (kp != k) {
00395                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00396                                 ldb);
00397                     }
00398 
00399 /*                 Apply the transformation */
00400 
00401                     i__1 = k - 1;
00402                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset], 
00403                             ldb, &a[k * a_dim1 + 1], &c__1, &c_b15, &b[k + 
00404                             b_dim1], ldb);
00405                 }
00406                 if (nounit) {
00407                     dscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00408                 }
00409                 --k;
00410 
00411 /*           2 x 2 pivot block. */
00412 
00413             } else {
00414                 if (k > 2) {
00415 
00416 /*                 Interchange if P(K) .ne. I. */
00417 
00418                     kp = (i__1 = ipiv[k], abs(i__1));
00419                     if (kp != k - 1) {
00420                         dswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1], 
00421                                  ldb);
00422                     }
00423 
00424 /*                 Apply the transformations */
00425 
00426                     i__1 = k - 2;
00427                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset], 
00428                             ldb, &a[k * a_dim1 + 1], &c__1, &c_b15, &b[k + 
00429                             b_dim1], ldb);
00430                     i__1 = k - 2;
00431                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset], 
00432                             ldb, &a[(k - 1) * a_dim1 + 1], &c__1, &c_b15, &b[
00433                             k - 1 + b_dim1], ldb);
00434                 }
00435 
00436 /*              Multiply by the diagonal block if non-unit. */
00437 
00438                 if (nounit) {
00439                     d11 = a[k - 1 + (k - 1) * a_dim1];
00440                     d22 = a[k + k * a_dim1];
00441                     d12 = a[k - 1 + k * a_dim1];
00442                     d21 = d12;
00443                     i__1 = *nrhs;
00444                     for (j = 1; j <= i__1; ++j) {
00445                         t1 = b[k - 1 + j * b_dim1];
00446                         t2 = b[k + j * b_dim1];
00447                         b[k - 1 + j * b_dim1] = d11 * t1 + d12 * t2;
00448                         b[k + j * b_dim1] = d21 * t1 + d22 * t2;
00449 /* L80: */
00450                     }
00451                 }
00452                 k += -2;
00453             }
00454             goto L70;
00455 L90:
00456 
00457 /*        Form  B := L'*B */
00458 /*        where L  = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) */
00459 /*        and   L' = inv(L'(m))*P(m)* ... *inv(L'(1))*P(1) */
00460 
00461             ;
00462         } else {
00463 
00464 /*           Loop forward applying the L-transformations. */
00465 
00466             k = 1;
00467 L100:
00468             if (k > *n) {
00469                 goto L120;
00470             }
00471 
00472 /*           1 x 1 pivot block */
00473 
00474             if (ipiv[k] > 0) {
00475                 if (k < *n) {
00476 
00477 /*                 Interchange if P(K) .ne. I. */
00478 
00479                     kp = ipiv[k];
00480                     if (kp != k) {
00481                         dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], 
00482                                 ldb);
00483                     }
00484 
00485 /*                 Apply the transformation */
00486 
00487                     i__1 = *n - k;
00488                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 1 + 
00489                             b_dim1], ldb, &a[k + 1 + k * a_dim1], &c__1, &
00490                             c_b15, &b[k + b_dim1], ldb);
00491                 }
00492                 if (nounit) {
00493                     dscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00494                 }
00495                 ++k;
00496 
00497 /*           2 x 2 pivot block. */
00498 
00499             } else {
00500                 if (k < *n - 1) {
00501 
00502 /*              Interchange if P(K) .ne. I. */
00503 
00504                     kp = (i__1 = ipiv[k], abs(i__1));
00505                     if (kp != k + 1) {
00506                         dswap_(nrhs, &b[k + 1 + b_dim1], ldb, &b[kp + b_dim1], 
00507                                  ldb);
00508                     }
00509 
00510 /*                 Apply the transformation */
00511 
00512                     i__1 = *n - k - 1;
00513                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 2 + 
00514                             b_dim1], ldb, &a[k + 2 + (k + 1) * a_dim1], &c__1, 
00515                              &c_b15, &b[k + 1 + b_dim1], ldb);
00516                     i__1 = *n - k - 1;
00517                     dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 2 + 
00518                             b_dim1], ldb, &a[k + 2 + k * a_dim1], &c__1, &
00519                             c_b15, &b[k + b_dim1], ldb);
00520                 }
00521 
00522 /*              Multiply by the diagonal block if non-unit. */
00523 
00524                 if (nounit) {
00525                     d11 = a[k + k * a_dim1];
00526                     d22 = a[k + 1 + (k + 1) * a_dim1];
00527                     d21 = a[k + 1 + k * a_dim1];
00528                     d12 = d21;
00529                     i__1 = *nrhs;
00530                     for (j = 1; j <= i__1; ++j) {
00531                         t1 = b[k + j * b_dim1];
00532                         t2 = b[k + 1 + j * b_dim1];
00533                         b[k + j * b_dim1] = d11 * t1 + d12 * t2;
00534                         b[k + 1 + j * b_dim1] = d21 * t1 + d22 * t2;
00535 /* L110: */
00536                     }
00537                 }
00538                 k += 2;
00539             }
00540             goto L100;
00541 L120:
00542             ;
00543         }
00544 
00545     }
00546     return 0;
00547 
00548 /*     End of DLAVSY */
00549 
00550 } /* dlavsy_ */


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