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


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