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.

487 lines
15 KiB

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