csymm.c 15 KB

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