dgbmv.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /* dgbmv.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 dgbmv_(char *trans, integer *m, integer *n, integer *kl,
  14. integer *ku, doublereal *alpha, doublereal *a, integer *lda,
  15. doublereal *x, integer *incx, doublereal *beta, doublereal *y,
  16. integer *incy)
  17. {
  18. /* System generated locals */
  19. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  20. /* Local variables */
  21. integer i__, j, k, ix, iy, jx, jy, kx, ky, kup1, info;
  22. doublereal temp;
  23. integer lenx, leny;
  24. extern logical lsame_(char *, char *);
  25. extern /* Subroutine */ int xerbla_(char *, integer *);
  26. /* .. Scalar Arguments .. */
  27. /* .. */
  28. /* .. Array Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* DGBMV performs one of the matrix-vector operations */
  33. /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */
  34. /* where alpha and beta are scalars, x and y are vectors and A is an */
  35. /* m by n band matrix, with kl sub-diagonals and ku super-diagonals. */
  36. /* Arguments */
  37. /* ========== */
  38. /* TRANS - CHARACTER*1. */
  39. /* On entry, TRANS specifies the operation to be performed as */
  40. /* follows: */
  41. /* TRANS = 'N' or 'n' y := alpha*A*x + beta*y. */
  42. /* TRANS = 'T' or 't' y := alpha*A'*x + beta*y. */
  43. /* TRANS = 'C' or 'c' y := alpha*A'*x + beta*y. */
  44. /* Unchanged on exit. */
  45. /* M - INTEGER. */
  46. /* On entry, M specifies the number of rows of the matrix A. */
  47. /* M must be at least zero. */
  48. /* Unchanged on exit. */
  49. /* N - INTEGER. */
  50. /* On entry, N specifies the number of columns of the matrix A. */
  51. /* N must be at least zero. */
  52. /* Unchanged on exit. */
  53. /* KL - INTEGER. */
  54. /* On entry, KL specifies the number of sub-diagonals of the */
  55. /* matrix A. KL must satisfy 0 .le. KL. */
  56. /* Unchanged on exit. */
  57. /* KU - INTEGER. */
  58. /* On entry, KU specifies the number of super-diagonals of the */
  59. /* matrix A. KU must satisfy 0 .le. KU. */
  60. /* Unchanged on exit. */
  61. /* ALPHA - DOUBLE PRECISION. */
  62. /* On entry, ALPHA specifies the scalar alpha. */
  63. /* Unchanged on exit. */
  64. /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
  65. /* Before entry, the leading ( kl + ku + 1 ) by n part of the */
  66. /* array A must contain the matrix of coefficients, supplied */
  67. /* column by column, with the leading diagonal of the matrix in */
  68. /* row ( ku + 1 ) of the array, the first super-diagonal */
  69. /* starting at position 2 in row ku, the first sub-diagonal */
  70. /* starting at position 1 in row ( ku + 2 ), and so on. */
  71. /* Elements in the array A that do not correspond to elements */
  72. /* in the band matrix (such as the top left ku by ku triangle) */
  73. /* are not referenced. */
  74. /* The following program segment will transfer a band matrix */
  75. /* from conventional full matrix storage to band storage: */
  76. /* DO 20, J = 1, N */
  77. /* K = KU + 1 - J */
  78. /* DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL ) */
  79. /* A( K + I, J ) = matrix( I, J ) */
  80. /* 10 CONTINUE */
  81. /* 20 CONTINUE */
  82. /* Unchanged on exit. */
  83. /* LDA - INTEGER. */
  84. /* On entry, LDA specifies the first dimension of A as declared */
  85. /* in the calling (sub) program. LDA must be at least */
  86. /* ( kl + ku + 1 ). */
  87. /* Unchanged on exit. */
  88. /* X - DOUBLE PRECISION array of DIMENSION at least */
  89. /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
  90. /* and at least */
  91. /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
  92. /* Before entry, the incremented array X must contain the */
  93. /* vector x. */
  94. /* Unchanged on exit. */
  95. /* INCX - INTEGER. */
  96. /* On entry, INCX specifies the increment for the elements of */
  97. /* X. INCX must not be zero. */
  98. /* Unchanged on exit. */
  99. /* BETA - DOUBLE PRECISION. */
  100. /* On entry, BETA specifies the scalar beta. When BETA is */
  101. /* supplied as zero then Y need not be set on input. */
  102. /* Unchanged on exit. */
  103. /* Y - DOUBLE PRECISION array of DIMENSION at least */
  104. /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
  105. /* and at least */
  106. /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
  107. /* Before entry, the incremented array Y must contain the */
  108. /* vector y. On exit, Y is overwritten by the updated vector y. */
  109. /* INCY - INTEGER. */
  110. /* On entry, INCY specifies the increment for the elements of */
  111. /* Y. INCY must not be zero. */
  112. /* Unchanged on exit. */
  113. /* Level 2 Blas routine. */
  114. /* -- Written on 22-October-1986. */
  115. /* Jack Dongarra, Argonne National Lab. */
  116. /* Jeremy Du Croz, Nag Central Office. */
  117. /* Sven Hammarling, Nag Central Office. */
  118. /* Richard Hanson, Sandia National Labs. */
  119. /* .. Parameters .. */
  120. /* .. */
  121. /* .. Local Scalars .. */
  122. /* .. */
  123. /* .. External Functions .. */
  124. /* .. */
  125. /* .. External Subroutines .. */
  126. /* .. */
  127. /* .. Intrinsic Functions .. */
  128. /* .. */
  129. /* Test the input parameters. */
  130. /* Parameter adjustments */
  131. a_dim1 = *lda;
  132. a_offset = 1 + a_dim1;
  133. a -= a_offset;
  134. --x;
  135. --y;
  136. /* Function Body */
  137. info = 0;
  138. if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
  139. ) {
  140. info = 1;
  141. } else if (*m < 0) {
  142. info = 2;
  143. } else if (*n < 0) {
  144. info = 3;
  145. } else if (*kl < 0) {
  146. info = 4;
  147. } else if (*ku < 0) {
  148. info = 5;
  149. } else if (*lda < *kl + *ku + 1) {
  150. info = 8;
  151. } else if (*incx == 0) {
  152. info = 10;
  153. } else if (*incy == 0) {
  154. info = 13;
  155. }
  156. if (info != 0) {
  157. xerbla_("DGBMV ", &info);
  158. return 0;
  159. }
  160. /* Quick return if possible. */
  161. if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
  162. return 0;
  163. }
  164. /* Set LENX and LENY, the lengths of the vectors x and y, and set */
  165. /* up the start points in X and Y. */
  166. if (lsame_(trans, "N")) {
  167. lenx = *n;
  168. leny = *m;
  169. } else {
  170. lenx = *m;
  171. leny = *n;
  172. }
  173. if (*incx > 0) {
  174. kx = 1;
  175. } else {
  176. kx = 1 - (lenx - 1) * *incx;
  177. }
  178. if (*incy > 0) {
  179. ky = 1;
  180. } else {
  181. ky = 1 - (leny - 1) * *incy;
  182. }
  183. /* Start the operations. In this version the elements of A are */
  184. /* accessed sequentially with one pass through the band part of A. */
  185. /* First form y := beta*y. */
  186. if (*beta != 1.) {
  187. if (*incy == 1) {
  188. if (*beta == 0.) {
  189. i__1 = leny;
  190. for (i__ = 1; i__ <= i__1; ++i__) {
  191. y[i__] = 0.;
  192. /* L10: */
  193. }
  194. } else {
  195. i__1 = leny;
  196. for (i__ = 1; i__ <= i__1; ++i__) {
  197. y[i__] = *beta * y[i__];
  198. /* L20: */
  199. }
  200. }
  201. } else {
  202. iy = ky;
  203. if (*beta == 0.) {
  204. i__1 = leny;
  205. for (i__ = 1; i__ <= i__1; ++i__) {
  206. y[iy] = 0.;
  207. iy += *incy;
  208. /* L30: */
  209. }
  210. } else {
  211. i__1 = leny;
  212. for (i__ = 1; i__ <= i__1; ++i__) {
  213. y[iy] = *beta * y[iy];
  214. iy += *incy;
  215. /* L40: */
  216. }
  217. }
  218. }
  219. }
  220. if (*alpha == 0.) {
  221. return 0;
  222. }
  223. kup1 = *ku + 1;
  224. if (lsame_(trans, "N")) {
  225. /* Form y := alpha*A*x + y. */
  226. jx = kx;
  227. if (*incy == 1) {
  228. i__1 = *n;
  229. for (j = 1; j <= i__1; ++j) {
  230. if (x[jx] != 0.) {
  231. temp = *alpha * x[jx];
  232. k = kup1 - j;
  233. /* Computing MAX */
  234. i__2 = 1, i__3 = j - *ku;
  235. /* Computing MIN */
  236. i__5 = *m, i__6 = j + *kl;
  237. i__4 = min(i__5,i__6);
  238. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  239. y[i__] += temp * a[k + i__ + j * a_dim1];
  240. /* L50: */
  241. }
  242. }
  243. jx += *incx;
  244. /* L60: */
  245. }
  246. } else {
  247. i__1 = *n;
  248. for (j = 1; j <= i__1; ++j) {
  249. if (x[jx] != 0.) {
  250. temp = *alpha * x[jx];
  251. iy = ky;
  252. k = kup1 - j;
  253. /* Computing MAX */
  254. i__4 = 1, i__2 = j - *ku;
  255. /* Computing MIN */
  256. i__5 = *m, i__6 = j + *kl;
  257. i__3 = min(i__5,i__6);
  258. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  259. y[iy] += temp * a[k + i__ + j * a_dim1];
  260. iy += *incy;
  261. /* L70: */
  262. }
  263. }
  264. jx += *incx;
  265. if (j > *ku) {
  266. ky += *incy;
  267. }
  268. /* L80: */
  269. }
  270. }
  271. } else {
  272. /* Form y := alpha*A'*x + y. */
  273. jy = ky;
  274. if (*incx == 1) {
  275. i__1 = *n;
  276. for (j = 1; j <= i__1; ++j) {
  277. temp = 0.;
  278. k = kup1 - j;
  279. /* Computing MAX */
  280. i__3 = 1, i__4 = j - *ku;
  281. /* Computing MIN */
  282. i__5 = *m, i__6 = j + *kl;
  283. i__2 = min(i__5,i__6);
  284. for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
  285. temp += a[k + i__ + j * a_dim1] * x[i__];
  286. /* L90: */
  287. }
  288. y[jy] += *alpha * temp;
  289. jy += *incy;
  290. /* L100: */
  291. }
  292. } else {
  293. i__1 = *n;
  294. for (j = 1; j <= i__1; ++j) {
  295. temp = 0.;
  296. ix = kx;
  297. k = kup1 - j;
  298. /* Computing MAX */
  299. i__2 = 1, i__3 = j - *ku;
  300. /* Computing MIN */
  301. i__5 = *m, i__6 = j + *kl;
  302. i__4 = min(i__5,i__6);
  303. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  304. temp += a[k + i__ + j * a_dim1] * x[ix];
  305. ix += *incx;
  306. /* L110: */
  307. }
  308. y[jy] += *alpha * temp;
  309. jy += *incy;
  310. if (j > *ku) {
  311. kx += *incx;
  312. }
  313. /* L120: */
  314. }
  315. }
  316. }
  317. return 0;
  318. /* End of DGBMV . */
  319. } /* dgbmv_ */