Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dtrmv.c

Go to the documentation of this file.
00001 /* DTRMV.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 #include "cblasimpexp.h"
00008 
00009 /* DECK DTRMV */
00010 /* Subroutine */ int __IMPEXP__ dtrmv_(uplo, trans, diag, n, a, lda, x, incx, uplo_len, 
00011         trans_len, diag_len)
00012 char *uplo, *trans, *diag;
00013 integer *n;
00014 doublereal *a;
00015 integer *lda;
00016 doublereal *x;
00017 integer *incx;
00018 ftnlen uplo_len;
00019 ftnlen trans_len;
00020 ftnlen diag_len;
00021 {
00022     /* System generated locals */
00023     integer a_dim1, a_offset, i__1, i__2;
00024 
00025     /* Local variables */
00026     static integer info;
00027     static doublereal temp;
00028     static integer i, j;
00029     extern logical lsame_();
00030     static integer ix, jx, kx;
00031     extern /* Subroutine */ int xerbla_();
00032     static logical nounit;
00033 
00034 /* ***BEGIN PROLOGUE  DTRMV */
00035 /* ***PURPOSE  Perform one of the matrix-vector operations. */
00036 /* ***LIBRARY   SLATEC (BLAS) */
00037 /* ***CATEGORY  D1B4 */
00038 /* ***TYPE      DOUBLE PRECISION (STRMV-S, DTRMV-D, CTRMV-C) */
00039 /* ***KEYWORDS  LEVEL 2 BLAS, LINEAR ALGEBRA */
00040 /* ***AUTHOR  Dongarra, J. J., (ANL) */
00041 /*           Du Croz, J., (NAG) */
00042 /*           Hammarling, S., (NAG) */
00043 /*           Hanson, R. J., (SNLA) */
00044 /* ***DESCRIPTION */
00045 
00046 /*  DTRMV  performs one of the matrix-vector operations */
00047 
00048 /*     x := A*x,   or   x := A'*x, */
00049 
00050 /*  where x is an n element vector and  A is an n by n unit, or non-unit, 
00051 */
00052 /*  upper or lower triangular matrix. */
00053 
00054 /*  Parameters */
00055 /*  ========== */
00056 
00057 /*  UPLO   - CHARACTER*1. */
00058 /*           On entry, UPLO specifies whether the matrix is an upper or */
00059 /*           lower triangular matrix as follows: */
00060 
00061 /*              UPLO = 'U' or 'u'   A is an upper triangular matrix. */
00062 
00063 /*              UPLO = 'L' or 'l'   A is a lower triangular matrix. */
00064 
00065 /*           Unchanged on exit. */
00066 
00067 /*  TRANS  - CHARACTER*1. */
00068 /*           On entry, TRANS specifies the operation to be performed as */
00069 /*           follows: */
00070 
00071 /*              TRANS = 'N' or 'n'   x := A*x. */
00072 
00073 /*              TRANS = 'T' or 't'   x := A'*x. */
00074 
00075 /*              TRANS = 'C' or 'c'   x := A'*x. */
00076 
00077 /*           Unchanged on exit. */
00078 
00079 /*  DIAG   - CHARACTER*1. */
00080 /*           On entry, DIAG specifies whether or not A is unit */
00081 /*           triangular as follows: */
00082 
00083 /*              DIAG = 'U' or 'u'   A is assumed to be unit triangular. */
00084 
00085 /*              DIAG = 'N' or 'n'   A is not assumed to be unit */
00086 /*                                  triangular. */
00087 
00088 /*           Unchanged on exit. */
00089 
00090 /*  N      - INTEGER. */
00091 /*           On entry, N specifies the order of the matrix A. */
00092 /*           N must be at least zero. */
00093 /*           Unchanged on exit. */
00094 
00095 /*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n). */
00096 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00097 /*           upper triangular part of the array A must contain the upper 
00098 */
00099 /*           triangular matrix and the strictly lower triangular part of 
00100 */
00101 /*           A is not referenced. */
00102 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00103 /*           lower triangular part of the array A must contain the lower 
00104 */
00105 /*           triangular matrix and the strictly upper triangular part of 
00106 */
00107 /*           A is not referenced. */
00108 /*           Note that when  DIAG = 'U' or 'u', the diagonal elements of 
00109 */
00110 /*           A are not referenced either, but are assumed to be unity. */
00111 /*           Unchanged on exit. */
00112 
00113 /*  LDA    - INTEGER. */
00114 /*           On entry, LDA specifies the first dimension of A as declared 
00115 */
00116 /*           in the calling (sub) program. LDA must be at least */
00117 /*           max( 1, n ). */
00118 /*           Unchanged on exit. */
00119 
00120 /*  X      - DOUBLE PRECISION array of dimension at least */
00121 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00122 /*           Before entry, the incremented array X must contain the n */
00123 /*           element vector x. On exit, X is overwritten with the */
00124 /*           tranformed vector x. */
00125 
00126 /*  INCX   - INTEGER. */
00127 /*           On entry, INCX specifies the increment for the elements of */
00128 /*           X. INCX must not be zero. */
00129 /*           Unchanged on exit. */
00130 
00131 /* ***REFERENCES  Dongarra, J. J., Du Croz, J., Hammarling, S., and */
00132 /*                 Hanson, R. J.  An extended set of Fortran basic linear 
00133 */
00134 /*                 algebra subprograms.  ACM TOMS, Vol. 14, No. 1, */
00135 /*                 pp. 1-17, March 1988. */
00136 /* ***ROUTINES CALLED  LSAME, XERBLA */
00137 /* ***REVISION HISTORY  (YYMMDD) */
00138 /*   861022  DATE WRITTEN */
00139 /*   910605  Modified to meet SLATEC prologue standards.  Only comment */
00140 /*           lines were modified.  (BKS) */
00141 /* ***END PROLOGUE  DTRMV */
00142 /*     .. Scalar Arguments .. */
00143 /*     .. Array Arguments .. */
00144 /*     .. Parameters .. */
00145 /*     .. Local Scalars .. */
00146 /*     .. External Functions .. */
00147 /*     .. External Subroutines .. */
00148 /*     .. Intrinsic Functions .. */
00149 /* ***FIRST EXECUTABLE STATEMENT  DTRMV */
00150 
00151 /*     Test the input parameters. */
00152 
00153     /* Parameter adjustments */
00154     a_dim1 = *lda;
00155     a_offset = a_dim1 + 1;
00156     a -= a_offset;
00157     --x;
00158 
00159     /* Function Body */
00160     info = 0;
00161     if (! lsame_(uplo, "U", 1L, 1L) && ! lsame_(uplo, "L", 1L, 1L)) {
00162         info = 1;
00163     } else if (! lsame_(trans, "N", 1L, 1L) && ! lsame_(trans, "T", 1L, 1L) &&
00164              ! lsame_(trans, "C", 1L, 1L)) {
00165         info = 2;
00166     } else if (! lsame_(diag, "U", 1L, 1L) && ! lsame_(diag, "N", 1L, 1L)) {
00167         info = 3;
00168     } else if (*n < 0) {
00169         info = 4;
00170     } else if (*lda < max(1,*n)) {
00171         info = 6;
00172     } else if (*incx == 0) {
00173         info = 8;
00174     }
00175     if (info != 0) {
00176         xerbla_("DTRMV ", &info, 6L);
00177         return 0;
00178     }
00179 
00180 /*     Quick return if possible. */
00181 
00182     if (*n == 0) {
00183         return 0;
00184     }
00185 
00186     nounit = lsame_(diag, "N", 1L, 1L);
00187 
00188 /*     Set up the start point in X if the increment is not unity. This */
00189 /*     will be  ( N - 1 )*INCX  too small for descending loops. */
00190 
00191     if (*incx <= 0) {
00192         kx = 1 - (*n - 1) * *incx;
00193     } else if (*incx != 1) {
00194         kx = 1;
00195     }
00196 
00197 /*     Start the operations. In this version the elements of A are */
00198 /*     accessed sequentially with one pass through A. */
00199 
00200     if (lsame_(trans, "N", 1L, 1L)) {
00201 
00202 /*        Form  x := A*x. */
00203 
00204         if (lsame_(uplo, "U", 1L, 1L)) {
00205             if (*incx == 1) {
00206                 i__1 = *n;
00207                 for (j = 1; j <= i__1; ++j) {
00208                     if (x[j] != 0.) {
00209                         temp = x[j];
00210                         i__2 = j - 1;
00211                         for (i = 1; i <= i__2; ++i) {
00212                             x[i] += temp * a[i + j * a_dim1];
00213 /* L10: */
00214                         }
00215                         if (nounit) {
00216                             x[j] *= a[j + j * a_dim1];
00217                         }
00218                     }
00219 /* L20: */
00220                 }
00221             } else {
00222                 jx = kx;
00223                 i__1 = *n;
00224                 for (j = 1; j <= i__1; ++j) {
00225                     if (x[jx] != 0.) {
00226                         temp = x[jx];
00227                         ix = kx;
00228                         i__2 = j - 1;
00229                         for (i = 1; i <= i__2; ++i) {
00230                             x[ix] += temp * a[i + j * a_dim1];
00231                             ix += *incx;
00232 /* L30: */
00233                         }
00234                         if (nounit) {
00235                             x[jx] *= a[j + j * a_dim1];
00236                         }
00237                     }
00238                     jx += *incx;
00239 /* L40: */
00240                 }
00241             }
00242         } else {
00243             if (*incx == 1) {
00244                 for (j = *n; j >= 1; --j) {
00245                     if (x[j] != 0.) {
00246                         temp = x[j];
00247                         i__1 = j + 1;
00248                         for (i = *n; i >= i__1; --i) {
00249                             x[i] += temp * a[i + j * a_dim1];
00250 /* L50: */
00251                         }
00252                         if (nounit) {
00253                             x[j] *= a[j + j * a_dim1];
00254                         }
00255                     }
00256 /* L60: */
00257                 }
00258             } else {
00259                 kx += (*n - 1) * *incx;
00260                 jx = kx;
00261                 for (j = *n; j >= 1; --j) {
00262                     if (x[jx] != 0.) {
00263                         temp = x[jx];
00264                         ix = kx;
00265                         i__1 = j + 1;
00266                         for (i = *n; i >= i__1; --i) {
00267                             x[ix] += temp * a[i + j * a_dim1];
00268                             ix -= *incx;
00269 /* L70: */
00270                         }
00271                         if (nounit) {
00272                             x[jx] *= a[j + j * a_dim1];
00273                         }
00274                     }
00275                     jx -= *incx;
00276 /* L80: */
00277                 }
00278             }
00279         }
00280     } else {
00281 
00282 /*        Form  x := A'*x. */
00283 
00284         if (lsame_(uplo, "U", 1L, 1L)) {
00285             if (*incx == 1) {
00286                 for (j = *n; j >= 1; --j) {
00287                     temp = x[j];
00288                     if (nounit) {
00289                         temp *= a[j + j * a_dim1];
00290                     }
00291                     for (i = j - 1; i >= 1; --i) {
00292                         temp += a[i + j * a_dim1] * x[i];
00293 /* L90: */
00294                     }
00295                     x[j] = temp;
00296 /* L100: */
00297                 }
00298             } else {
00299                 jx = kx + (*n - 1) * *incx;
00300                 for (j = *n; j >= 1; --j) {
00301                     temp = x[jx];
00302                     ix = jx;
00303                     if (nounit) {
00304                         temp *= a[j + j * a_dim1];
00305                     }
00306                     for (i = j - 1; i >= 1; --i) {
00307                         ix -= *incx;
00308                         temp += a[i + j * a_dim1] * x[ix];
00309 /* L110: */
00310                     }
00311                     x[jx] = temp;
00312                     jx -= *incx;
00313 /* L120: */
00314                 }
00315             }
00316         } else {
00317             if (*incx == 1) {
00318                 i__1 = *n;
00319                 for (j = 1; j <= i__1; ++j) {
00320                     temp = x[j];
00321                     if (nounit) {
00322                         temp *= a[j + j * a_dim1];
00323                     }
00324                     i__2 = *n;
00325                     for (i = j + 1; i <= i__2; ++i) {
00326                         temp += a[i + j * a_dim1] * x[i];
00327 /* L130: */
00328                     }
00329                     x[j] = temp;
00330 /* L140: */
00331                 }
00332             } else {
00333                 jx = kx;
00334                 i__1 = *n;
00335                 for (j = 1; j <= i__1; ++j) {
00336                     temp = x[jx];
00337                     ix = jx;
00338                     if (nounit) {
00339                         temp *= a[j + j * a_dim1];
00340                     }
00341                     i__2 = *n;
00342                     for (i = j + 1; i <= i__2; ++i) {
00343                         ix += *incx;
00344                         temp += a[i + j * a_dim1] * x[ix];
00345 /* L150: */
00346                     }
00347                     x[jx] = temp;
00348                     jx += *incx;
00349 /* L160: */
00350                 }
00351             }
00352         }
00353     }
00354 
00355     return 0;
00356 
00357 /*     End of DTRMV . */
00358 
00359 } /* dtrmv_ */
00360 

Generated on Wed Sep 5 12:54:20 2007 for DSACSS Operational Code by  doxygen 1.3.9.1