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.

438 lines
13 KiB

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