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.

366 lines
9.9 KiB

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