dgbtrs.c
Go to the documentation of this file.
00001 /* dgbtrs.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_b7 = -1.;
00019 static integer c__1 = 1;
00020 static doublereal c_b23 = 1.;
00021 
00022 /* Subroutine */ int dgbtrs_(char *trans, integer *n, integer *kl, integer *
00023         ku, integer *nrhs, doublereal *ab, integer *ldab, integer *ipiv, 
00024         doublereal *b, integer *ldb, integer *info)
00025 {
00026     /* System generated locals */
00027     integer ab_dim1, ab_offset, b_dim1, b_offset, i__1, i__2, i__3;
00028 
00029     /* Local variables */
00030     integer i__, j, l, kd, lm;
00031     extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, 
00032             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00033             integer *);
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00036             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00037             doublereal *, doublereal *, integer *), dswap_(integer *, 
00038             doublereal *, integer *, doublereal *, integer *), dtbsv_(char *, 
00039             char *, char *, integer *, integer *, doublereal *, integer *, 
00040             doublereal *, integer *);
00041     logical lnoti;
00042     extern /* Subroutine */ int xerbla_(char *, integer *);
00043     logical notran;
00044 
00045 
00046 /*  -- LAPACK routine (version 3.2) -- */
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 /*  DGBTRS solves a system of linear equations */
00059 /*     A * X = B  or  A' * X = B */
00060 /*  with a general band matrix A using the LU factorization computed */
00061 /*  by DGBTRF. */
00062 
00063 /*  Arguments */
00064 /*  ========= */
00065 
00066 /*  TRANS   (input) CHARACTER*1 */
00067 /*          Specifies the form of the system of equations. */
00068 /*          = 'N':  A * X = B  (No transpose) */
00069 /*          = 'T':  A'* X = B  (Transpose) */
00070 /*          = 'C':  A'* X = B  (Conjugate transpose = Transpose) */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The order of the matrix A.  N >= 0. */
00074 
00075 /*  KL      (input) INTEGER */
00076 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00077 
00078 /*  KU      (input) INTEGER */
00079 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00080 
00081 /*  NRHS    (input) INTEGER */
00082 /*          The number of right hand sides, i.e., the number of columns */
00083 /*          of the matrix B.  NRHS >= 0. */
00084 
00085 /*  AB      (input) DOUBLE PRECISION array, dimension (LDAB,N) */
00086 /*          Details of the LU factorization of the band matrix A, as */
00087 /*          computed by DGBTRF.  U is stored as an upper triangular band */
00088 /*          matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */
00089 /*          the multipliers used during the factorization are stored in */
00090 /*          rows KL+KU+2 to 2*KL+KU+1. */
00091 
00092 /*  LDAB    (input) INTEGER */
00093 /*          The leading dimension of the array AB.  LDAB >= 2*KL+KU+1. */
00094 
00095 /*  IPIV    (input) INTEGER array, dimension (N) */
00096 /*          The pivot indices; for 1 <= i <= N, row i of the matrix was */
00097 /*          interchanged with row IPIV(i). */
00098 
00099 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00100 /*          On entry, the right hand side matrix B. */
00101 /*          On exit, the solution matrix X. */
00102 
00103 /*  LDB     (input) INTEGER */
00104 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00105 
00106 /*  INFO    (output) INTEGER */
00107 /*          = 0:  successful exit */
00108 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124 /*     Test the input parameters. */
00125 
00126     /* Parameter adjustments */
00127     ab_dim1 = *ldab;
00128     ab_offset = 1 + ab_dim1;
00129     ab -= ab_offset;
00130     --ipiv;
00131     b_dim1 = *ldb;
00132     b_offset = 1 + b_dim1;
00133     b -= b_offset;
00134 
00135     /* Function Body */
00136     *info = 0;
00137     notran = lsame_(trans, "N");
00138     if (! notran && ! lsame_(trans, "T") && ! lsame_(
00139             trans, "C")) {
00140         *info = -1;
00141     } else if (*n < 0) {
00142         *info = -2;
00143     } else if (*kl < 0) {
00144         *info = -3;
00145     } else if (*ku < 0) {
00146         *info = -4;
00147     } else if (*nrhs < 0) {
00148         *info = -5;
00149     } else if (*ldab < (*kl << 1) + *ku + 1) {
00150         *info = -7;
00151     } else if (*ldb < max(1,*n)) {
00152         *info = -10;
00153     }
00154     if (*info != 0) {
00155         i__1 = -(*info);
00156         xerbla_("DGBTRS", &i__1);
00157         return 0;
00158     }
00159 
00160 /*     Quick return if possible */
00161 
00162     if (*n == 0 || *nrhs == 0) {
00163         return 0;
00164     }
00165 
00166     kd = *ku + *kl + 1;
00167     lnoti = *kl > 0;
00168 
00169     if (notran) {
00170 
00171 /*        Solve  A*X = B. */
00172 
00173 /*        Solve L*X = B, overwriting B with X. */
00174 
00175 /*        L is represented as a product of permutations and unit lower */
00176 /*        triangular matrices L = P(1) * L(1) * ... * P(n-1) * L(n-1), */
00177 /*        where each transformation L(i) is a rank-one modification of */
00178 /*        the identity matrix. */
00179 
00180         if (lnoti) {
00181             i__1 = *n - 1;
00182             for (j = 1; j <= i__1; ++j) {
00183 /* Computing MIN */
00184                 i__2 = *kl, i__3 = *n - j;
00185                 lm = min(i__2,i__3);
00186                 l = ipiv[j];
00187                 if (l != j) {
00188                     dswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb);
00189                 }
00190                 dger_(&lm, nrhs, &c_b7, &ab[kd + 1 + j * ab_dim1], &c__1, &b[
00191                         j + b_dim1], ldb, &b[j + 1 + b_dim1], ldb);
00192 /* L10: */
00193             }
00194         }
00195 
00196         i__1 = *nrhs;
00197         for (i__ = 1; i__ <= i__1; ++i__) {
00198 
00199 /*           Solve U*X = B, overwriting B with X. */
00200 
00201             i__2 = *kl + *ku;
00202             dtbsv_("Upper", "No transpose", "Non-unit", n, &i__2, &ab[
00203                     ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1);
00204 /* L20: */
00205         }
00206 
00207     } else {
00208 
00209 /*        Solve A'*X = B. */
00210 
00211         i__1 = *nrhs;
00212         for (i__ = 1; i__ <= i__1; ++i__) {
00213 
00214 /*           Solve U'*X = B, overwriting B with X. */
00215 
00216             i__2 = *kl + *ku;
00217             dtbsv_("Upper", "Transpose", "Non-unit", n, &i__2, &ab[ab_offset], 
00218                      ldab, &b[i__ * b_dim1 + 1], &c__1);
00219 /* L30: */
00220         }
00221 
00222 /*        Solve L'*X = B, overwriting B with X. */
00223 
00224         if (lnoti) {
00225             for (j = *n - 1; j >= 1; --j) {
00226 /* Computing MIN */
00227                 i__1 = *kl, i__2 = *n - j;
00228                 lm = min(i__1,i__2);
00229                 dgemv_("Transpose", &lm, nrhs, &c_b7, &b[j + 1 + b_dim1], ldb, 
00230                          &ab[kd + 1 + j * ab_dim1], &c__1, &c_b23, &b[j + 
00231                         b_dim1], ldb);
00232                 l = ipiv[j];
00233                 if (l != j) {
00234                     dswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb);
00235                 }
00236 /* L40: */
00237             }
00238         }
00239     }
00240     return 0;
00241 
00242 /*     End of DGBTRS */
00243 
00244 } /* dgbtrs_ */


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