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