zsymm.c 16 KB

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