chbmv.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. /* chbmv.f -- translated by f2c (version 20061008).
  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 "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int chbmv_(char *uplo, integer *n, integer *k, complex *
  14. alpha, complex *a, integer *lda, complex *x, integer *incx, complex *
  15. beta, complex *y, integer *incy)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
  19. real r__1;
  20. complex q__1, q__2, q__3, q__4;
  21. /* Builtin functions */
  22. void r_cnjg(complex *, complex *);
  23. /* Local variables */
  24. integer i__, j, l, ix, iy, jx, jy, kx, ky, info;
  25. complex temp1, temp2;
  26. extern logical lsame_(char *, char *);
  27. integer kplus1;
  28. extern /* Subroutine */ int xerbla_(char *, integer *);
  29. /* .. Scalar Arguments .. */
  30. /* .. */
  31. /* .. Array Arguments .. */
  32. /* .. */
  33. /* Purpose */
  34. /* ======= */
  35. /* CHBMV 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 . */
  59. /* On entry, ALPHA specifies the scalar alpha. */
  60. /* Unchanged on exit. */
  61. /* A - COMPLEX 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 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 . */
  112. /* On entry, BETA specifies the scalar beta. */
  113. /* Unchanged on exit. */
  114. /* Y - COMPLEX 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. /* Level 2 Blas routine. */
  123. /* -- Written on 22-October-1986. */
  124. /* Jack Dongarra, Argonne National Lab. */
  125. /* Jeremy Du Croz, Nag Central Office. */
  126. /* Sven Hammarling, Nag Central Office. */
  127. /* Richard Hanson, Sandia National Labs. */
  128. /* .. Parameters .. */
  129. /* .. */
  130. /* .. Local Scalars .. */
  131. /* .. */
  132. /* .. External Functions .. */
  133. /* .. */
  134. /* .. External Subroutines .. */
  135. /* .. */
  136. /* .. Intrinsic Functions .. */
  137. /* .. */
  138. /* Test the input parameters. */
  139. /* Parameter adjustments */
  140. a_dim1 = *lda;
  141. a_offset = 1 + a_dim1;
  142. a -= a_offset;
  143. --x;
  144. --y;
  145. /* Function Body */
  146. info = 0;
  147. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  148. info = 1;
  149. } else if (*n < 0) {
  150. info = 2;
  151. } else if (*k < 0) {
  152. info = 3;
  153. } else if (*lda < *k + 1) {
  154. info = 6;
  155. } else if (*incx == 0) {
  156. info = 8;
  157. } else if (*incy == 0) {
  158. info = 11;
  159. }
  160. if (info != 0) {
  161. xerbla_("CHBMV ", &info);
  162. return 0;
  163. }
  164. /* Quick return if possible. */
  165. if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r == 1.f &&
  166. beta->i == 0.f)) {
  167. return 0;
  168. }
  169. /* Set up the start points in X and Y. */
  170. if (*incx > 0) {
  171. kx = 1;
  172. } else {
  173. kx = 1 - (*n - 1) * *incx;
  174. }
  175. if (*incy > 0) {
  176. ky = 1;
  177. } else {
  178. ky = 1 - (*n - 1) * *incy;
  179. }
  180. /* Start the operations. In this version the elements of the array A */
  181. /* are accessed sequentially with one pass through A. */
  182. /* First form y := beta*y. */
  183. if (beta->r != 1.f || beta->i != 0.f) {
  184. if (*incy == 1) {
  185. if (beta->r == 0.f && beta->i == 0.f) {
  186. i__1 = *n;
  187. for (i__ = 1; i__ <= i__1; ++i__) {
  188. i__2 = i__;
  189. y[i__2].r = 0.f, y[i__2].i = 0.f;
  190. /* L10: */
  191. }
  192. } else {
  193. i__1 = *n;
  194. for (i__ = 1; i__ <= i__1; ++i__) {
  195. i__2 = i__;
  196. i__3 = i__;
  197. q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
  198. q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
  199. .r;
  200. y[i__2].r = q__1.r, y[i__2].i = q__1.i;
  201. /* L20: */
  202. }
  203. }
  204. } else {
  205. iy = ky;
  206. if (beta->r == 0.f && beta->i == 0.f) {
  207. i__1 = *n;
  208. for (i__ = 1; i__ <= i__1; ++i__) {
  209. i__2 = iy;
  210. y[i__2].r = 0.f, y[i__2].i = 0.f;
  211. iy += *incy;
  212. /* L30: */
  213. }
  214. } else {
  215. i__1 = *n;
  216. for (i__ = 1; i__ <= i__1; ++i__) {
  217. i__2 = iy;
  218. i__3 = iy;
  219. q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
  220. q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
  221. .r;
  222. y[i__2].r = q__1.r, y[i__2].i = q__1.i;
  223. iy += *incy;
  224. /* L40: */
  225. }
  226. }
  227. }
  228. }
  229. if (alpha->r == 0.f && alpha->i == 0.f) {
  230. return 0;
  231. }
  232. if (lsame_(uplo, "U")) {
  233. /* Form y when upper triangle of A is stored. */
  234. kplus1 = *k + 1;
  235. if (*incx == 1 && *incy == 1) {
  236. i__1 = *n;
  237. for (j = 1; j <= i__1; ++j) {
  238. i__2 = j;
  239. q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
  240. alpha->r * x[i__2].i + alpha->i * x[i__2].r;
  241. temp1.r = q__1.r, temp1.i = q__1.i;
  242. temp2.r = 0.f, temp2.i = 0.f;
  243. l = kplus1 - j;
  244. /* Computing MAX */
  245. i__2 = 1, i__3 = j - *k;
  246. i__4 = j - 1;
  247. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  248. i__2 = i__;
  249. i__3 = i__;
  250. i__5 = l + i__ + j * a_dim1;
  251. q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  252. q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  253. .r;
  254. q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
  255. y[i__2].r = q__1.r, y[i__2].i = q__1.i;
  256. r_cnjg(&q__3, &a[l + i__ + j * a_dim1]);
  257. i__2 = i__;
  258. q__2.r = q__3.r * x[i__2].r - q__3.i * x[i__2].i, q__2.i =
  259. q__3.r * x[i__2].i + q__3.i * x[i__2].r;
  260. q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
  261. temp2.r = q__1.r, temp2.i = q__1.i;
  262. /* L50: */
  263. }
  264. i__4 = j;
  265. i__2 = j;
  266. i__3 = kplus1 + j * a_dim1;
  267. r__1 = a[i__3].r;
  268. q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
  269. q__2.r = y[i__2].r + q__3.r, q__2.i = y[i__2].i + q__3.i;
  270. q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
  271. alpha->r * temp2.i + alpha->i * temp2.r;
  272. q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
  273. y[i__4].r = q__1.r, y[i__4].i = q__1.i;
  274. /* L60: */
  275. }
  276. } else {
  277. jx = kx;
  278. jy = ky;
  279. i__1 = *n;
  280. for (j = 1; j <= i__1; ++j) {
  281. i__4 = jx;
  282. q__1.r = alpha->r * x[i__4].r - alpha->i * x[i__4].i, q__1.i =
  283. alpha->r * x[i__4].i + alpha->i * x[i__4].r;
  284. temp1.r = q__1.r, temp1.i = q__1.i;
  285. temp2.r = 0.f, temp2.i = 0.f;
  286. ix = kx;
  287. iy = ky;
  288. l = kplus1 - j;
  289. /* Computing MAX */
  290. i__4 = 1, i__2 = j - *k;
  291. i__3 = j - 1;
  292. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  293. i__4 = iy;
  294. i__2 = iy;
  295. i__5 = l + i__ + j * a_dim1;
  296. q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  297. q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  298. .r;
  299. q__1.r = y[i__2].r + q__2.r, q__1.i = y[i__2].i + q__2.i;
  300. y[i__4].r = q__1.r, y[i__4].i = q__1.i;
  301. r_cnjg(&q__3, &a[l + i__ + j * a_dim1]);
  302. i__4 = ix;
  303. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i, q__2.i =
  304. q__3.r * x[i__4].i + q__3.i * x[i__4].r;
  305. q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
  306. temp2.r = q__1.r, temp2.i = q__1.i;
  307. ix += *incx;
  308. iy += *incy;
  309. /* L70: */
  310. }
  311. i__3 = jy;
  312. i__4 = jy;
  313. i__2 = kplus1 + j * a_dim1;
  314. r__1 = a[i__2].r;
  315. q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
  316. q__2.r = y[i__4].r + q__3.r, q__2.i = y[i__4].i + q__3.i;
  317. q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
  318. alpha->r * temp2.i + alpha->i * temp2.r;
  319. q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
  320. y[i__3].r = q__1.r, y[i__3].i = q__1.i;
  321. jx += *incx;
  322. jy += *incy;
  323. if (j > *k) {
  324. kx += *incx;
  325. ky += *incy;
  326. }
  327. /* L80: */
  328. }
  329. }
  330. } else {
  331. /* Form y when lower triangle of A is stored. */
  332. if (*incx == 1 && *incy == 1) {
  333. i__1 = *n;
  334. for (j = 1; j <= i__1; ++j) {
  335. i__3 = j;
  336. q__1.r = alpha->r * x[i__3].r - alpha->i * x[i__3].i, q__1.i =
  337. alpha->r * x[i__3].i + alpha->i * x[i__3].r;
  338. temp1.r = q__1.r, temp1.i = q__1.i;
  339. temp2.r = 0.f, temp2.i = 0.f;
  340. i__3 = j;
  341. i__4 = j;
  342. i__2 = j * a_dim1 + 1;
  343. r__1 = a[i__2].r;
  344. q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
  345. q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
  346. y[i__3].r = q__1.r, y[i__3].i = q__1.i;
  347. l = 1 - j;
  348. /* Computing MIN */
  349. i__4 = *n, i__2 = j + *k;
  350. i__3 = min(i__4,i__2);
  351. for (i__ = j + 1; i__ <= i__3; ++i__) {
  352. i__4 = i__;
  353. i__2 = i__;
  354. i__5 = l + i__ + j * a_dim1;
  355. q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  356. q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  357. .r;
  358. q__1.r = y[i__2].r + q__2.r, q__1.i = y[i__2].i + q__2.i;
  359. y[i__4].r = q__1.r, y[i__4].i = q__1.i;
  360. r_cnjg(&q__3, &a[l + i__ + j * a_dim1]);
  361. i__4 = i__;
  362. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i, q__2.i =
  363. q__3.r * x[i__4].i + q__3.i * x[i__4].r;
  364. q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
  365. temp2.r = q__1.r, temp2.i = q__1.i;
  366. /* L90: */
  367. }
  368. i__3 = j;
  369. i__4 = j;
  370. q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
  371. alpha->r * temp2.i + alpha->i * temp2.r;
  372. q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
  373. y[i__3].r = q__1.r, y[i__3].i = q__1.i;
  374. /* L100: */
  375. }
  376. } else {
  377. jx = kx;
  378. jy = ky;
  379. i__1 = *n;
  380. for (j = 1; j <= i__1; ++j) {
  381. i__3 = jx;
  382. q__1.r = alpha->r * x[i__3].r - alpha->i * x[i__3].i, q__1.i =
  383. alpha->r * x[i__3].i + alpha->i * x[i__3].r;
  384. temp1.r = q__1.r, temp1.i = q__1.i;
  385. temp2.r = 0.f, temp2.i = 0.f;
  386. i__3 = jy;
  387. i__4 = jy;
  388. i__2 = j * a_dim1 + 1;
  389. r__1 = a[i__2].r;
  390. q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
  391. q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
  392. y[i__3].r = q__1.r, y[i__3].i = q__1.i;
  393. l = 1 - j;
  394. ix = jx;
  395. iy = jy;
  396. /* Computing MIN */
  397. i__4 = *n, i__2 = j + *k;
  398. i__3 = min(i__4,i__2);
  399. for (i__ = j + 1; i__ <= i__3; ++i__) {
  400. ix += *incx;
  401. iy += *incy;
  402. i__4 = iy;
  403. i__2 = iy;
  404. i__5 = l + i__ + j * a_dim1;
  405. q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
  406. q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
  407. .r;
  408. q__1.r = y[i__2].r + q__2.r, q__1.i = y[i__2].i + q__2.i;
  409. y[i__4].r = q__1.r, y[i__4].i = q__1.i;
  410. r_cnjg(&q__3, &a[l + i__ + j * a_dim1]);
  411. i__4 = ix;
  412. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i, q__2.i =
  413. q__3.r * x[i__4].i + q__3.i * x[i__4].r;
  414. q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
  415. temp2.r = q__1.r, temp2.i = q__1.i;
  416. /* L110: */
  417. }
  418. i__3 = jy;
  419. i__4 = jy;
  420. q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
  421. alpha->r * temp2.i + alpha->i * temp2.r;
  422. q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
  423. y[i__3].r = q__1.r, y[i__3].i = q__1.i;
  424. jx += *incx;
  425. jy += *incy;
  426. /* L120: */
  427. }
  428. }
  429. }
  430. return 0;
  431. /* End of CHBMV . */
  432. } /* chbmv_ */