annotate ext/cblas/src/dtrmv.c @ 495:1bea13b8f951

Style fixes in constant-Q: avoid unsigned, reuse our Window class, fix comments
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 31 May 2019 18:25:31 +0100
parents 905e45637745
children
rev   line source
c@427 1 /* dtrmv.f -- translated by f2c (version 20061008).
c@427 2 You must link the resulting object file with libf2c:
c@427 3 on Microsoft Windows system, link with libf2c.lib;
c@427 4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
c@427 5 or, if you install libf2c.a in a standard place, with -lf2c -lm
c@427 6 -- in that order, at the end of the command line, as in
c@427 7 cc *.o -lf2c -lm
c@427 8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
c@427 9
c@427 10 http://www.netlib.org/f2c/libf2c.zip
c@427 11 */
c@427 12
c@427 13 #include "f2c.h"
c@427 14 #include "blaswrap.h"
c@427 15
c@427 16 /* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, integer *n,
c@427 17 doublereal *a, integer *lda, doublereal *x, integer *incx)
c@427 18 {
c@427 19 /* System generated locals */
c@427 20 integer a_dim1, a_offset, i__1, i__2;
c@427 21
c@427 22 /* Local variables */
c@427 23 integer i__, j, ix, jx, kx, info;
c@427 24 doublereal temp;
c@427 25 extern logical lsame_(char *, char *);
c@427 26 extern /* Subroutine */ int xerbla_(char *, integer *);
c@427 27 logical nounit;
c@427 28
c@427 29 /* .. Scalar Arguments .. */
c@427 30 /* .. */
c@427 31 /* .. Array Arguments .. */
c@427 32 /* .. */
c@427 33
c@427 34 /* Purpose */
c@427 35 /* ======= */
c@427 36
c@427 37 /* DTRMV performs one of the matrix-vector operations */
c@427 38
c@427 39 /* x := A*x, or x := A'*x, */
c@427 40
c@427 41 /* where x is an n element vector and A is an n by n unit, or non-unit, */
c@427 42 /* upper or lower triangular matrix. */
c@427 43
c@427 44 /* Arguments */
c@427 45 /* ========== */
c@427 46
c@427 47 /* UPLO - CHARACTER*1. */
c@427 48 /* On entry, UPLO specifies whether the matrix is an upper or */
c@427 49 /* lower triangular matrix as follows: */
c@427 50
c@427 51 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
c@427 52
c@427 53 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
c@427 54
c@427 55 /* Unchanged on exit. */
c@427 56
c@427 57 /* TRANS - CHARACTER*1. */
c@427 58 /* On entry, TRANS specifies the operation to be performed as */
c@427 59 /* follows: */
c@427 60
c@427 61 /* TRANS = 'N' or 'n' x := A*x. */
c@427 62
c@427 63 /* TRANS = 'T' or 't' x := A'*x. */
c@427 64
c@427 65 /* TRANS = 'C' or 'c' x := A'*x. */
c@427 66
c@427 67 /* Unchanged on exit. */
c@427 68
c@427 69 /* DIAG - CHARACTER*1. */
c@427 70 /* On entry, DIAG specifies whether or not A is unit */
c@427 71 /* triangular as follows: */
c@427 72
c@427 73 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
c@427 74
c@427 75 /* DIAG = 'N' or 'n' A is not assumed to be unit */
c@427 76 /* triangular. */
c@427 77
c@427 78 /* Unchanged on exit. */
c@427 79
c@427 80 /* N - INTEGER. */
c@427 81 /* On entry, N specifies the order of the matrix A. */
c@427 82 /* N must be at least zero. */
c@427 83 /* Unchanged on exit. */
c@427 84
c@427 85 /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
c@427 86 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
c@427 87 /* upper triangular part of the array A must contain the upper */
c@427 88 /* triangular matrix and the strictly lower triangular part of */
c@427 89 /* A is not referenced. */
c@427 90 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
c@427 91 /* lower triangular part of the array A must contain the lower */
c@427 92 /* triangular matrix and the strictly upper triangular part of */
c@427 93 /* A is not referenced. */
c@427 94 /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
c@427 95 /* A are not referenced either, but are assumed to be unity. */
c@427 96 /* Unchanged on exit. */
c@427 97
c@427 98 /* LDA - INTEGER. */
c@427 99 /* On entry, LDA specifies the first dimension of A as declared */
c@427 100 /* in the calling (sub) program. LDA must be at least */
c@427 101 /* max( 1, n ). */
c@427 102 /* Unchanged on exit. */
c@427 103
c@427 104 /* X - DOUBLE PRECISION array of dimension at least */
c@427 105 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
c@427 106 /* Before entry, the incremented array X must contain the n */
c@427 107 /* element vector x. On exit, X is overwritten with the */
c@427 108 /* tranformed vector x. */
c@427 109
c@427 110 /* INCX - INTEGER. */
c@427 111 /* On entry, INCX specifies the increment for the elements of */
c@427 112 /* X. INCX must not be zero. */
c@427 113 /* Unchanged on exit. */
c@427 114
c@427 115
c@427 116 /* Level 2 Blas routine. */
c@427 117
c@427 118 /* -- Written on 22-October-1986. */
c@427 119 /* Jack Dongarra, Argonne National Lab. */
c@427 120 /* Jeremy Du Croz, Nag Central Office. */
c@427 121 /* Sven Hammarling, Nag Central Office. */
c@427 122 /* Richard Hanson, Sandia National Labs. */
c@427 123
c@427 124
c@427 125 /* .. Parameters .. */
c@427 126 /* .. */
c@427 127 /* .. Local Scalars .. */
c@427 128 /* .. */
c@427 129 /* .. External Functions .. */
c@427 130 /* .. */
c@427 131 /* .. External Subroutines .. */
c@427 132 /* .. */
c@427 133 /* .. Intrinsic Functions .. */
c@427 134 /* .. */
c@427 135
c@427 136 /* Test the input parameters. */
c@427 137
c@427 138 /* Parameter adjustments */
c@427 139 a_dim1 = *lda;
c@427 140 a_offset = 1 + a_dim1;
c@427 141 a -= a_offset;
c@427 142 --x;
c@427 143
c@427 144 /* Function Body */
c@427 145 info = 0;
c@427 146 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
c@427 147 info = 1;
c@427 148 } else if (! lsame_(trans, "N") && ! lsame_(trans,
c@427 149 "T") && ! lsame_(trans, "C")) {
c@427 150 info = 2;
c@427 151 } else if (! lsame_(diag, "U") && ! lsame_(diag,
c@427 152 "N")) {
c@427 153 info = 3;
c@427 154 } else if (*n < 0) {
c@427 155 info = 4;
c@427 156 } else if (*lda < max(1,*n)) {
c@427 157 info = 6;
c@427 158 } else if (*incx == 0) {
c@427 159 info = 8;
c@427 160 }
c@427 161 if (info != 0) {
c@427 162 xerbla_("DTRMV ", &info);
c@427 163 return 0;
c@427 164 }
c@427 165
c@427 166 /* Quick return if possible. */
c@427 167
c@427 168 if (*n == 0) {
c@427 169 return 0;
c@427 170 }
c@427 171
c@427 172 nounit = lsame_(diag, "N");
c@427 173
c@427 174 /* Set up the start point in X if the increment is not unity. This */
c@427 175 /* will be ( N - 1 )*INCX too small for descending loops. */
c@427 176
c@427 177 if (*incx <= 0) {
c@427 178 kx = 1 - (*n - 1) * *incx;
c@427 179 } else if (*incx != 1) {
c@427 180 kx = 1;
c@427 181 }
c@427 182
c@427 183 /* Start the operations. In this version the elements of A are */
c@427 184 /* accessed sequentially with one pass through A. */
c@427 185
c@427 186 if (lsame_(trans, "N")) {
c@427 187
c@427 188 /* Form x := A*x. */
c@427 189
c@427 190 if (lsame_(uplo, "U")) {
c@427 191 if (*incx == 1) {
c@427 192 i__1 = *n;
c@427 193 for (j = 1; j <= i__1; ++j) {
c@427 194 if (x[j] != 0.) {
c@427 195 temp = x[j];
c@427 196 i__2 = j - 1;
c@427 197 for (i__ = 1; i__ <= i__2; ++i__) {
c@427 198 x[i__] += temp * a[i__ + j * a_dim1];
c@427 199 /* L10: */
c@427 200 }
c@427 201 if (nounit) {
c@427 202 x[j] *= a[j + j * a_dim1];
c@427 203 }
c@427 204 }
c@427 205 /* L20: */
c@427 206 }
c@427 207 } else {
c@427 208 jx = kx;
c@427 209 i__1 = *n;
c@427 210 for (j = 1; j <= i__1; ++j) {
c@427 211 if (x[jx] != 0.) {
c@427 212 temp = x[jx];
c@427 213 ix = kx;
c@427 214 i__2 = j - 1;
c@427 215 for (i__ = 1; i__ <= i__2; ++i__) {
c@427 216 x[ix] += temp * a[i__ + j * a_dim1];
c@427 217 ix += *incx;
c@427 218 /* L30: */
c@427 219 }
c@427 220 if (nounit) {
c@427 221 x[jx] *= a[j + j * a_dim1];
c@427 222 }
c@427 223 }
c@427 224 jx += *incx;
c@427 225 /* L40: */
c@427 226 }
c@427 227 }
c@427 228 } else {
c@427 229 if (*incx == 1) {
c@427 230 for (j = *n; j >= 1; --j) {
c@427 231 if (x[j] != 0.) {
c@427 232 temp = x[j];
c@427 233 i__1 = j + 1;
c@427 234 for (i__ = *n; i__ >= i__1; --i__) {
c@427 235 x[i__] += temp * a[i__ + j * a_dim1];
c@427 236 /* L50: */
c@427 237 }
c@427 238 if (nounit) {
c@427 239 x[j] *= a[j + j * a_dim1];
c@427 240 }
c@427 241 }
c@427 242 /* L60: */
c@427 243 }
c@427 244 } else {
c@427 245 kx += (*n - 1) * *incx;
c@427 246 jx = kx;
c@427 247 for (j = *n; j >= 1; --j) {
c@427 248 if (x[jx] != 0.) {
c@427 249 temp = x[jx];
c@427 250 ix = kx;
c@427 251 i__1 = j + 1;
c@427 252 for (i__ = *n; i__ >= i__1; --i__) {
c@427 253 x[ix] += temp * a[i__ + j * a_dim1];
c@427 254 ix -= *incx;
c@427 255 /* L70: */
c@427 256 }
c@427 257 if (nounit) {
c@427 258 x[jx] *= a[j + j * a_dim1];
c@427 259 }
c@427 260 }
c@427 261 jx -= *incx;
c@427 262 /* L80: */
c@427 263 }
c@427 264 }
c@427 265 }
c@427 266 } else {
c@427 267
c@427 268 /* Form x := A'*x. */
c@427 269
c@427 270 if (lsame_(uplo, "U")) {
c@427 271 if (*incx == 1) {
c@427 272 for (j = *n; j >= 1; --j) {
c@427 273 temp = x[j];
c@427 274 if (nounit) {
c@427 275 temp *= a[j + j * a_dim1];
c@427 276 }
c@427 277 for (i__ = j - 1; i__ >= 1; --i__) {
c@427 278 temp += a[i__ + j * a_dim1] * x[i__];
c@427 279 /* L90: */
c@427 280 }
c@427 281 x[j] = temp;
c@427 282 /* L100: */
c@427 283 }
c@427 284 } else {
c@427 285 jx = kx + (*n - 1) * *incx;
c@427 286 for (j = *n; j >= 1; --j) {
c@427 287 temp = x[jx];
c@427 288 ix = jx;
c@427 289 if (nounit) {
c@427 290 temp *= a[j + j * a_dim1];
c@427 291 }
c@427 292 for (i__ = j - 1; i__ >= 1; --i__) {
c@427 293 ix -= *incx;
c@427 294 temp += a[i__ + j * a_dim1] * x[ix];
c@427 295 /* L110: */
c@427 296 }
c@427 297 x[jx] = temp;
c@427 298 jx -= *incx;
c@427 299 /* L120: */
c@427 300 }
c@427 301 }
c@427 302 } else {
c@427 303 if (*incx == 1) {
c@427 304 i__1 = *n;
c@427 305 for (j = 1; j <= i__1; ++j) {
c@427 306 temp = x[j];
c@427 307 if (nounit) {
c@427 308 temp *= a[j + j * a_dim1];
c@427 309 }
c@427 310 i__2 = *n;
c@427 311 for (i__ = j + 1; i__ <= i__2; ++i__) {
c@427 312 temp += a[i__ + j * a_dim1] * x[i__];
c@427 313 /* L130: */
c@427 314 }
c@427 315 x[j] = temp;
c@427 316 /* L140: */
c@427 317 }
c@427 318 } else {
c@427 319 jx = kx;
c@427 320 i__1 = *n;
c@427 321 for (j = 1; j <= i__1; ++j) {
c@427 322 temp = x[jx];
c@427 323 ix = jx;
c@427 324 if (nounit) {
c@427 325 temp *= a[j + j * a_dim1];
c@427 326 }
c@427 327 i__2 = *n;
c@427 328 for (i__ = j + 1; i__ <= i__2; ++i__) {
c@427 329 ix += *incx;
c@427 330 temp += a[i__ + j * a_dim1] * x[ix];
c@427 331 /* L150: */
c@427 332 }
c@427 333 x[jx] = temp;
c@427 334 jx += *incx;
c@427 335 /* L160: */
c@427 336 }
c@427 337 }
c@427 338 }
c@427 339 }
c@427 340
c@427 341 return 0;
c@427 342
c@427 343 /* End of DTRMV . */
c@427 344
c@427 345 } /* dtrmv_ */