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


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