dsbmv.c 9.8 KB

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