zgbmv.c 13 KB

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