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.

368 lines
10 KiB

  1. /* ssbmv.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 ssbmv_(char *uplo, integer *n, integer *k, real *alpha,
  13. real *a, integer *lda, real *x, integer *incx, real *beta, real *y,
  14. 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. real 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. /* SSBMV 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 - REAL . */
  54. /* On entry, ALPHA specifies the scalar alpha. */
  55. /* Unchanged on exit. */
  56. /* A - REAL 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 - REAL 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 - REAL . */
  105. /* On entry, BETA specifies the scalar beta. */
  106. /* Unchanged on exit. */
  107. /* Y - REAL 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. /* Further Details */
  116. /* =============== */
  117. /* Level 2 Blas routine. */
  118. /* -- Written on 22-October-1986. */
  119. /* Jack Dongarra, Argonne National Lab. */
  120. /* Jeremy Du Croz, Nag Central Office. */
  121. /* Sven Hammarling, Nag Central Office. */
  122. /* Richard Hanson, Sandia National Labs. */
  123. /* ===================================================================== */
  124. /* .. Parameters .. */
  125. /* .. */
  126. /* .. Local Scalars .. */
  127. /* .. */
  128. /* .. External Functions .. */
  129. /* .. */
  130. /* .. External Subroutines .. */
  131. /* .. */
  132. /* .. Intrinsic Functions .. */
  133. /* .. */
  134. /* Test the input parameters. */
  135. /* Parameter adjustments */
  136. a_dim1 = *lda;
  137. a_offset = 1 + a_dim1;
  138. a -= a_offset;
  139. --x;
  140. --y;
  141. /* Function Body */
  142. info = 0;
  143. if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
  144. ftnlen)1, (ftnlen)1)) {
  145. info = 1;
  146. } else if (*n < 0) {
  147. info = 2;
  148. } else if (*k < 0) {
  149. info = 3;
  150. } else if (*lda < *k + 1) {
  151. info = 6;
  152. } else if (*incx == 0) {
  153. info = 8;
  154. } else if (*incy == 0) {
  155. info = 11;
  156. }
  157. if (info != 0) {
  158. xerbla_("SSBMV ", &info, (ftnlen)6);
  159. return 0;
  160. }
  161. /* Quick return if possible. */
  162. if (*n == 0 || (*alpha == 0.f && *beta == 1.f)) {
  163. return 0;
  164. }
  165. /* Set up the start points in X and Y. */
  166. if (*incx > 0) {
  167. kx = 1;
  168. } else {
  169. kx = 1 - (*n - 1) * *incx;
  170. }
  171. if (*incy > 0) {
  172. ky = 1;
  173. } else {
  174. ky = 1 - (*n - 1) * *incy;
  175. }
  176. /* Start the operations. In this version the elements of the array A */
  177. /* are accessed sequentially with one pass through A. */
  178. /* First form y := beta*y. */
  179. if (*beta != 1.f) {
  180. if (*incy == 1) {
  181. if (*beta == 0.f) {
  182. i__1 = *n;
  183. for (i__ = 1; i__ <= i__1; ++i__) {
  184. y[i__] = 0.f;
  185. /* L10: */
  186. }
  187. } else {
  188. i__1 = *n;
  189. for (i__ = 1; i__ <= i__1; ++i__) {
  190. y[i__] = *beta * y[i__];
  191. /* L20: */
  192. }
  193. }
  194. } else {
  195. iy = ky;
  196. if (*beta == 0.f) {
  197. i__1 = *n;
  198. for (i__ = 1; i__ <= i__1; ++i__) {
  199. y[iy] = 0.f;
  200. iy += *incy;
  201. /* L30: */
  202. }
  203. } else {
  204. i__1 = *n;
  205. for (i__ = 1; i__ <= i__1; ++i__) {
  206. y[iy] = *beta * y[iy];
  207. iy += *incy;
  208. /* L40: */
  209. }
  210. }
  211. }
  212. }
  213. if (*alpha == 0.f) {
  214. return 0;
  215. }
  216. if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
  217. /* Form y when upper triangle of A is stored. */
  218. kplus1 = *k + 1;
  219. if (*incx == 1 && *incy == 1) {
  220. i__1 = *n;
  221. for (j = 1; j <= i__1; ++j) {
  222. temp1 = *alpha * x[j];
  223. temp2 = 0.f;
  224. l = kplus1 - j;
  225. /* Computing MAX */
  226. i__2 = 1, i__3 = j - *k;
  227. i__4 = j - 1;
  228. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  229. y[i__] += temp1 * a[l + i__ + j * a_dim1];
  230. temp2 += a[l + i__ + j * a_dim1] * x[i__];
  231. /* L50: */
  232. }
  233. y[j] = y[j] + temp1 * a[kplus1 + j * a_dim1] + *alpha * temp2;
  234. /* L60: */
  235. }
  236. } else {
  237. jx = kx;
  238. jy = ky;
  239. i__1 = *n;
  240. for (j = 1; j <= i__1; ++j) {
  241. temp1 = *alpha * x[jx];
  242. temp2 = 0.f;
  243. ix = kx;
  244. iy = ky;
  245. l = kplus1 - j;
  246. /* Computing MAX */
  247. i__4 = 1, i__2 = j - *k;
  248. i__3 = j - 1;
  249. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  250. y[iy] += temp1 * a[l + i__ + j * a_dim1];
  251. temp2 += a[l + i__ + j * a_dim1] * x[ix];
  252. ix += *incx;
  253. iy += *incy;
  254. /* L70: */
  255. }
  256. y[jy] = y[jy] + temp1 * a[kplus1 + j * a_dim1] + *alpha *
  257. temp2;
  258. jx += *incx;
  259. jy += *incy;
  260. if (j > *k) {
  261. kx += *incx;
  262. ky += *incy;
  263. }
  264. /* L80: */
  265. }
  266. }
  267. } else {
  268. /* Form y when lower triangle of A is stored. */
  269. if (*incx == 1 && *incy == 1) {
  270. i__1 = *n;
  271. for (j = 1; j <= i__1; ++j) {
  272. temp1 = *alpha * x[j];
  273. temp2 = 0.f;
  274. y[j] += temp1 * a[j * a_dim1 + 1];
  275. l = 1 - j;
  276. /* Computing MIN */
  277. i__4 = *n, i__2 = j + *k;
  278. i__3 = min(i__4,i__2);
  279. for (i__ = j + 1; i__ <= i__3; ++i__) {
  280. y[i__] += temp1 * a[l + i__ + j * a_dim1];
  281. temp2 += a[l + i__ + j * a_dim1] * x[i__];
  282. /* L90: */
  283. }
  284. y[j] += *alpha * temp2;
  285. /* L100: */
  286. }
  287. } else {
  288. jx = kx;
  289. jy = ky;
  290. i__1 = *n;
  291. for (j = 1; j <= i__1; ++j) {
  292. temp1 = *alpha * x[jx];
  293. temp2 = 0.f;
  294. y[jy] += temp1 * a[j * a_dim1 + 1];
  295. l = 1 - j;
  296. ix = jx;
  297. iy = jy;
  298. /* Computing MIN */
  299. i__4 = *n, i__2 = j + *k;
  300. i__3 = min(i__4,i__2);
  301. for (i__ = j + 1; i__ <= i__3; ++i__) {
  302. ix += *incx;
  303. iy += *incy;
  304. y[iy] += temp1 * a[l + i__ + j * a_dim1];
  305. temp2 += a[l + i__ + j * a_dim1] * x[ix];
  306. /* L110: */
  307. }
  308. y[jy] += *alpha * temp2;
  309. jx += *incx;
  310. jy += *incy;
  311. /* L120: */
  312. }
  313. }
  314. }
  315. return 0;
  316. /* End of SSBMV . */
  317. } /* ssbmv_ */