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.

316 lines
7.9 KiB

  1. /* dspmv.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 dspmv_(char *uplo, integer *n, doublereal *alpha,
  13. doublereal *ap, doublereal *x, integer *incx, doublereal *beta,
  14. doublereal *y, integer *incy, ftnlen uplo_len)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
  20. doublereal temp1, temp2;
  21. extern logical lsame_(char *, char *, ftnlen, ftnlen);
  22. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  23. /* .. Scalar Arguments .. */
  24. /* .. */
  25. /* .. Array Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* DSPMV performs the matrix-vector operation */
  30. /* y := alpha*A*x + beta*y, */
  31. /* where alpha and beta are scalars, x and y are n element vectors and */
  32. /* A is an n by n symmetric matrix, supplied in packed form. */
  33. /* Arguments */
  34. /* ========== */
  35. /* UPLO - CHARACTER*1. */
  36. /* On entry, UPLO specifies whether the upper or lower */
  37. /* triangular part of the matrix A is supplied in the packed */
  38. /* array AP as follows: */
  39. /* UPLO = 'U' or 'u' The upper triangular part of A is */
  40. /* supplied in AP. */
  41. /* UPLO = 'L' or 'l' The lower triangular part of A is */
  42. /* supplied in AP. */
  43. /* Unchanged on exit. */
  44. /* N - INTEGER. */
  45. /* On entry, N specifies the order of the matrix A. */
  46. /* N must be at least zero. */
  47. /* Unchanged on exit. */
  48. /* ALPHA - DOUBLE PRECISION. */
  49. /* On entry, ALPHA specifies the scalar alpha. */
  50. /* Unchanged on exit. */
  51. /* AP - DOUBLE PRECISION array of DIMENSION at least */
  52. /* ( ( n*( n + 1 ) )/2 ). */
  53. /* Before entry with UPLO = 'U' or 'u', the array AP must */
  54. /* contain the upper triangular part of the symmetric matrix */
  55. /* packed sequentially, column by column, so that AP( 1 ) */
  56. /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
  57. /* and a( 2, 2 ) respectively, and so on. */
  58. /* Before entry with UPLO = 'L' or 'l', the array AP must */
  59. /* contain the lower triangular part of the symmetric matrix */
  60. /* packed sequentially, column by column, so that AP( 1 ) */
  61. /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
  62. /* and a( 3, 1 ) respectively, and so on. */
  63. /* Unchanged on exit. */
  64. /* X - DOUBLE PRECISION array of dimension at least */
  65. /* ( 1 + ( n - 1 )*abs( INCX ) ). */
  66. /* Before entry, the incremented array X must contain the n */
  67. /* element vector x. */
  68. /* Unchanged on exit. */
  69. /* INCX - INTEGER. */
  70. /* On entry, INCX specifies the increment for the elements of */
  71. /* X. INCX must not be zero. */
  72. /* Unchanged on exit. */
  73. /* BETA - DOUBLE PRECISION. */
  74. /* On entry, BETA specifies the scalar beta. When BETA is */
  75. /* supplied as zero then Y need not be set on input. */
  76. /* Unchanged on exit. */
  77. /* Y - DOUBLE PRECISION array of dimension at least */
  78. /* ( 1 + ( n - 1 )*abs( INCY ) ). */
  79. /* Before entry, the incremented array Y must contain the n */
  80. /* element vector y. On exit, Y is overwritten by the updated */
  81. /* vector y. */
  82. /* INCY - INTEGER. */
  83. /* On entry, INCY specifies the increment for the elements of */
  84. /* Y. INCY must not be zero. */
  85. /* Unchanged on exit. */
  86. /* Further Details */
  87. /* =============== */
  88. /* Level 2 Blas routine. */
  89. /* -- Written on 22-October-1986. */
  90. /* Jack Dongarra, Argonne National Lab. */
  91. /* Jeremy Du Croz, Nag Central Office. */
  92. /* Sven Hammarling, Nag Central Office. */
  93. /* Richard Hanson, Sandia National Labs. */
  94. /* ===================================================================== */
  95. /* .. Parameters .. */
  96. /* .. */
  97. /* .. Local Scalars .. */
  98. /* .. */
  99. /* .. External Functions .. */
  100. /* .. */
  101. /* .. External Subroutines .. */
  102. /* .. */
  103. /* Test the input parameters. */
  104. /* Parameter adjustments */
  105. --y;
  106. --x;
  107. --ap;
  108. /* Function Body */
  109. info = 0;
  110. if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
  111. ftnlen)1, (ftnlen)1)) {
  112. info = 1;
  113. } else if (*n < 0) {
  114. info = 2;
  115. } else if (*incx == 0) {
  116. info = 6;
  117. } else if (*incy == 0) {
  118. info = 9;
  119. }
  120. if (info != 0) {
  121. xerbla_("DSPMV ", &info, (ftnlen)6);
  122. return 0;
  123. }
  124. /* Quick return if possible. */
  125. if (*n == 0 || (*alpha == 0. && *beta == 1.)) {
  126. return 0;
  127. }
  128. /* Set up the start points in X and Y. */
  129. if (*incx > 0) {
  130. kx = 1;
  131. } else {
  132. kx = 1 - (*n - 1) * *incx;
  133. }
  134. if (*incy > 0) {
  135. ky = 1;
  136. } else {
  137. ky = 1 - (*n - 1) * *incy;
  138. }
  139. /* Start the operations. In this version the elements of the array AP */
  140. /* are accessed sequentially with one pass through AP. */
  141. /* First form y := beta*y. */
  142. if (*beta != 1.) {
  143. if (*incy == 1) {
  144. if (*beta == 0.) {
  145. i__1 = *n;
  146. for (i__ = 1; i__ <= i__1; ++i__) {
  147. y[i__] = 0.;
  148. /* L10: */
  149. }
  150. } else {
  151. i__1 = *n;
  152. for (i__ = 1; i__ <= i__1; ++i__) {
  153. y[i__] = *beta * y[i__];
  154. /* L20: */
  155. }
  156. }
  157. } else {
  158. iy = ky;
  159. if (*beta == 0.) {
  160. i__1 = *n;
  161. for (i__ = 1; i__ <= i__1; ++i__) {
  162. y[iy] = 0.;
  163. iy += *incy;
  164. /* L30: */
  165. }
  166. } else {
  167. i__1 = *n;
  168. for (i__ = 1; i__ <= i__1; ++i__) {
  169. y[iy] = *beta * y[iy];
  170. iy += *incy;
  171. /* L40: */
  172. }
  173. }
  174. }
  175. }
  176. if (*alpha == 0.) {
  177. return 0;
  178. }
  179. kk = 1;
  180. if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
  181. /* Form y when AP contains the upper triangle. */
  182. if (*incx == 1 && *incy == 1) {
  183. i__1 = *n;
  184. for (j = 1; j <= i__1; ++j) {
  185. temp1 = *alpha * x[j];
  186. temp2 = 0.;
  187. k = kk;
  188. i__2 = j - 1;
  189. for (i__ = 1; i__ <= i__2; ++i__) {
  190. y[i__] += temp1 * ap[k];
  191. temp2 += ap[k] * x[i__];
  192. ++k;
  193. /* L50: */
  194. }
  195. y[j] = y[j] + temp1 * ap[kk + j - 1] + *alpha * temp2;
  196. kk += j;
  197. /* L60: */
  198. }
  199. } else {
  200. jx = kx;
  201. jy = ky;
  202. i__1 = *n;
  203. for (j = 1; j <= i__1; ++j) {
  204. temp1 = *alpha * x[jx];
  205. temp2 = 0.;
  206. ix = kx;
  207. iy = ky;
  208. i__2 = kk + j - 2;
  209. for (k = kk; k <= i__2; ++k) {
  210. y[iy] += temp1 * ap[k];
  211. temp2 += ap[k] * x[ix];
  212. ix += *incx;
  213. iy += *incy;
  214. /* L70: */
  215. }
  216. y[jy] = y[jy] + temp1 * ap[kk + j - 1] + *alpha * temp2;
  217. jx += *incx;
  218. jy += *incy;
  219. kk += j;
  220. /* L80: */
  221. }
  222. }
  223. } else {
  224. /* Form y when AP contains the lower triangle. */
  225. if (*incx == 1 && *incy == 1) {
  226. i__1 = *n;
  227. for (j = 1; j <= i__1; ++j) {
  228. temp1 = *alpha * x[j];
  229. temp2 = 0.;
  230. y[j] += temp1 * ap[kk];
  231. k = kk + 1;
  232. i__2 = *n;
  233. for (i__ = j + 1; i__ <= i__2; ++i__) {
  234. y[i__] += temp1 * ap[k];
  235. temp2 += ap[k] * x[i__];
  236. ++k;
  237. /* L90: */
  238. }
  239. y[j] += *alpha * temp2;
  240. kk += *n - j + 1;
  241. /* L100: */
  242. }
  243. } else {
  244. jx = kx;
  245. jy = ky;
  246. i__1 = *n;
  247. for (j = 1; j <= i__1; ++j) {
  248. temp1 = *alpha * x[jx];
  249. temp2 = 0.;
  250. y[jy] += temp1 * ap[kk];
  251. ix = jx;
  252. iy = jy;
  253. i__2 = kk + *n - j;
  254. for (k = kk + 1; k <= i__2; ++k) {
  255. ix += *incx;
  256. iy += *incy;
  257. y[iy] += temp1 * ap[k];
  258. temp2 += ap[k] * x[ix];
  259. /* L110: */
  260. }
  261. y[jy] += *alpha * temp2;
  262. jx += *incx;
  263. jy += *incy;
  264. kk += *n - j + 1;
  265. /* L120: */
  266. }
  267. }
  268. }
  269. return 0;
  270. /* End of DSPMV . */
  271. } /* dspmv_ */