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.

488 lines
15 KiB

  1. /* zhbmv.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 zhbmv_(char *uplo, integer *n, integer *k, doublecomplex
  13. *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *
  14. incx, doublecomplex *beta, doublecomplex *y, integer *incy, ftnlen
  15. uplo_len)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
  19. doublereal d__1;
  20. doublecomplex z__1, z__2, z__3, z__4;
  21. /* Builtin functions */
  22. void d_cnjg(doublecomplex *, doublecomplex *);
  23. /* Local variables */
  24. integer i__, j, l, ix, iy, jx, jy, kx, ky, info;
  25. doublecomplex temp1, temp2;
  26. extern logical lsame_(char *, char *, ftnlen, ftnlen);
  27. integer kplus1;
  28. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  29. /* .. Scalar Arguments .. */
  30. /* .. */
  31. /* .. Array Arguments .. */
  32. /* .. */
  33. /* Purpose */
  34. /* ======= */
  35. /* ZHBMV performs the matrix-vector operation */
  36. /* y := alpha*A*x + beta*y, */
  37. /* where alpha and beta are scalars, x and y are n element vectors and */
  38. /* A is an n by n hermitian band matrix, with k super-diagonals. */
  39. /* Arguments */
  40. /* ========== */
  41. /* UPLO - CHARACTER*1. */
  42. /* On entry, UPLO specifies whether the upper or lower */
  43. /* triangular part of the band matrix A is being supplied as */
  44. /* follows: */
  45. /* UPLO = 'U' or 'u' The upper triangular part of A is */
  46. /* being supplied. */
  47. /* UPLO = 'L' or 'l' The lower triangular part of A is */
  48. /* being supplied. */
  49. /* Unchanged on exit. */
  50. /* N - INTEGER. */
  51. /* On entry, N specifies the order of the matrix A. */
  52. /* N must be at least zero. */
  53. /* Unchanged on exit. */
  54. /* K - INTEGER. */
  55. /* On entry, K specifies the number of super-diagonals of the */
  56. /* matrix A. K must satisfy 0 .le. K. */
  57. /* Unchanged on exit. */
  58. /* ALPHA - COMPLEX*16 . */
  59. /* On entry, ALPHA specifies the scalar alpha. */
  60. /* Unchanged on exit. */
  61. /* A - COMPLEX*16 array of DIMENSION ( LDA, n ). */
  62. /* Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) */
  63. /* by n part of the array A must contain the upper triangular */
  64. /* band part of the hermitian matrix, supplied column by */
  65. /* column, with the leading diagonal of the matrix in row */
  66. /* ( k + 1 ) of the array, the first super-diagonal starting at */
  67. /* position 2 in row k, and so on. The top left k by k triangle */
  68. /* of the array A is not referenced. */
  69. /* The following program segment will transfer the upper */
  70. /* triangular part of a hermitian band matrix from conventional */
  71. /* full matrix storage to band storage: */
  72. /* DO 20, J = 1, N */
  73. /* M = K + 1 - J */
  74. /* DO 10, I = MAX( 1, J - K ), J */
  75. /* A( M + I, J ) = matrix( I, J ) */
  76. /* 10 CONTINUE */
  77. /* 20 CONTINUE */
  78. /* Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) */
  79. /* by n part of the array A must contain the lower triangular */
  80. /* band part of the hermitian matrix, supplied column by */
  81. /* column, with the leading diagonal of the matrix in row 1 of */
  82. /* the array, the first sub-diagonal starting at position 1 in */
  83. /* row 2, and so on. The bottom right k by k triangle of the */
  84. /* array A is not referenced. */
  85. /* The following program segment will transfer the lower */
  86. /* triangular part of a hermitian band matrix from conventional */
  87. /* full matrix storage to band storage: */
  88. /* DO 20, J = 1, N */
  89. /* M = 1 - J */
  90. /* DO 10, I = J, MIN( N, J + K ) */
  91. /* A( M + I, J ) = matrix( I, J ) */
  92. /* 10 CONTINUE */
  93. /* 20 CONTINUE */
  94. /* Note that the imaginary parts of the diagonal elements need */
  95. /* not be set and are assumed to be zero. */
  96. /* Unchanged on exit. */
  97. /* LDA - INTEGER. */
  98. /* On entry, LDA specifies the first dimension of A as declared */
  99. /* in the calling (sub) program. LDA must be at least */
  100. /* ( k + 1 ). */
  101. /* Unchanged on exit. */
  102. /* X - COMPLEX*16 array of DIMENSION at least */
  103. /* ( 1 + ( n - 1 )*abs( INCX ) ). */
  104. /* Before entry, the incremented array X must contain the */
  105. /* vector x. */
  106. /* Unchanged on exit. */
  107. /* INCX - INTEGER. */
  108. /* On entry, INCX specifies the increment for the elements of */
  109. /* X. INCX must not be zero. */
  110. /* Unchanged on exit. */
  111. /* BETA - COMPLEX*16 . */
  112. /* On entry, BETA specifies the scalar beta. */
  113. /* Unchanged on exit. */
  114. /* Y - COMPLEX*16 array of DIMENSION at least */
  115. /* ( 1 + ( n - 1 )*abs( INCY ) ). */
  116. /* Before entry, the incremented array Y must contain the */
  117. /* vector y. On exit, Y is overwritten by the updated vector y. */
  118. /* INCY - INTEGER. */
  119. /* On entry, INCY specifies the increment for the elements of */
  120. /* Y. INCY must not be zero. */
  121. /* Unchanged on exit. */
  122. /* Further Details */
  123. /* =============== */
  124. /* Level 2 Blas routine. */
  125. /* -- Written on 22-October-1986. */
  126. /* Jack Dongarra, Argonne National Lab. */
  127. /* Jeremy Du Croz, Nag Central Office. */
  128. /* Sven Hammarling, Nag Central Office. */
  129. /* Richard Hanson, Sandia National Labs. */
  130. /* ===================================================================== */
  131. /* .. Parameters .. */
  132. /* .. */
  133. /* .. Local Scalars .. */
  134. /* .. */
  135. /* .. External Functions .. */
  136. /* .. */
  137. /* .. External Subroutines .. */
  138. /* .. */
  139. /* .. Intrinsic Functions .. */
  140. /* .. */
  141. /* Test the input parameters. */
  142. /* Parameter adjustments */
  143. a_dim1 = *lda;
  144. a_offset = 1 + a_dim1;
  145. a -= a_offset;
  146. --x;
  147. --y;
  148. /* Function Body */
  149. info = 0;
  150. if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
  151. ftnlen)1, (ftnlen)1)) {
  152. info = 1;
  153. } else if (*n < 0) {
  154. info = 2;
  155. } else if (*k < 0) {
  156. info = 3;
  157. } else if (*lda < *k + 1) {
  158. info = 6;
  159. } else if (*incx == 0) {
  160. info = 8;
  161. } else if (*incy == 0) {
  162. info = 11;
  163. }
  164. if (info != 0) {
  165. xerbla_("ZHBMV ", &info, (ftnlen)6);
  166. return 0;
  167. }
  168. /* Quick return if possible. */
  169. if (*n == 0 || (alpha->r == 0. && alpha->i == 0. && (beta->r == 1. &&
  170. beta->i == 0.))) {
  171. return 0;
  172. }
  173. /* Set up the start points in X and Y. */
  174. if (*incx > 0) {
  175. kx = 1;
  176. } else {
  177. kx = 1 - (*n - 1) * *incx;
  178. }
  179. if (*incy > 0) {
  180. ky = 1;
  181. } else {
  182. ky = 1 - (*n - 1) * *incy;
  183. }
  184. /* Start the operations. In this version the elements of the array A */
  185. /* are accessed sequentially with one pass through A. */
  186. /* First form y := beta*y. */
  187. if (beta->r != 1. || beta->i != 0.) {
  188. if (*incy == 1) {
  189. if (beta->r == 0. && beta->i == 0.) {
  190. i__1 = *n;
  191. for (i__ = 1; i__ <= i__1; ++i__) {
  192. i__2 = i__;
  193. y[i__2].r = 0., y[i__2].i = 0.;
  194. /* L10: */
  195. }
  196. } else {
  197. i__1 = *n;
  198. for (i__ = 1; i__ <= i__1; ++i__) {
  199. i__2 = i__;
  200. i__3 = i__;
  201. z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
  202. z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
  203. .r;
  204. y[i__2].r = z__1.r, y[i__2].i = z__1.i;
  205. /* L20: */
  206. }
  207. }
  208. } else {
  209. iy = ky;
  210. if (beta->r == 0. && beta->i == 0.) {
  211. i__1 = *n;
  212. for (i__ = 1; i__ <= i__1; ++i__) {
  213. i__2 = iy;
  214. y[i__2].r = 0., y[i__2].i = 0.;
  215. iy += *incy;
  216. /* L30: */
  217. }
  218. } else {
  219. i__1 = *n;
  220. for (i__ = 1; i__ <= i__1; ++i__) {
  221. i__2 = iy;
  222. i__3 = iy;
  223. z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
  224. z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
  225. .r;
  226. y[i__2].r = z__1.r, y[i__2].i = z__1.i;
  227. iy += *incy;
  228. /* L40: */
  229. }
  230. }
  231. }
  232. }
  233. if (alpha->r == 0. && alpha->i == 0.) {
  234. return 0;
  235. }
  236. if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
  237. /* Form y when upper triangle of A is stored. */
  238. kplus1 = *k + 1;
  239. if (*incx == 1 && *incy == 1) {
  240. i__1 = *n;
  241. for (j = 1; j <= i__1; ++j) {
  242. i__2 = j;
  243. z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, z__1.i =
  244. alpha->r * x[i__2].i + alpha->i * x[i__2].r;
  245. temp1.r = z__1.r, temp1.i = z__1.i;
  246. temp2.r = 0., temp2.i = 0.;
  247. l = kplus1 - j;
  248. /* Computing MAX */
  249. i__2 = 1, i__3 = j - *k;
  250. i__4 = j - 1;
  251. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  252. i__2 = i__;
  253. i__3 = i__;
  254. i__5 = l + i__ + j * a_dim1;
  255. z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  256. z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  257. .r;
  258. z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
  259. y[i__2].r = z__1.r, y[i__2].i = z__1.i;
  260. d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
  261. i__2 = i__;
  262. z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i, z__2.i =
  263. z__3.r * x[i__2].i + z__3.i * x[i__2].r;
  264. z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
  265. temp2.r = z__1.r, temp2.i = z__1.i;
  266. /* L50: */
  267. }
  268. i__4 = j;
  269. i__2 = j;
  270. i__3 = kplus1 + j * a_dim1;
  271. d__1 = a[i__3].r;
  272. z__3.r = d__1 * temp1.r, z__3.i = d__1 * temp1.i;
  273. z__2.r = y[i__2].r + z__3.r, z__2.i = y[i__2].i + z__3.i;
  274. z__4.r = alpha->r * temp2.r - alpha->i * temp2.i, z__4.i =
  275. alpha->r * temp2.i + alpha->i * temp2.r;
  276. z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
  277. y[i__4].r = z__1.r, y[i__4].i = z__1.i;
  278. /* L60: */
  279. }
  280. } else {
  281. jx = kx;
  282. jy = ky;
  283. i__1 = *n;
  284. for (j = 1; j <= i__1; ++j) {
  285. i__4 = jx;
  286. z__1.r = alpha->r * x[i__4].r - alpha->i * x[i__4].i, z__1.i =
  287. alpha->r * x[i__4].i + alpha->i * x[i__4].r;
  288. temp1.r = z__1.r, temp1.i = z__1.i;
  289. temp2.r = 0., temp2.i = 0.;
  290. ix = kx;
  291. iy = ky;
  292. l = kplus1 - j;
  293. /* Computing MAX */
  294. i__4 = 1, i__2 = j - *k;
  295. i__3 = j - 1;
  296. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  297. i__4 = iy;
  298. i__2 = iy;
  299. i__5 = l + i__ + j * a_dim1;
  300. z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  301. z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  302. .r;
  303. z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + z__2.i;
  304. y[i__4].r = z__1.r, y[i__4].i = z__1.i;
  305. d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
  306. i__4 = ix;
  307. z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i, z__2.i =
  308. z__3.r * x[i__4].i + z__3.i * x[i__4].r;
  309. z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
  310. temp2.r = z__1.r, temp2.i = z__1.i;
  311. ix += *incx;
  312. iy += *incy;
  313. /* L70: */
  314. }
  315. i__3 = jy;
  316. i__4 = jy;
  317. i__2 = kplus1 + j * a_dim1;
  318. d__1 = a[i__2].r;
  319. z__3.r = d__1 * temp1.r, z__3.i = d__1 * temp1.i;
  320. z__2.r = y[i__4].r + z__3.r, z__2.i = y[i__4].i + z__3.i;
  321. z__4.r = alpha->r * temp2.r - alpha->i * temp2.i, z__4.i =
  322. alpha->r * temp2.i + alpha->i * temp2.r;
  323. z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
  324. y[i__3].r = z__1.r, y[i__3].i = z__1.i;
  325. jx += *incx;
  326. jy += *incy;
  327. if (j > *k) {
  328. kx += *incx;
  329. ky += *incy;
  330. }
  331. /* L80: */
  332. }
  333. }
  334. } else {
  335. /* Form y when lower triangle of A is stored. */
  336. if (*incx == 1 && *incy == 1) {
  337. i__1 = *n;
  338. for (j = 1; j <= i__1; ++j) {
  339. i__3 = j;
  340. z__1.r = alpha->r * x[i__3].r - alpha->i * x[i__3].i, z__1.i =
  341. alpha->r * x[i__3].i + alpha->i * x[i__3].r;
  342. temp1.r = z__1.r, temp1.i = z__1.i;
  343. temp2.r = 0., temp2.i = 0.;
  344. i__3 = j;
  345. i__4 = j;
  346. i__2 = j * a_dim1 + 1;
  347. d__1 = a[i__2].r;
  348. z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
  349. z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
  350. y[i__3].r = z__1.r, y[i__3].i = z__1.i;
  351. l = 1 - j;
  352. /* Computing MIN */
  353. i__4 = *n, i__2 = j + *k;
  354. i__3 = min(i__4,i__2);
  355. for (i__ = j + 1; i__ <= i__3; ++i__) {
  356. i__4 = i__;
  357. i__2 = i__;
  358. i__5 = l + i__ + j * a_dim1;
  359. z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  360. z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  361. .r;
  362. z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + z__2.i;
  363. y[i__4].r = z__1.r, y[i__4].i = z__1.i;
  364. d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
  365. i__4 = i__;
  366. z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i, z__2.i =
  367. z__3.r * x[i__4].i + z__3.i * x[i__4].r;
  368. z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
  369. temp2.r = z__1.r, temp2.i = z__1.i;
  370. /* L90: */
  371. }
  372. i__3 = j;
  373. i__4 = j;
  374. z__2.r = alpha->r * temp2.r - alpha->i * temp2.i, z__2.i =
  375. alpha->r * temp2.i + alpha->i * temp2.r;
  376. z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
  377. y[i__3].r = z__1.r, y[i__3].i = z__1.i;
  378. /* L100: */
  379. }
  380. } else {
  381. jx = kx;
  382. jy = ky;
  383. i__1 = *n;
  384. for (j = 1; j <= i__1; ++j) {
  385. i__3 = jx;
  386. z__1.r = alpha->r * x[i__3].r - alpha->i * x[i__3].i, z__1.i =
  387. alpha->r * x[i__3].i + alpha->i * x[i__3].r;
  388. temp1.r = z__1.r, temp1.i = z__1.i;
  389. temp2.r = 0., temp2.i = 0.;
  390. i__3 = jy;
  391. i__4 = jy;
  392. i__2 = j * a_dim1 + 1;
  393. d__1 = a[i__2].r;
  394. z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
  395. z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
  396. y[i__3].r = z__1.r, y[i__3].i = z__1.i;
  397. l = 1 - j;
  398. ix = jx;
  399. iy = jy;
  400. /* Computing MIN */
  401. i__4 = *n, i__2 = j + *k;
  402. i__3 = min(i__4,i__2);
  403. for (i__ = j + 1; i__ <= i__3; ++i__) {
  404. ix += *incx;
  405. iy += *incy;
  406. i__4 = iy;
  407. i__2 = iy;
  408. i__5 = l + i__ + j * a_dim1;
  409. z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  410. z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  411. .r;
  412. z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + z__2.i;
  413. y[i__4].r = z__1.r, y[i__4].i = z__1.i;
  414. d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
  415. i__4 = ix;
  416. z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i, z__2.i =
  417. z__3.r * x[i__4].i + z__3.i * x[i__4].r;
  418. z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
  419. temp2.r = z__1.r, temp2.i = z__1.i;
  420. /* L110: */
  421. }
  422. i__3 = jy;
  423. i__4 = jy;
  424. z__2.r = alpha->r * temp2.r - alpha->i * temp2.i, z__2.i =
  425. alpha->r * temp2.i + alpha->i * temp2.r;
  426. z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
  427. y[i__3].r = z__1.r, y[i__3].i = z__1.i;
  428. jx += *incx;
  429. jy += *incy;
  430. /* L120: */
  431. }
  432. }
  433. }
  434. return 0;
  435. /* End of ZHBMV . */
  436. } /* zhbmv_ */