Chris@202: /* dtrmv.f -- translated by f2c (version 20061008). Chris@202: You must link the resulting object file with libf2c: Chris@202: on Microsoft Windows system, link with libf2c.lib; Chris@202: on Linux or Unix systems, link with .../path/to/libf2c.a -lm Chris@202: or, if you install libf2c.a in a standard place, with -lf2c -lm Chris@202: -- in that order, at the end of the command line, as in Chris@202: cc *.o -lf2c -lm Chris@202: Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., Chris@202: Chris@202: http://www.netlib.org/f2c/libf2c.zip Chris@202: */ Chris@202: Chris@202: #include "f2c.h" Chris@202: #include "blaswrap.h" Chris@202: Chris@202: /* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, integer *n, Chris@202: doublereal *a, integer *lda, doublereal *x, integer *incx) Chris@202: { Chris@202: /* System generated locals */ Chris@202: integer a_dim1, a_offset, i__1, i__2; Chris@202: Chris@202: /* Local variables */ Chris@202: integer i__, j, ix, jx, kx, info; Chris@202: doublereal temp; Chris@202: extern logical lsame_(char *, char *); Chris@202: extern /* Subroutine */ int xerbla_(char *, integer *); Chris@202: logical nounit; Chris@202: Chris@202: /* .. Scalar Arguments .. */ Chris@202: /* .. */ Chris@202: /* .. Array Arguments .. */ Chris@202: /* .. */ Chris@202: Chris@202: /* Purpose */ Chris@202: /* ======= */ Chris@202: Chris@202: /* DTRMV performs one of the matrix-vector operations */ Chris@202: Chris@202: /* x := A*x, or x := A'*x, */ Chris@202: Chris@202: /* where x is an n element vector and A is an n by n unit, or non-unit, */ Chris@202: /* upper or lower triangular matrix. */ Chris@202: Chris@202: /* Arguments */ Chris@202: /* ========== */ Chris@202: Chris@202: /* UPLO - CHARACTER*1. */ Chris@202: /* On entry, UPLO specifies whether the matrix is an upper or */ Chris@202: /* lower triangular matrix as follows: */ Chris@202: Chris@202: /* UPLO = 'U' or 'u' A is an upper triangular matrix. */ Chris@202: Chris@202: /* UPLO = 'L' or 'l' A is a lower triangular matrix. */ Chris@202: Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* TRANS - CHARACTER*1. */ Chris@202: /* On entry, TRANS specifies the operation to be performed as */ Chris@202: /* follows: */ Chris@202: Chris@202: /* TRANS = 'N' or 'n' x := A*x. */ Chris@202: Chris@202: /* TRANS = 'T' or 't' x := A'*x. */ Chris@202: Chris@202: /* TRANS = 'C' or 'c' x := A'*x. */ Chris@202: Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* DIAG - CHARACTER*1. */ Chris@202: /* On entry, DIAG specifies whether or not A is unit */ Chris@202: /* triangular as follows: */ Chris@202: Chris@202: /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */ Chris@202: Chris@202: /* DIAG = 'N' or 'n' A is not assumed to be unit */ Chris@202: /* triangular. */ Chris@202: Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* N - INTEGER. */ Chris@202: /* On entry, N specifies the order of the matrix A. */ Chris@202: /* N must be at least zero. */ Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */ Chris@202: /* Before entry with UPLO = 'U' or 'u', the leading n by n */ Chris@202: /* upper triangular part of the array A must contain the upper */ Chris@202: /* triangular matrix and the strictly lower triangular part of */ Chris@202: /* A is not referenced. */ Chris@202: /* Before entry with UPLO = 'L' or 'l', the leading n by n */ Chris@202: /* lower triangular part of the array A must contain the lower */ Chris@202: /* triangular matrix and the strictly upper triangular part of */ Chris@202: /* A is not referenced. */ Chris@202: /* Note that when DIAG = 'U' or 'u', the diagonal elements of */ Chris@202: /* A are not referenced either, but are assumed to be unity. */ Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* LDA - INTEGER. */ Chris@202: /* On entry, LDA specifies the first dimension of A as declared */ Chris@202: /* in the calling (sub) program. LDA must be at least */ Chris@202: /* max( 1, n ). */ Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: /* X - DOUBLE PRECISION array of dimension at least */ Chris@202: /* ( 1 + ( n - 1 )*abs( INCX ) ). */ Chris@202: /* Before entry, the incremented array X must contain the n */ Chris@202: /* element vector x. On exit, X is overwritten with the */ Chris@202: /* tranformed vector x. */ Chris@202: Chris@202: /* INCX - INTEGER. */ Chris@202: /* On entry, INCX specifies the increment for the elements of */ Chris@202: /* X. INCX must not be zero. */ Chris@202: /* Unchanged on exit. */ Chris@202: Chris@202: Chris@202: /* Level 2 Blas routine. */ Chris@202: Chris@202: /* -- Written on 22-October-1986. */ Chris@202: /* Jack Dongarra, Argonne National Lab. */ Chris@202: /* Jeremy Du Croz, Nag Central Office. */ Chris@202: /* Sven Hammarling, Nag Central Office. */ Chris@202: /* Richard Hanson, Sandia National Labs. */ Chris@202: Chris@202: Chris@202: /* .. Parameters .. */ Chris@202: /* .. */ Chris@202: /* .. Local Scalars .. */ Chris@202: /* .. */ Chris@202: /* .. External Functions .. */ Chris@202: /* .. */ Chris@202: /* .. External Subroutines .. */ Chris@202: /* .. */ Chris@202: /* .. Intrinsic Functions .. */ Chris@202: /* .. */ Chris@202: Chris@202: /* Test the input parameters. */ Chris@202: Chris@202: /* Parameter adjustments */ Chris@202: a_dim1 = *lda; Chris@202: a_offset = 1 + a_dim1; Chris@202: a -= a_offset; Chris@202: --x; Chris@202: Chris@202: /* Function Body */ Chris@202: info = 0; Chris@202: if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { Chris@202: info = 1; Chris@202: } else if (! lsame_(trans, "N") && ! lsame_(trans, Chris@202: "T") && ! lsame_(trans, "C")) { Chris@202: info = 2; Chris@202: } else if (! lsame_(diag, "U") && ! lsame_(diag, Chris@202: "N")) { Chris@202: info = 3; Chris@202: } else if (*n < 0) { Chris@202: info = 4; Chris@202: } else if (*lda < max(1,*n)) { Chris@202: info = 6; Chris@202: } else if (*incx == 0) { Chris@202: info = 8; Chris@202: } Chris@202: if (info != 0) { Chris@202: xerbla_("DTRMV ", &info); Chris@202: return 0; Chris@202: } Chris@202: Chris@202: /* Quick return if possible. */ Chris@202: Chris@202: if (*n == 0) { Chris@202: return 0; Chris@202: } Chris@202: Chris@202: nounit = lsame_(diag, "N"); Chris@202: Chris@202: /* Set up the start point in X if the increment is not unity. This */ Chris@202: /* will be ( N - 1 )*INCX too small for descending loops. */ Chris@202: Chris@202: if (*incx <= 0) { Chris@202: kx = 1 - (*n - 1) * *incx; Chris@202: } else if (*incx != 1) { Chris@202: kx = 1; Chris@202: } Chris@202: Chris@202: /* Start the operations. In this version the elements of A are */ Chris@202: /* accessed sequentially with one pass through A. */ Chris@202: Chris@202: if (lsame_(trans, "N")) { Chris@202: Chris@202: /* Form x := A*x. */ Chris@202: Chris@202: if (lsame_(uplo, "U")) { Chris@202: if (*incx == 1) { Chris@202: i__1 = *n; Chris@202: for (j = 1; j <= i__1; ++j) { Chris@202: if (x[j] != 0.) { Chris@202: temp = x[j]; Chris@202: i__2 = j - 1; Chris@202: for (i__ = 1; i__ <= i__2; ++i__) { Chris@202: x[i__] += temp * a[i__ + j * a_dim1]; Chris@202: /* L10: */ Chris@202: } Chris@202: if (nounit) { Chris@202: x[j] *= a[j + j * a_dim1]; Chris@202: } Chris@202: } Chris@202: /* L20: */ Chris@202: } Chris@202: } else { Chris@202: jx = kx; Chris@202: i__1 = *n; Chris@202: for (j = 1; j <= i__1; ++j) { Chris@202: if (x[jx] != 0.) { Chris@202: temp = x[jx]; Chris@202: ix = kx; Chris@202: i__2 = j - 1; Chris@202: for (i__ = 1; i__ <= i__2; ++i__) { Chris@202: x[ix] += temp * a[i__ + j * a_dim1]; Chris@202: ix += *incx; Chris@202: /* L30: */ Chris@202: } Chris@202: if (nounit) { Chris@202: x[jx] *= a[j + j * a_dim1]; Chris@202: } Chris@202: } Chris@202: jx += *incx; Chris@202: /* L40: */ Chris@202: } Chris@202: } Chris@202: } else { Chris@202: if (*incx == 1) { Chris@202: for (j = *n; j >= 1; --j) { Chris@202: if (x[j] != 0.) { Chris@202: temp = x[j]; Chris@202: i__1 = j + 1; Chris@202: for (i__ = *n; i__ >= i__1; --i__) { Chris@202: x[i__] += temp * a[i__ + j * a_dim1]; Chris@202: /* L50: */ Chris@202: } Chris@202: if (nounit) { Chris@202: x[j] *= a[j + j * a_dim1]; Chris@202: } Chris@202: } Chris@202: /* L60: */ Chris@202: } Chris@202: } else { Chris@202: kx += (*n - 1) * *incx; Chris@202: jx = kx; Chris@202: for (j = *n; j >= 1; --j) { Chris@202: if (x[jx] != 0.) { Chris@202: temp = x[jx]; Chris@202: ix = kx; Chris@202: i__1 = j + 1; Chris@202: for (i__ = *n; i__ >= i__1; --i__) { Chris@202: x[ix] += temp * a[i__ + j * a_dim1]; Chris@202: ix -= *incx; Chris@202: /* L70: */ Chris@202: } Chris@202: if (nounit) { Chris@202: x[jx] *= a[j + j * a_dim1]; Chris@202: } Chris@202: } Chris@202: jx -= *incx; Chris@202: /* L80: */ Chris@202: } Chris@202: } Chris@202: } Chris@202: } else { Chris@202: Chris@202: /* Form x := A'*x. */ Chris@202: Chris@202: if (lsame_(uplo, "U")) { Chris@202: if (*incx == 1) { Chris@202: for (j = *n; j >= 1; --j) { Chris@202: temp = x[j]; Chris@202: if (nounit) { Chris@202: temp *= a[j + j * a_dim1]; Chris@202: } Chris@202: for (i__ = j - 1; i__ >= 1; --i__) { Chris@202: temp += a[i__ + j * a_dim1] * x[i__]; Chris@202: /* L90: */ Chris@202: } Chris@202: x[j] = temp; Chris@202: /* L100: */ Chris@202: } Chris@202: } else { Chris@202: jx = kx + (*n - 1) * *incx; Chris@202: for (j = *n; j >= 1; --j) { Chris@202: temp = x[jx]; Chris@202: ix = jx; Chris@202: if (nounit) { Chris@202: temp *= a[j + j * a_dim1]; Chris@202: } Chris@202: for (i__ = j - 1; i__ >= 1; --i__) { Chris@202: ix -= *incx; Chris@202: temp += a[i__ + j * a_dim1] * x[ix]; Chris@202: /* L110: */ Chris@202: } Chris@202: x[jx] = temp; Chris@202: jx -= *incx; Chris@202: /* L120: */ Chris@202: } Chris@202: } Chris@202: } else { Chris@202: if (*incx == 1) { Chris@202: i__1 = *n; Chris@202: for (j = 1; j <= i__1; ++j) { Chris@202: temp = x[j]; Chris@202: if (nounit) { Chris@202: temp *= a[j + j * a_dim1]; Chris@202: } Chris@202: i__2 = *n; Chris@202: for (i__ = j + 1; i__ <= i__2; ++i__) { Chris@202: temp += a[i__ + j * a_dim1] * x[i__]; Chris@202: /* L130: */ Chris@202: } Chris@202: x[j] = temp; Chris@202: /* L140: */ Chris@202: } Chris@202: } else { Chris@202: jx = kx; Chris@202: i__1 = *n; Chris@202: for (j = 1; j <= i__1; ++j) { Chris@202: temp = x[jx]; Chris@202: ix = jx; Chris@202: if (nounit) { Chris@202: temp *= a[j + j * a_dim1]; Chris@202: } Chris@202: i__2 = *n; Chris@202: for (i__ = j + 1; i__ <= i__2; ++i__) { Chris@202: ix += *incx; Chris@202: temp += a[i__ + j * a_dim1] * x[ix]; Chris@202: /* L150: */ Chris@202: } Chris@202: x[jx] = temp; Chris@202: jx += *incx; Chris@202: /* L160: */ Chris@202: } Chris@202: } Chris@202: } Chris@202: } Chris@202: Chris@202: return 0; Chris@202: Chris@202: /* End of DTRMV . */ Chris@202: Chris@202: } /* dtrmv_ */