cgbmv.c 13 KB

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