zsyrk.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /* zsyrk.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 zsyrk_(char *uplo, char *trans, integer *n, integer *k,
  14. doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
  15. beta, doublecomplex *c__, integer *ldc)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3, i__4, i__5,
  19. i__6;
  20. doublecomplex z__1, z__2, z__3;
  21. /* Local variables */
  22. integer i__, j, l, info;
  23. doublecomplex temp;
  24. extern logical lsame_(char *, char *);
  25. integer nrowa;
  26. logical upper;
  27. extern /* Subroutine */ int xerbla_(char *, integer *);
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* .. Array Arguments .. */
  31. /* .. */
  32. /* Purpose */
  33. /* ======= */
  34. /* ZSYRK performs one of the symmetric rank k operations */
  35. /* C := alpha*A*A' + beta*C, */
  36. /* or */
  37. /* C := alpha*A'*A + beta*C, */
  38. /* where alpha and beta are scalars, C is an n by n symmetric matrix */
  39. /* and A is an n by k matrix in the first case and a k by n matrix */
  40. /* in the second case. */
  41. /* Arguments */
  42. /* ========== */
  43. /* UPLO - CHARACTER*1. */
  44. /* On entry, UPLO specifies whether the upper or lower */
  45. /* triangular part of the array C is to be referenced as */
  46. /* follows: */
  47. /* UPLO = 'U' or 'u' Only the upper triangular part of C */
  48. /* is to be referenced. */
  49. /* UPLO = 'L' or 'l' Only the lower triangular part of C */
  50. /* is to be referenced. */
  51. /* Unchanged on exit. */
  52. /* TRANS - CHARACTER*1. */
  53. /* On entry, TRANS specifies the operation to be performed as */
  54. /* follows: */
  55. /* TRANS = 'N' or 'n' C := alpha*A*A' + beta*C. */
  56. /* TRANS = 'T' or 't' C := alpha*A'*A + beta*C. */
  57. /* Unchanged on exit. */
  58. /* N - INTEGER. */
  59. /* On entry, N specifies the order of the matrix C. N must be */
  60. /* at least zero. */
  61. /* Unchanged on exit. */
  62. /* K - INTEGER. */
  63. /* On entry with TRANS = 'N' or 'n', K specifies the number */
  64. /* of columns of the matrix A, and on entry with */
  65. /* TRANS = 'T' or 't', K specifies the number of rows of the */
  66. /* matrix A. K must be at least zero. */
  67. /* Unchanged on exit. */
  68. /* ALPHA - COMPLEX*16 . */
  69. /* On entry, ALPHA specifies the scalar alpha. */
  70. /* Unchanged on exit. */
  71. /* A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is */
  72. /* k when TRANS = 'N' or 'n', and is n otherwise. */
  73. /* Before entry with TRANS = 'N' or 'n', the leading n by k */
  74. /* part of the array A must contain the matrix A, otherwise */
  75. /* the leading k by n part of the array A must contain the */
  76. /* matrix A. */
  77. /* Unchanged on exit. */
  78. /* LDA - INTEGER. */
  79. /* On entry, LDA specifies the first dimension of A as declared */
  80. /* in the calling (sub) program. When TRANS = 'N' or 'n' */
  81. /* then LDA must be at least max( 1, n ), otherwise LDA must */
  82. /* be at least max( 1, k ). */
  83. /* Unchanged on exit. */
  84. /* BETA - COMPLEX*16 . */
  85. /* On entry, BETA specifies the scalar beta. */
  86. /* Unchanged on exit. */
  87. /* C - COMPLEX*16 array of DIMENSION ( LDC, n ). */
  88. /* Before entry with UPLO = 'U' or 'u', the leading n by n */
  89. /* upper triangular part of the array C must contain the upper */
  90. /* triangular part of the symmetric matrix and the strictly */
  91. /* lower triangular part of C is not referenced. On exit, the */
  92. /* upper triangular part of the array C is overwritten by the */
  93. /* upper triangular part of the updated matrix. */
  94. /* Before entry with UPLO = 'L' or 'l', the leading n by n */
  95. /* lower triangular part of the array C must contain the lower */
  96. /* triangular part of the symmetric matrix and the strictly */
  97. /* upper triangular part of C is not referenced. On exit, the */
  98. /* lower triangular part of the array C is overwritten by the */
  99. /* lower triangular part of the updated matrix. */
  100. /* LDC - INTEGER. */
  101. /* On entry, LDC specifies the first dimension of C as declared */
  102. /* in the calling (sub) program. LDC must be at least */
  103. /* max( 1, n ). */
  104. /* Unchanged on exit. */
  105. /* Level 3 Blas routine. */
  106. /* -- Written on 8-February-1989. */
  107. /* Jack Dongarra, Argonne National Laboratory. */
  108. /* Iain Duff, AERE Harwell. */
  109. /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
  110. /* Sven Hammarling, Numerical Algorithms Group Ltd. */
  111. /* .. External Functions .. */
  112. /* .. */
  113. /* .. External Subroutines .. */
  114. /* .. */
  115. /* .. Intrinsic Functions .. */
  116. /* .. */
  117. /* .. Local Scalars .. */
  118. /* .. */
  119. /* .. Parameters .. */
  120. /* .. */
  121. /* Test the input parameters. */
  122. /* Parameter adjustments */
  123. a_dim1 = *lda;
  124. a_offset = 1 + a_dim1;
  125. a -= a_offset;
  126. c_dim1 = *ldc;
  127. c_offset = 1 + c_dim1;
  128. c__ -= c_offset;
  129. /* Function Body */
  130. if (lsame_(trans, "N")) {
  131. nrowa = *n;
  132. } else {
  133. nrowa = *k;
  134. }
  135. upper = lsame_(uplo, "U");
  136. info = 0;
  137. if (! upper && ! lsame_(uplo, "L")) {
  138. info = 1;
  139. } else if (! lsame_(trans, "N") && ! lsame_(trans,
  140. "T")) {
  141. info = 2;
  142. } else if (*n < 0) {
  143. info = 3;
  144. } else if (*k < 0) {
  145. info = 4;
  146. } else if (*lda < max(1,nrowa)) {
  147. info = 7;
  148. } else if (*ldc < max(1,*n)) {
  149. info = 10;
  150. }
  151. if (info != 0) {
  152. xerbla_("ZSYRK ", &info);
  153. return 0;
  154. }
  155. /* Quick return if possible. */
  156. if (*n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) && (beta->r
  157. == 1. && beta->i == 0.)) {
  158. return 0;
  159. }
  160. /* And when alpha.eq.zero. */
  161. if (alpha->r == 0. && alpha->i == 0.) {
  162. if (upper) {
  163. if (beta->r == 0. && beta->i == 0.) {
  164. i__1 = *n;
  165. for (j = 1; j <= i__1; ++j) {
  166. i__2 = j;
  167. for (i__ = 1; i__ <= i__2; ++i__) {
  168. i__3 = i__ + j * c_dim1;
  169. c__[i__3].r = 0., c__[i__3].i = 0.;
  170. /* L10: */
  171. }
  172. /* L20: */
  173. }
  174. } else {
  175. i__1 = *n;
  176. for (j = 1; j <= i__1; ++j) {
  177. i__2 = j;
  178. for (i__ = 1; i__ <= i__2; ++i__) {
  179. i__3 = i__ + j * c_dim1;
  180. i__4 = i__ + j * c_dim1;
  181. z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  182. .i, z__1.i = beta->r * c__[i__4].i + beta->i *
  183. c__[i__4].r;
  184. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  185. /* L30: */
  186. }
  187. /* L40: */
  188. }
  189. }
  190. } else {
  191. if (beta->r == 0. && beta->i == 0.) {
  192. i__1 = *n;
  193. for (j = 1; j <= i__1; ++j) {
  194. i__2 = *n;
  195. for (i__ = j; i__ <= i__2; ++i__) {
  196. i__3 = i__ + j * c_dim1;
  197. c__[i__3].r = 0., c__[i__3].i = 0.;
  198. /* L50: */
  199. }
  200. /* L60: */
  201. }
  202. } else {
  203. i__1 = *n;
  204. for (j = 1; j <= i__1; ++j) {
  205. i__2 = *n;
  206. for (i__ = j; i__ <= i__2; ++i__) {
  207. i__3 = i__ + j * c_dim1;
  208. i__4 = i__ + j * c_dim1;
  209. z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  210. .i, z__1.i = beta->r * c__[i__4].i + beta->i *
  211. c__[i__4].r;
  212. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  213. /* L70: */
  214. }
  215. /* L80: */
  216. }
  217. }
  218. }
  219. return 0;
  220. }
  221. /* Start the operations. */
  222. if (lsame_(trans, "N")) {
  223. /* Form C := alpha*A*A' + beta*C. */
  224. if (upper) {
  225. i__1 = *n;
  226. for (j = 1; j <= i__1; ++j) {
  227. if (beta->r == 0. && beta->i == 0.) {
  228. i__2 = j;
  229. for (i__ = 1; i__ <= i__2; ++i__) {
  230. i__3 = i__ + j * c_dim1;
  231. c__[i__3].r = 0., c__[i__3].i = 0.;
  232. /* L90: */
  233. }
  234. } else if (beta->r != 1. || beta->i != 0.) {
  235. i__2 = j;
  236. for (i__ = 1; i__ <= i__2; ++i__) {
  237. i__3 = i__ + j * c_dim1;
  238. i__4 = i__ + j * c_dim1;
  239. z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  240. .i, z__1.i = beta->r * c__[i__4].i + beta->i *
  241. c__[i__4].r;
  242. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  243. /* L100: */
  244. }
  245. }
  246. i__2 = *k;
  247. for (l = 1; l <= i__2; ++l) {
  248. i__3 = j + l * a_dim1;
  249. if (a[i__3].r != 0. || a[i__3].i != 0.) {
  250. i__3 = j + l * a_dim1;
  251. z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
  252. z__1.i = alpha->r * a[i__3].i + alpha->i * a[
  253. i__3].r;
  254. temp.r = z__1.r, temp.i = z__1.i;
  255. i__3 = j;
  256. for (i__ = 1; i__ <= i__3; ++i__) {
  257. i__4 = i__ + j * c_dim1;
  258. i__5 = i__ + j * c_dim1;
  259. i__6 = i__ + l * a_dim1;
  260. z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
  261. z__2.i = temp.r * a[i__6].i + temp.i * a[
  262. i__6].r;
  263. z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
  264. .i + z__2.i;
  265. c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
  266. /* L110: */
  267. }
  268. }
  269. /* L120: */
  270. }
  271. /* L130: */
  272. }
  273. } else {
  274. i__1 = *n;
  275. for (j = 1; j <= i__1; ++j) {
  276. if (beta->r == 0. && beta->i == 0.) {
  277. i__2 = *n;
  278. for (i__ = j; i__ <= i__2; ++i__) {
  279. i__3 = i__ + j * c_dim1;
  280. c__[i__3].r = 0., c__[i__3].i = 0.;
  281. /* L140: */
  282. }
  283. } else if (beta->r != 1. || beta->i != 0.) {
  284. i__2 = *n;
  285. for (i__ = j; i__ <= i__2; ++i__) {
  286. i__3 = i__ + j * c_dim1;
  287. i__4 = i__ + j * c_dim1;
  288. z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  289. .i, z__1.i = beta->r * c__[i__4].i + beta->i *
  290. c__[i__4].r;
  291. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  292. /* L150: */
  293. }
  294. }
  295. i__2 = *k;
  296. for (l = 1; l <= i__2; ++l) {
  297. i__3 = j + l * a_dim1;
  298. if (a[i__3].r != 0. || a[i__3].i != 0.) {
  299. i__3 = j + l * a_dim1;
  300. z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
  301. z__1.i = alpha->r * a[i__3].i + alpha->i * a[
  302. i__3].r;
  303. temp.r = z__1.r, temp.i = z__1.i;
  304. i__3 = *n;
  305. for (i__ = j; i__ <= i__3; ++i__) {
  306. i__4 = i__ + j * c_dim1;
  307. i__5 = i__ + j * c_dim1;
  308. i__6 = i__ + l * a_dim1;
  309. z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
  310. z__2.i = temp.r * a[i__6].i + temp.i * a[
  311. i__6].r;
  312. z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
  313. .i + z__2.i;
  314. c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
  315. /* L160: */
  316. }
  317. }
  318. /* L170: */
  319. }
  320. /* L180: */
  321. }
  322. }
  323. } else {
  324. /* Form C := alpha*A'*A + beta*C. */
  325. if (upper) {
  326. i__1 = *n;
  327. for (j = 1; j <= i__1; ++j) {
  328. i__2 = j;
  329. for (i__ = 1; i__ <= i__2; ++i__) {
  330. temp.r = 0., temp.i = 0.;
  331. i__3 = *k;
  332. for (l = 1; l <= i__3; ++l) {
  333. i__4 = l + i__ * a_dim1;
  334. i__5 = l + j * a_dim1;
  335. z__2.r = a[i__4].r * a[i__5].r - a[i__4].i * a[i__5]
  336. .i, z__2.i = a[i__4].r * a[i__5].i + a[i__4]
  337. .i * a[i__5].r;
  338. z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
  339. temp.r = z__1.r, temp.i = z__1.i;
  340. /* L190: */
  341. }
  342. if (beta->r == 0. && beta->i == 0.) {
  343. i__3 = i__ + j * c_dim1;
  344. z__1.r = alpha->r * temp.r - alpha->i * temp.i,
  345. z__1.i = alpha->r * temp.i + alpha->i *
  346. temp.r;
  347. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  348. } else {
  349. i__3 = i__ + j * c_dim1;
  350. z__2.r = alpha->r * temp.r - alpha->i * temp.i,
  351. z__2.i = alpha->r * temp.i + alpha->i *
  352. temp.r;
  353. i__4 = i__ + j * c_dim1;
  354. z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  355. .i, z__3.i = beta->r * c__[i__4].i + beta->i *
  356. c__[i__4].r;
  357. z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
  358. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  359. }
  360. /* L200: */
  361. }
  362. /* L210: */
  363. }
  364. } else {
  365. i__1 = *n;
  366. for (j = 1; j <= i__1; ++j) {
  367. i__2 = *n;
  368. for (i__ = j; i__ <= i__2; ++i__) {
  369. temp.r = 0., temp.i = 0.;
  370. i__3 = *k;
  371. for (l = 1; l <= i__3; ++l) {
  372. i__4 = l + i__ * a_dim1;
  373. i__5 = l + j * a_dim1;
  374. z__2.r = a[i__4].r * a[i__5].r - a[i__4].i * a[i__5]
  375. .i, z__2.i = a[i__4].r * a[i__5].i + a[i__4]
  376. .i * a[i__5].r;
  377. z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
  378. temp.r = z__1.r, temp.i = z__1.i;
  379. /* L220: */
  380. }
  381. if (beta->r == 0. && beta->i == 0.) {
  382. i__3 = i__ + j * c_dim1;
  383. z__1.r = alpha->r * temp.r - alpha->i * temp.i,
  384. z__1.i = alpha->r * temp.i + alpha->i *
  385. temp.r;
  386. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  387. } else {
  388. i__3 = i__ + j * c_dim1;
  389. z__2.r = alpha->r * temp.r - alpha->i * temp.i,
  390. z__2.i = alpha->r * temp.i + alpha->i *
  391. temp.r;
  392. i__4 = i__ + j * c_dim1;
  393. z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  394. .i, z__3.i = beta->r * c__[i__4].i + beta->i *
  395. c__[i__4].r;
  396. z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
  397. c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
  398. }
  399. /* L230: */
  400. }
  401. /* L240: */
  402. }
  403. }
  404. }
  405. return 0;
  406. /* End of ZSYRK . */
  407. } /* zsyrk_ */