stbsv.c
Go to the documentation of this file.
00001 /* stbsv.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 /* Subroutine */ int stbsv_(char *uplo, char *trans, char *diag, integer *n, 
00017         integer *k, real *a, integer *lda, real *x, integer *incx)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00021 
00022     /* Local variables */
00023     integer i__, j, l, ix, jx, kx, info;
00024     real temp;
00025     extern logical lsame_(char *, char *);
00026     integer kplus1;
00027     extern /* Subroutine */ int xerbla_(char *, integer *);
00028     logical nounit;
00029 
00030 /*     .. Scalar Arguments .. */
00031 /*     .. */
00032 /*     .. Array Arguments .. */
00033 /*     .. */
00034 
00035 /*  Purpose */
00036 /*  ======= */
00037 
00038 /*  STBSV  solves one of the systems of equations */
00039 
00040 /*     A*x = b,   or   A'*x = b, */
00041 
00042 /*  where b and x are n element vectors and A is an n by n unit, or */
00043 /*  non-unit, upper or lower triangular band matrix, with ( k + 1 ) */
00044 /*  diagonals. */
00045 
00046 /*  No test for singularity or near-singularity is included in this */
00047 /*  routine. Such tests must be performed before calling this routine. */
00048 
00049 /*  Arguments */
00050 /*  ========== */
00051 
00052 /*  UPLO   - CHARACTER*1. */
00053 /*           On entry, UPLO specifies whether the matrix is an upper or */
00054 /*           lower triangular matrix as follows: */
00055 
00056 /*              UPLO = 'U' or 'u'   A is an upper triangular matrix. */
00057 
00058 /*              UPLO = 'L' or 'l'   A is a lower triangular matrix. */
00059 
00060 /*           Unchanged on exit. */
00061 
00062 /*  TRANS  - CHARACTER*1. */
00063 /*           On entry, TRANS specifies the equations to be solved as */
00064 /*           follows: */
00065 
00066 /*              TRANS = 'N' or 'n'   A*x = b. */
00067 
00068 /*              TRANS = 'T' or 't'   A'*x = b. */
00069 
00070 /*              TRANS = 'C' or 'c'   A'*x = b. */
00071 
00072 /*           Unchanged on exit. */
00073 
00074 /*  DIAG   - CHARACTER*1. */
00075 /*           On entry, DIAG specifies whether or not A is unit */
00076 /*           triangular as follows: */
00077 
00078 /*              DIAG = 'U' or 'u'   A is assumed to be unit triangular. */
00079 
00080 /*              DIAG = 'N' or 'n'   A is not assumed to be unit */
00081 /*                                  triangular. */
00082 
00083 /*           Unchanged on exit. */
00084 
00085 /*  N      - INTEGER. */
00086 /*           On entry, N specifies the order of the matrix A. */
00087 /*           N must be at least zero. */
00088 /*           Unchanged on exit. */
00089 
00090 /*  K      - INTEGER. */
00091 /*           On entry with UPLO = 'U' or 'u', K specifies the number of */
00092 /*           super-diagonals of the matrix A. */
00093 /*           On entry with UPLO = 'L' or 'l', K specifies the number of */
00094 /*           sub-diagonals of the matrix A. */
00095 /*           K must satisfy  0 .le. K. */
00096 /*           Unchanged on exit. */
00097 
00098 /*  A      - REAL             array of DIMENSION ( LDA, n ). */
00099 /*           Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) */
00100 /*           by n part of the array A must contain the upper triangular */
00101 /*           band part of the matrix of coefficients, supplied column by */
00102 /*           column, with the leading diagonal of the matrix in row */
00103 /*           ( k + 1 ) of the array, the first super-diagonal starting at */
00104 /*           position 2 in row k, and so on. The top left k by k triangle */
00105 /*           of the array A is not referenced. */
00106 /*           The following program segment will transfer an upper */
00107 /*           triangular band matrix from conventional full matrix storage */
00108 /*           to band storage: */
00109 
00110 /*                 DO 20, J = 1, N */
00111 /*                    M = K + 1 - J */
00112 /*                    DO 10, I = MAX( 1, J - K ), J */
00113 /*                       A( M + I, J ) = matrix( I, J ) */
00114 /*              10    CONTINUE */
00115 /*              20 CONTINUE */
00116 
00117 /*           Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) */
00118 /*           by n part of the array A must contain the lower triangular */
00119 /*           band part of the matrix of coefficients, supplied column by */
00120 /*           column, with the leading diagonal of the matrix in row 1 of */
00121 /*           the array, the first sub-diagonal starting at position 1 in */
00122 /*           row 2, and so on. The bottom right k by k triangle of the */
00123 /*           array A is not referenced. */
00124 /*           The following program segment will transfer a lower */
00125 /*           triangular band matrix from conventional full matrix storage */
00126 /*           to band storage: */
00127 
00128 /*                 DO 20, J = 1, N */
00129 /*                    M = 1 - J */
00130 /*                    DO 10, I = J, MIN( N, J + K ) */
00131 /*                       A( M + I, J ) = matrix( I, J ) */
00132 /*              10    CONTINUE */
00133 /*              20 CONTINUE */
00134 
00135 /*           Note that when DIAG = 'U' or 'u' the elements of the array A */
00136 /*           corresponding to the diagonal elements of the matrix are not */
00137 /*           referenced, but are assumed to be unity. */
00138 /*           Unchanged on exit. */
00139 
00140 /*  LDA    - INTEGER. */
00141 /*           On entry, LDA specifies the first dimension of A as declared */
00142 /*           in the calling (sub) program. LDA must be at least */
00143 /*           ( k + 1 ). */
00144 /*           Unchanged on exit. */
00145 
00146 /*  X      - REAL             array of dimension at least */
00147 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00148 /*           Before entry, the incremented array X must contain the n */
00149 /*           element right-hand side vector b. On exit, X is overwritten */
00150 /*           with the solution vector x. */
00151 
00152 /*  INCX   - INTEGER. */
00153 /*           On entry, INCX specifies the increment for the elements of */
00154 /*           X. INCX must not be zero. */
00155 /*           Unchanged on exit. */
00156 
00157 
00158 /*  Level 2 Blas routine. */
00159 
00160 /*  -- Written on 22-October-1986. */
00161 /*     Jack Dongarra, Argonne National Lab. */
00162 /*     Jeremy Du Croz, Nag Central Office. */
00163 /*     Sven Hammarling, Nag Central Office. */
00164 /*     Richard Hanson, Sandia National Labs. */
00165 
00166 
00167 /*     .. Parameters .. */
00168 /*     .. */
00169 /*     .. Local Scalars .. */
00170 /*     .. */
00171 /*     .. External Functions .. */
00172 /*     .. */
00173 /*     .. External Subroutines .. */
00174 /*     .. */
00175 /*     .. Intrinsic Functions .. */
00176 /*     .. */
00177 
00178 /*     Test the input parameters. */
00179 
00180     /* Parameter adjustments */
00181     a_dim1 = *lda;
00182     a_offset = 1 + a_dim1;
00183     a -= a_offset;
00184     --x;
00185 
00186     /* Function Body */
00187     info = 0;
00188     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00189         info = 1;
00190     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00191             "T") && ! lsame_(trans, "C")) {
00192         info = 2;
00193     } else if (! lsame_(diag, "U") && ! lsame_(diag, 
00194             "N")) {
00195         info = 3;
00196     } else if (*n < 0) {
00197         info = 4;
00198     } else if (*k < 0) {
00199         info = 5;
00200     } else if (*lda < *k + 1) {
00201         info = 7;
00202     } else if (*incx == 0) {
00203         info = 9;
00204     }
00205     if (info != 0) {
00206         xerbla_("STBSV ", &info);
00207         return 0;
00208     }
00209 
00210 /*     Quick return if possible. */
00211 
00212     if (*n == 0) {
00213         return 0;
00214     }
00215 
00216     nounit = lsame_(diag, "N");
00217 
00218 /*     Set up the start point in X if the increment is not unity. This */
00219 /*     will be  ( N - 1 )*INCX  too small for descending loops. */
00220 
00221     if (*incx <= 0) {
00222         kx = 1 - (*n - 1) * *incx;
00223     } else if (*incx != 1) {
00224         kx = 1;
00225     }
00226 
00227 /*     Start the operations. In this version the elements of A are */
00228 /*     accessed by sequentially with one pass through A. */
00229 
00230     if (lsame_(trans, "N")) {
00231 
00232 /*        Form  x := inv( A )*x. */
00233 
00234         if (lsame_(uplo, "U")) {
00235             kplus1 = *k + 1;
00236             if (*incx == 1) {
00237                 for (j = *n; j >= 1; --j) {
00238                     if (x[j] != 0.f) {
00239                         l = kplus1 - j;
00240                         if (nounit) {
00241                             x[j] /= a[kplus1 + j * a_dim1];
00242                         }
00243                         temp = x[j];
00244 /* Computing MAX */
00245                         i__2 = 1, i__3 = j - *k;
00246                         i__1 = max(i__2,i__3);
00247                         for (i__ = j - 1; i__ >= i__1; --i__) {
00248                             x[i__] -= temp * a[l + i__ + j * a_dim1];
00249 /* L10: */
00250                         }
00251                     }
00252 /* L20: */
00253                 }
00254             } else {
00255                 kx += (*n - 1) * *incx;
00256                 jx = kx;
00257                 for (j = *n; j >= 1; --j) {
00258                     kx -= *incx;
00259                     if (x[jx] != 0.f) {
00260                         ix = kx;
00261                         l = kplus1 - j;
00262                         if (nounit) {
00263                             x[jx] /= a[kplus1 + j * a_dim1];
00264                         }
00265                         temp = x[jx];
00266 /* Computing MAX */
00267                         i__2 = 1, i__3 = j - *k;
00268                         i__1 = max(i__2,i__3);
00269                         for (i__ = j - 1; i__ >= i__1; --i__) {
00270                             x[ix] -= temp * a[l + i__ + j * a_dim1];
00271                             ix -= *incx;
00272 /* L30: */
00273                         }
00274                     }
00275                     jx -= *incx;
00276 /* L40: */
00277                 }
00278             }
00279         } else {
00280             if (*incx == 1) {
00281                 i__1 = *n;
00282                 for (j = 1; j <= i__1; ++j) {
00283                     if (x[j] != 0.f) {
00284                         l = 1 - j;
00285                         if (nounit) {
00286                             x[j] /= a[j * a_dim1 + 1];
00287                         }
00288                         temp = x[j];
00289 /* Computing MIN */
00290                         i__3 = *n, i__4 = j + *k;
00291                         i__2 = min(i__3,i__4);
00292                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00293                             x[i__] -= temp * a[l + i__ + j * a_dim1];
00294 /* L50: */
00295                         }
00296                     }
00297 /* L60: */
00298                 }
00299             } else {
00300                 jx = kx;
00301                 i__1 = *n;
00302                 for (j = 1; j <= i__1; ++j) {
00303                     kx += *incx;
00304                     if (x[jx] != 0.f) {
00305                         ix = kx;
00306                         l = 1 - j;
00307                         if (nounit) {
00308                             x[jx] /= a[j * a_dim1 + 1];
00309                         }
00310                         temp = x[jx];
00311 /* Computing MIN */
00312                         i__3 = *n, i__4 = j + *k;
00313                         i__2 = min(i__3,i__4);
00314                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00315                             x[ix] -= temp * a[l + i__ + j * a_dim1];
00316                             ix += *incx;
00317 /* L70: */
00318                         }
00319                     }
00320                     jx += *incx;
00321 /* L80: */
00322                 }
00323             }
00324         }
00325     } else {
00326 
00327 /*        Form  x := inv( A')*x. */
00328 
00329         if (lsame_(uplo, "U")) {
00330             kplus1 = *k + 1;
00331             if (*incx == 1) {
00332                 i__1 = *n;
00333                 for (j = 1; j <= i__1; ++j) {
00334                     temp = x[j];
00335                     l = kplus1 - j;
00336 /* Computing MAX */
00337                     i__2 = 1, i__3 = j - *k;
00338                     i__4 = j - 1;
00339                     for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00340                         temp -= a[l + i__ + j * a_dim1] * x[i__];
00341 /* L90: */
00342                     }
00343                     if (nounit) {
00344                         temp /= a[kplus1 + j * a_dim1];
00345                     }
00346                     x[j] = temp;
00347 /* L100: */
00348                 }
00349             } else {
00350                 jx = kx;
00351                 i__1 = *n;
00352                 for (j = 1; j <= i__1; ++j) {
00353                     temp = x[jx];
00354                     ix = kx;
00355                     l = kplus1 - j;
00356 /* Computing MAX */
00357                     i__4 = 1, i__2 = j - *k;
00358                     i__3 = j - 1;
00359                     for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
00360                         temp -= a[l + i__ + j * a_dim1] * x[ix];
00361                         ix += *incx;
00362 /* L110: */
00363                     }
00364                     if (nounit) {
00365                         temp /= a[kplus1 + j * a_dim1];
00366                     }
00367                     x[jx] = temp;
00368                     jx += *incx;
00369                     if (j > *k) {
00370                         kx += *incx;
00371                     }
00372 /* L120: */
00373                 }
00374             }
00375         } else {
00376             if (*incx == 1) {
00377                 for (j = *n; j >= 1; --j) {
00378                     temp = x[j];
00379                     l = 1 - j;
00380 /* Computing MIN */
00381                     i__1 = *n, i__3 = j + *k;
00382                     i__4 = j + 1;
00383                     for (i__ = min(i__1,i__3); i__ >= i__4; --i__) {
00384                         temp -= a[l + i__ + j * a_dim1] * x[i__];
00385 /* L130: */
00386                     }
00387                     if (nounit) {
00388                         temp /= a[j * a_dim1 + 1];
00389                     }
00390                     x[j] = temp;
00391 /* L140: */
00392                 }
00393             } else {
00394                 kx += (*n - 1) * *incx;
00395                 jx = kx;
00396                 for (j = *n; j >= 1; --j) {
00397                     temp = x[jx];
00398                     ix = kx;
00399                     l = 1 - j;
00400 /* Computing MIN */
00401                     i__4 = *n, i__1 = j + *k;
00402                     i__3 = j + 1;
00403                     for (i__ = min(i__4,i__1); i__ >= i__3; --i__) {
00404                         temp -= a[l + i__ + j * a_dim1] * x[ix];
00405                         ix -= *incx;
00406 /* L150: */
00407                     }
00408                     if (nounit) {
00409                         temp /= a[j * a_dim1 + 1];
00410                     }
00411                     x[jx] = temp;
00412                     jx -= *incx;
00413                     if (*n - j >= *k) {
00414                         kx -= *incx;
00415                     }
00416 /* L160: */
00417                 }
00418             }
00419         }
00420     }
00421 
00422     return 0;
00423 
00424 /*     End of STBSV . */
00425 
00426 } /* stbsv_ */


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