You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

428 lines
11 KiB

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