stbmv.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. /* stbmv.f -- translated by f2c (version 20061008).
  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 "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int stbmv_(char *uplo, char *trans, char *diag, integer *n,
  14. integer *k, real *a, integer *lda, real *x, integer *incx)
  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 *);
  22. integer kplus1;
  23. extern /* Subroutine */ int xerbla_(char *, integer *);
  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. /* Level 2 Blas routine. */
  120. /* -- Written on 22-October-1986. */
  121. /* Jack Dongarra, Argonne National Lab. */
  122. /* Jeremy Du Croz, Nag Central Office. */
  123. /* Sven Hammarling, Nag Central Office. */
  124. /* Richard Hanson, Sandia National Labs. */
  125. /* .. Parameters .. */
  126. /* .. */
  127. /* .. Local Scalars .. */
  128. /* .. */
  129. /* .. External Functions .. */
  130. /* .. */
  131. /* .. External Subroutines .. */
  132. /* .. */
  133. /* .. Intrinsic Functions .. */
  134. /* .. */
  135. /* Test the input parameters. */
  136. /* Parameter adjustments */
  137. a_dim1 = *lda;
  138. a_offset = 1 + a_dim1;
  139. a -= a_offset;
  140. --x;
  141. /* Function Body */
  142. info = 0;
  143. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  144. info = 1;
  145. } else if (! lsame_(trans, "N") && ! lsame_(trans,
  146. "T") && ! lsame_(trans, "C")) {
  147. info = 2;
  148. } else if (! lsame_(diag, "U") && ! lsame_(diag,
  149. "N")) {
  150. info = 3;
  151. } else if (*n < 0) {
  152. info = 4;
  153. } else if (*k < 0) {
  154. info = 5;
  155. } else if (*lda < *k + 1) {
  156. info = 7;
  157. } else if (*incx == 0) {
  158. info = 9;
  159. }
  160. if (info != 0) {
  161. xerbla_("STBMV ", &info);
  162. return 0;
  163. }
  164. /* Quick return if possible. */
  165. if (*n == 0) {
  166. return 0;
  167. }
  168. nounit = lsame_(diag, "N");
  169. /* Set up the start point in X if the increment is not unity. This */
  170. /* will be ( N - 1 )*INCX too small for descending loops. */
  171. if (*incx <= 0) {
  172. kx = 1 - (*n - 1) * *incx;
  173. } else if (*incx != 1) {
  174. kx = 1;
  175. }
  176. /* Start the operations. In this version the elements of A are */
  177. /* accessed sequentially with one pass through A. */
  178. if (lsame_(trans, "N")) {
  179. /* Form x := A*x. */
  180. if (lsame_(uplo, "U")) {
  181. kplus1 = *k + 1;
  182. if (*incx == 1) {
  183. i__1 = *n;
  184. for (j = 1; j <= i__1; ++j) {
  185. if (x[j] != 0.f) {
  186. temp = x[j];
  187. l = kplus1 - j;
  188. /* Computing MAX */
  189. i__2 = 1, i__3 = j - *k;
  190. i__4 = j - 1;
  191. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  192. x[i__] += temp * a[l + i__ + j * a_dim1];
  193. /* L10: */
  194. }
  195. if (nounit) {
  196. x[j] *= a[kplus1 + j * a_dim1];
  197. }
  198. }
  199. /* L20: */
  200. }
  201. } else {
  202. jx = kx;
  203. i__1 = *n;
  204. for (j = 1; j <= i__1; ++j) {
  205. if (x[jx] != 0.f) {
  206. temp = x[jx];
  207. ix = kx;
  208. l = kplus1 - j;
  209. /* Computing MAX */
  210. i__4 = 1, i__2 = j - *k;
  211. i__3 = j - 1;
  212. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  213. x[ix] += temp * a[l + i__ + j * a_dim1];
  214. ix += *incx;
  215. /* L30: */
  216. }
  217. if (nounit) {
  218. x[jx] *= a[kplus1 + j * a_dim1];
  219. }
  220. }
  221. jx += *incx;
  222. if (j > *k) {
  223. kx += *incx;
  224. }
  225. /* L40: */
  226. }
  227. }
  228. } else {
  229. if (*incx == 1) {
  230. for (j = *n; j >= 1; --j) {
  231. if (x[j] != 0.f) {
  232. temp = x[j];
  233. l = 1 - j;
  234. /* Computing MIN */
  235. i__1 = *n, i__3 = j + *k;
  236. i__4 = j + 1;
  237. for (i__ = min(i__1,i__3); i__ >= i__4; --i__) {
  238. x[i__] += temp * a[l + i__ + j * a_dim1];
  239. /* L50: */
  240. }
  241. if (nounit) {
  242. x[j] *= a[j * a_dim1 + 1];
  243. }
  244. }
  245. /* L60: */
  246. }
  247. } else {
  248. kx += (*n - 1) * *incx;
  249. jx = kx;
  250. for (j = *n; j >= 1; --j) {
  251. if (x[jx] != 0.f) {
  252. temp = x[jx];
  253. ix = kx;
  254. l = 1 - j;
  255. /* Computing MIN */
  256. i__4 = *n, i__1 = j + *k;
  257. i__3 = j + 1;
  258. for (i__ = min(i__4,i__1); i__ >= i__3; --i__) {
  259. x[ix] += temp * a[l + i__ + j * a_dim1];
  260. ix -= *incx;
  261. /* L70: */
  262. }
  263. if (nounit) {
  264. x[jx] *= a[j * a_dim1 + 1];
  265. }
  266. }
  267. jx -= *incx;
  268. if (*n - j >= *k) {
  269. kx -= *incx;
  270. }
  271. /* L80: */
  272. }
  273. }
  274. }
  275. } else {
  276. /* Form x := A'*x. */
  277. if (lsame_(uplo, "U")) {
  278. kplus1 = *k + 1;
  279. if (*incx == 1) {
  280. for (j = *n; j >= 1; --j) {
  281. temp = x[j];
  282. l = kplus1 - j;
  283. if (nounit) {
  284. temp *= a[kplus1 + j * a_dim1];
  285. }
  286. /* Computing MAX */
  287. i__4 = 1, i__1 = j - *k;
  288. i__3 = max(i__4,i__1);
  289. for (i__ = j - 1; i__ >= i__3; --i__) {
  290. temp += a[l + i__ + j * a_dim1] * x[i__];
  291. /* L90: */
  292. }
  293. x[j] = temp;
  294. /* L100: */
  295. }
  296. } else {
  297. kx += (*n - 1) * *incx;
  298. jx = kx;
  299. for (j = *n; j >= 1; --j) {
  300. temp = x[jx];
  301. kx -= *incx;
  302. ix = kx;
  303. l = kplus1 - j;
  304. if (nounit) {
  305. temp *= a[kplus1 + j * a_dim1];
  306. }
  307. /* Computing MAX */
  308. i__4 = 1, i__1 = j - *k;
  309. i__3 = max(i__4,i__1);
  310. for (i__ = j - 1; i__ >= i__3; --i__) {
  311. temp += a[l + i__ + j * a_dim1] * x[ix];
  312. ix -= *incx;
  313. /* L110: */
  314. }
  315. x[jx] = temp;
  316. jx -= *incx;
  317. /* L120: */
  318. }
  319. }
  320. } else {
  321. if (*incx == 1) {
  322. i__3 = *n;
  323. for (j = 1; j <= i__3; ++j) {
  324. temp = x[j];
  325. l = 1 - j;
  326. if (nounit) {
  327. temp *= a[j * a_dim1 + 1];
  328. }
  329. /* Computing MIN */
  330. i__1 = *n, i__2 = j + *k;
  331. i__4 = min(i__1,i__2);
  332. for (i__ = j + 1; i__ <= i__4; ++i__) {
  333. temp += a[l + i__ + j * a_dim1] * x[i__];
  334. /* L130: */
  335. }
  336. x[j] = temp;
  337. /* L140: */
  338. }
  339. } else {
  340. jx = kx;
  341. i__3 = *n;
  342. for (j = 1; j <= i__3; ++j) {
  343. temp = x[jx];
  344. kx += *incx;
  345. ix = kx;
  346. l = 1 - j;
  347. if (nounit) {
  348. temp *= a[j * a_dim1 + 1];
  349. }
  350. /* Computing MIN */
  351. i__1 = *n, i__2 = j + *k;
  352. i__4 = min(i__1,i__2);
  353. for (i__ = j + 1; i__ <= i__4; ++i__) {
  354. temp += a[l + i__ + j * a_dim1] * x[ix];
  355. ix += *incx;
  356. /* L150: */
  357. }
  358. x[jx] = temp;
  359. jx += *incx;
  360. /* L160: */
  361. }
  362. }
  363. }
  364. }
  365. return 0;
  366. /* End of STBMV . */
  367. } /* stbmv_ */