cgemm.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /* cgemm.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 cgemm_(char *transa, char *transb, integer *m, integer *
  14. n, integer *k, complex *alpha, complex *a, integer *lda, complex *b,
  15. integer *ldb, 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;
  21. /* Builtin functions */
  22. void r_cnjg(complex *, complex *);
  23. /* Local variables */
  24. integer i__, j, l, info;
  25. logical nota, notb;
  26. complex temp;
  27. logical conja, conjb;
  28. integer ncola;
  29. extern logical lsame_(char *, char *);
  30. integer nrowa, nrowb;
  31. extern /* Subroutine */ int xerbla_(char *, integer *);
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* CGEMM performs one of the matrix-matrix operations */
  39. /* C := alpha*op( A )*op( B ) + beta*C, */
  40. /* where op( X ) is one of */
  41. /* op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ), */
  42. /* alpha and beta are scalars, and A, B and C are matrices, with op( A ) */
  43. /* an m by k matrix, op( B ) a k by n matrix and C an m by n matrix. */
  44. /* Arguments */
  45. /* ========== */
  46. /* TRANSA - CHARACTER*1. */
  47. /* On entry, TRANSA specifies the form of op( A ) to be used in */
  48. /* the matrix multiplication as follows: */
  49. /* TRANSA = 'N' or 'n', op( A ) = A. */
  50. /* TRANSA = 'T' or 't', op( A ) = A'. */
  51. /* TRANSA = 'C' or 'c', op( A ) = conjg( A' ). */
  52. /* Unchanged on exit. */
  53. /* TRANSB - CHARACTER*1. */
  54. /* On entry, TRANSB specifies the form of op( B ) to be used in */
  55. /* the matrix multiplication as follows: */
  56. /* TRANSB = 'N' or 'n', op( B ) = B. */
  57. /* TRANSB = 'T' or 't', op( B ) = B'. */
  58. /* TRANSB = 'C' or 'c', op( B ) = conjg( B' ). */
  59. /* Unchanged on exit. */
  60. /* M - INTEGER. */
  61. /* On entry, M specifies the number of rows of the matrix */
  62. /* op( A ) and of the matrix C. M must be at least zero. */
  63. /* Unchanged on exit. */
  64. /* N - INTEGER. */
  65. /* On entry, N specifies the number of columns of the matrix */
  66. /* op( B ) and the number of columns of the matrix C. N must be */
  67. /* at least zero. */
  68. /* Unchanged on exit. */
  69. /* K - INTEGER. */
  70. /* On entry, K specifies the number of columns of the matrix */
  71. /* op( A ) and the number of rows of the matrix op( B ). K must */
  72. /* be at least zero. */
  73. /* Unchanged on exit. */
  74. /* ALPHA - COMPLEX . */
  75. /* On entry, ALPHA specifies the scalar alpha. */
  76. /* Unchanged on exit. */
  77. /* A - COMPLEX array of DIMENSION ( LDA, ka ), where ka is */
  78. /* k when TRANSA = 'N' or 'n', and is m otherwise. */
  79. /* Before entry with TRANSA = 'N' or 'n', the leading m by k */
  80. /* part of the array A must contain the matrix A, otherwise */
  81. /* the leading k by m part of the array A must contain the */
  82. /* matrix A. */
  83. /* Unchanged on exit. */
  84. /* LDA - INTEGER. */
  85. /* On entry, LDA specifies the first dimension of A as declared */
  86. /* in the calling (sub) program. When TRANSA = 'N' or 'n' then */
  87. /* LDA must be at least max( 1, m ), otherwise LDA must be at */
  88. /* least max( 1, k ). */
  89. /* Unchanged on exit. */
  90. /* B - COMPLEX array of DIMENSION ( LDB, kb ), where kb is */
  91. /* n when TRANSB = 'N' or 'n', and is k otherwise. */
  92. /* Before entry with TRANSB = 'N' or 'n', the leading k by n */
  93. /* part of the array B must contain the matrix B, otherwise */
  94. /* the leading n by k part of the array B must contain the */
  95. /* matrix B. */
  96. /* Unchanged on exit. */
  97. /* LDB - INTEGER. */
  98. /* On entry, LDB specifies the first dimension of B as declared */
  99. /* in the calling (sub) program. When TRANSB = 'N' or 'n' then */
  100. /* LDB must be at least max( 1, k ), otherwise LDB must be at */
  101. /* least max( 1, n ). */
  102. /* Unchanged on exit. */
  103. /* BETA - COMPLEX . */
  104. /* On entry, BETA specifies the scalar beta. When BETA is */
  105. /* supplied as zero then C need not be set on input. */
  106. /* Unchanged on exit. */
  107. /* C - COMPLEX array of DIMENSION ( LDC, n ). */
  108. /* Before entry, the leading m by n part of the array C must */
  109. /* contain the matrix C, except when beta is zero, in which */
  110. /* case C need not be set on entry. */
  111. /* On exit, the array C is overwritten by the m by n matrix */
  112. /* ( alpha*op( A )*op( B ) + beta*C ). */
  113. /* LDC - INTEGER. */
  114. /* On entry, LDC specifies the first dimension of C as declared */
  115. /* in the calling (sub) program. LDC must be at least */
  116. /* max( 1, m ). */
  117. /* Unchanged on exit. */
  118. /* Level 3 Blas routine. */
  119. /* -- Written on 8-February-1989. */
  120. /* Jack Dongarra, Argonne National Laboratory. */
  121. /* Iain Duff, AERE Harwell. */
  122. /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
  123. /* Sven Hammarling, Numerical Algorithms Group Ltd. */
  124. /* .. External Functions .. */
  125. /* .. */
  126. /* .. External Subroutines .. */
  127. /* .. */
  128. /* .. Intrinsic Functions .. */
  129. /* .. */
  130. /* .. Local Scalars .. */
  131. /* .. */
  132. /* .. Parameters .. */
  133. /* .. */
  134. /* Set NOTA and NOTB as true if A and B respectively are not */
  135. /* conjugated or transposed, set CONJA and CONJB as true if A and */
  136. /* B respectively are to be transposed but not conjugated and set */
  137. /* NROWA, NCOLA and NROWB as the number of rows and columns of A */
  138. /* and the number of rows of B respectively. */
  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. nota = lsame_(transa, "N");
  151. notb = lsame_(transb, "N");
  152. conja = lsame_(transa, "C");
  153. conjb = lsame_(transb, "C");
  154. if (nota) {
  155. nrowa = *m;
  156. ncola = *k;
  157. } else {
  158. nrowa = *k;
  159. ncola = *m;
  160. }
  161. if (notb) {
  162. nrowb = *k;
  163. } else {
  164. nrowb = *n;
  165. }
  166. /* Test the input parameters. */
  167. info = 0;
  168. if (! nota && ! conja && ! lsame_(transa, "T")) {
  169. info = 1;
  170. } else if (! notb && ! conjb && ! lsame_(transb, "T")) {
  171. info = 2;
  172. } else if (*m < 0) {
  173. info = 3;
  174. } else if (*n < 0) {
  175. info = 4;
  176. } else if (*k < 0) {
  177. info = 5;
  178. } else if (*lda < max(1,nrowa)) {
  179. info = 8;
  180. } else if (*ldb < max(1,nrowb)) {
  181. info = 10;
  182. } else if (*ldc < max(1,*m)) {
  183. info = 13;
  184. }
  185. if (info != 0) {
  186. xerbla_("CGEMM ", &info);
  187. return 0;
  188. }
  189. /* Quick return if possible. */
  190. if (*m == 0 || *n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0)
  191. && (beta->r == 1.f && beta->i == 0.f)) {
  192. return 0;
  193. }
  194. /* And when alpha.eq.zero. */
  195. if (alpha->r == 0.f && alpha->i == 0.f) {
  196. if (beta->r == 0.f && beta->i == 0.f) {
  197. i__1 = *n;
  198. for (j = 1; j <= i__1; ++j) {
  199. i__2 = *m;
  200. for (i__ = 1; i__ <= i__2; ++i__) {
  201. i__3 = i__ + j * c_dim1;
  202. c__[i__3].r = 0.f, c__[i__3].i = 0.f;
  203. /* L10: */
  204. }
  205. /* L20: */
  206. }
  207. } else {
  208. i__1 = *n;
  209. for (j = 1; j <= i__1; ++j) {
  210. i__2 = *m;
  211. for (i__ = 1; i__ <= i__2; ++i__) {
  212. i__3 = i__ + j * c_dim1;
  213. i__4 = i__ + j * c_dim1;
  214. q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
  215. q__1.i = beta->r * c__[i__4].i + beta->i * c__[
  216. i__4].r;
  217. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  218. /* L30: */
  219. }
  220. /* L40: */
  221. }
  222. }
  223. return 0;
  224. }
  225. /* Start the operations. */
  226. if (notb) {
  227. if (nota) {
  228. /* Form C := alpha*A*B + beta*C. */
  229. i__1 = *n;
  230. for (j = 1; j <= i__1; ++j) {
  231. if (beta->r == 0.f && beta->i == 0.f) {
  232. i__2 = *m;
  233. for (i__ = 1; i__ <= i__2; ++i__) {
  234. i__3 = i__ + j * c_dim1;
  235. c__[i__3].r = 0.f, c__[i__3].i = 0.f;
  236. /* L50: */
  237. }
  238. } else if (beta->r != 1.f || beta->i != 0.f) {
  239. i__2 = *m;
  240. for (i__ = 1; i__ <= i__2; ++i__) {
  241. i__3 = i__ + j * c_dim1;
  242. i__4 = i__ + j * c_dim1;
  243. q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  244. .i, q__1.i = beta->r * c__[i__4].i + beta->i *
  245. c__[i__4].r;
  246. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  247. /* L60: */
  248. }
  249. }
  250. i__2 = *k;
  251. for (l = 1; l <= i__2; ++l) {
  252. i__3 = l + j * b_dim1;
  253. if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
  254. i__3 = l + j * b_dim1;
  255. q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
  256. q__1.i = alpha->r * b[i__3].i + alpha->i * b[
  257. i__3].r;
  258. temp.r = q__1.r, temp.i = q__1.i;
  259. i__3 = *m;
  260. for (i__ = 1; i__ <= i__3; ++i__) {
  261. i__4 = i__ + j * c_dim1;
  262. i__5 = i__ + j * c_dim1;
  263. i__6 = i__ + l * a_dim1;
  264. q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
  265. q__2.i = temp.r * a[i__6].i + temp.i * a[
  266. i__6].r;
  267. q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
  268. .i + q__2.i;
  269. c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
  270. /* L70: */
  271. }
  272. }
  273. /* L80: */
  274. }
  275. /* L90: */
  276. }
  277. } else if (conja) {
  278. /* Form C := alpha*conjg( A' )*B + beta*C. */
  279. i__1 = *n;
  280. for (j = 1; j <= i__1; ++j) {
  281. i__2 = *m;
  282. for (i__ = 1; i__ <= i__2; ++i__) {
  283. temp.r = 0.f, temp.i = 0.f;
  284. i__3 = *k;
  285. for (l = 1; l <= i__3; ++l) {
  286. r_cnjg(&q__3, &a[l + i__ * a_dim1]);
  287. i__4 = l + j * b_dim1;
  288. q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
  289. q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
  290. .r;
  291. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  292. temp.r = q__1.r, temp.i = q__1.i;
  293. /* L100: */
  294. }
  295. if (beta->r == 0.f && beta->i == 0.f) {
  296. i__3 = i__ + j * c_dim1;
  297. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  298. q__1.i = alpha->r * temp.i + alpha->i *
  299. temp.r;
  300. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  301. } else {
  302. i__3 = i__ + j * c_dim1;
  303. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  304. q__2.i = alpha->r * temp.i + alpha->i *
  305. temp.r;
  306. i__4 = i__ + j * c_dim1;
  307. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  308. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  309. c__[i__4].r;
  310. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  311. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  312. }
  313. /* L110: */
  314. }
  315. /* L120: */
  316. }
  317. } else {
  318. /* Form C := alpha*A'*B + beta*C */
  319. i__1 = *n;
  320. for (j = 1; j <= i__1; ++j) {
  321. i__2 = *m;
  322. for (i__ = 1; i__ <= i__2; ++i__) {
  323. temp.r = 0.f, temp.i = 0.f;
  324. i__3 = *k;
  325. for (l = 1; l <= i__3; ++l) {
  326. i__4 = l + i__ * a_dim1;
  327. i__5 = l + j * b_dim1;
  328. q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
  329. .i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
  330. .i * b[i__5].r;
  331. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  332. temp.r = q__1.r, temp.i = q__1.i;
  333. /* L130: */
  334. }
  335. if (beta->r == 0.f && beta->i == 0.f) {
  336. i__3 = i__ + j * c_dim1;
  337. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  338. q__1.i = alpha->r * temp.i + alpha->i *
  339. temp.r;
  340. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  341. } else {
  342. i__3 = i__ + j * c_dim1;
  343. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  344. q__2.i = alpha->r * temp.i + alpha->i *
  345. temp.r;
  346. i__4 = i__ + j * c_dim1;
  347. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  348. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  349. c__[i__4].r;
  350. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  351. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  352. }
  353. /* L140: */
  354. }
  355. /* L150: */
  356. }
  357. }
  358. } else if (nota) {
  359. if (conjb) {
  360. /* Form C := alpha*A*conjg( B' ) + beta*C. */
  361. i__1 = *n;
  362. for (j = 1; j <= i__1; ++j) {
  363. if (beta->r == 0.f && beta->i == 0.f) {
  364. i__2 = *m;
  365. for (i__ = 1; i__ <= i__2; ++i__) {
  366. i__3 = i__ + j * c_dim1;
  367. c__[i__3].r = 0.f, c__[i__3].i = 0.f;
  368. /* L160: */
  369. }
  370. } else if (beta->r != 1.f || beta->i != 0.f) {
  371. i__2 = *m;
  372. for (i__ = 1; i__ <= i__2; ++i__) {
  373. i__3 = i__ + j * c_dim1;
  374. i__4 = i__ + j * c_dim1;
  375. q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  376. .i, q__1.i = beta->r * c__[i__4].i + beta->i *
  377. c__[i__4].r;
  378. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  379. /* L170: */
  380. }
  381. }
  382. i__2 = *k;
  383. for (l = 1; l <= i__2; ++l) {
  384. i__3 = j + l * b_dim1;
  385. if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
  386. r_cnjg(&q__2, &b[j + l * b_dim1]);
  387. q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
  388. q__1.i = alpha->r * q__2.i + alpha->i *
  389. q__2.r;
  390. temp.r = q__1.r, temp.i = q__1.i;
  391. i__3 = *m;
  392. for (i__ = 1; i__ <= i__3; ++i__) {
  393. i__4 = i__ + j * c_dim1;
  394. i__5 = i__ + j * c_dim1;
  395. i__6 = i__ + l * a_dim1;
  396. q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
  397. q__2.i = temp.r * a[i__6].i + temp.i * a[
  398. i__6].r;
  399. q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
  400. .i + q__2.i;
  401. c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
  402. /* L180: */
  403. }
  404. }
  405. /* L190: */
  406. }
  407. /* L200: */
  408. }
  409. } else {
  410. /* Form C := alpha*A*B' + beta*C */
  411. i__1 = *n;
  412. for (j = 1; j <= i__1; ++j) {
  413. if (beta->r == 0.f && beta->i == 0.f) {
  414. i__2 = *m;
  415. for (i__ = 1; i__ <= i__2; ++i__) {
  416. i__3 = i__ + j * c_dim1;
  417. c__[i__3].r = 0.f, c__[i__3].i = 0.f;
  418. /* L210: */
  419. }
  420. } else if (beta->r != 1.f || beta->i != 0.f) {
  421. i__2 = *m;
  422. for (i__ = 1; i__ <= i__2; ++i__) {
  423. i__3 = i__ + j * c_dim1;
  424. i__4 = i__ + j * c_dim1;
  425. q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  426. .i, q__1.i = beta->r * c__[i__4].i + beta->i *
  427. c__[i__4].r;
  428. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  429. /* L220: */
  430. }
  431. }
  432. i__2 = *k;
  433. for (l = 1; l <= i__2; ++l) {
  434. i__3 = j + l * b_dim1;
  435. if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
  436. i__3 = j + l * b_dim1;
  437. q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
  438. q__1.i = alpha->r * b[i__3].i + alpha->i * b[
  439. i__3].r;
  440. temp.r = q__1.r, temp.i = q__1.i;
  441. i__3 = *m;
  442. for (i__ = 1; i__ <= i__3; ++i__) {
  443. i__4 = i__ + j * c_dim1;
  444. i__5 = i__ + j * c_dim1;
  445. i__6 = i__ + l * a_dim1;
  446. q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
  447. q__2.i = temp.r * a[i__6].i + temp.i * a[
  448. i__6].r;
  449. q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
  450. .i + q__2.i;
  451. c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
  452. /* L230: */
  453. }
  454. }
  455. /* L240: */
  456. }
  457. /* L250: */
  458. }
  459. }
  460. } else if (conja) {
  461. if (conjb) {
  462. /* Form C := alpha*conjg( A' )*conjg( B' ) + beta*C. */
  463. i__1 = *n;
  464. for (j = 1; j <= i__1; ++j) {
  465. i__2 = *m;
  466. for (i__ = 1; i__ <= i__2; ++i__) {
  467. temp.r = 0.f, temp.i = 0.f;
  468. i__3 = *k;
  469. for (l = 1; l <= i__3; ++l) {
  470. r_cnjg(&q__3, &a[l + i__ * a_dim1]);
  471. r_cnjg(&q__4, &b[j + l * b_dim1]);
  472. q__2.r = q__3.r * q__4.r - q__3.i * q__4.i, q__2.i =
  473. q__3.r * q__4.i + q__3.i * q__4.r;
  474. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  475. temp.r = q__1.r, temp.i = q__1.i;
  476. /* L260: */
  477. }
  478. if (beta->r == 0.f && beta->i == 0.f) {
  479. i__3 = i__ + j * c_dim1;
  480. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  481. q__1.i = alpha->r * temp.i + alpha->i *
  482. temp.r;
  483. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  484. } else {
  485. i__3 = i__ + j * c_dim1;
  486. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  487. q__2.i = alpha->r * temp.i + alpha->i *
  488. temp.r;
  489. i__4 = i__ + j * c_dim1;
  490. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  491. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  492. c__[i__4].r;
  493. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  494. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  495. }
  496. /* L270: */
  497. }
  498. /* L280: */
  499. }
  500. } else {
  501. /* Form C := alpha*conjg( A' )*B' + beta*C */
  502. i__1 = *n;
  503. for (j = 1; j <= i__1; ++j) {
  504. i__2 = *m;
  505. for (i__ = 1; i__ <= i__2; ++i__) {
  506. temp.r = 0.f, temp.i = 0.f;
  507. i__3 = *k;
  508. for (l = 1; l <= i__3; ++l) {
  509. r_cnjg(&q__3, &a[l + i__ * a_dim1]);
  510. i__4 = j + l * b_dim1;
  511. q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
  512. q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
  513. .r;
  514. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  515. temp.r = q__1.r, temp.i = q__1.i;
  516. /* L290: */
  517. }
  518. if (beta->r == 0.f && beta->i == 0.f) {
  519. i__3 = i__ + j * c_dim1;
  520. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  521. q__1.i = alpha->r * temp.i + alpha->i *
  522. temp.r;
  523. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  524. } else {
  525. i__3 = i__ + j * c_dim1;
  526. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  527. q__2.i = alpha->r * temp.i + alpha->i *
  528. temp.r;
  529. i__4 = i__ + j * c_dim1;
  530. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  531. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  532. c__[i__4].r;
  533. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  534. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  535. }
  536. /* L300: */
  537. }
  538. /* L310: */
  539. }
  540. }
  541. } else {
  542. if (conjb) {
  543. /* Form C := alpha*A'*conjg( B' ) + beta*C */
  544. i__1 = *n;
  545. for (j = 1; j <= i__1; ++j) {
  546. i__2 = *m;
  547. for (i__ = 1; i__ <= i__2; ++i__) {
  548. temp.r = 0.f, temp.i = 0.f;
  549. i__3 = *k;
  550. for (l = 1; l <= i__3; ++l) {
  551. i__4 = l + i__ * a_dim1;
  552. r_cnjg(&q__3, &b[j + l * b_dim1]);
  553. q__2.r = a[i__4].r * q__3.r - a[i__4].i * q__3.i,
  554. q__2.i = a[i__4].r * q__3.i + a[i__4].i *
  555. q__3.r;
  556. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  557. temp.r = q__1.r, temp.i = q__1.i;
  558. /* L320: */
  559. }
  560. if (beta->r == 0.f && beta->i == 0.f) {
  561. i__3 = i__ + j * c_dim1;
  562. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  563. q__1.i = alpha->r * temp.i + alpha->i *
  564. temp.r;
  565. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  566. } else {
  567. i__3 = i__ + j * c_dim1;
  568. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  569. q__2.i = alpha->r * temp.i + alpha->i *
  570. temp.r;
  571. i__4 = i__ + j * c_dim1;
  572. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  573. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  574. c__[i__4].r;
  575. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  576. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  577. }
  578. /* L330: */
  579. }
  580. /* L340: */
  581. }
  582. } else {
  583. /* Form C := alpha*A'*B' + beta*C */
  584. i__1 = *n;
  585. for (j = 1; j <= i__1; ++j) {
  586. i__2 = *m;
  587. for (i__ = 1; i__ <= i__2; ++i__) {
  588. temp.r = 0.f, temp.i = 0.f;
  589. i__3 = *k;
  590. for (l = 1; l <= i__3; ++l) {
  591. i__4 = l + i__ * a_dim1;
  592. i__5 = j + l * b_dim1;
  593. q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
  594. .i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
  595. .i * b[i__5].r;
  596. q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
  597. temp.r = q__1.r, temp.i = q__1.i;
  598. /* L350: */
  599. }
  600. if (beta->r == 0.f && beta->i == 0.f) {
  601. i__3 = i__ + j * c_dim1;
  602. q__1.r = alpha->r * temp.r - alpha->i * temp.i,
  603. q__1.i = alpha->r * temp.i + alpha->i *
  604. temp.r;
  605. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  606. } else {
  607. i__3 = i__ + j * c_dim1;
  608. q__2.r = alpha->r * temp.r - alpha->i * temp.i,
  609. q__2.i = alpha->r * temp.i + alpha->i *
  610. temp.r;
  611. i__4 = i__ + j * c_dim1;
  612. q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
  613. .i, q__3.i = beta->r * c__[i__4].i + beta->i *
  614. c__[i__4].r;
  615. q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
  616. c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
  617. }
  618. /* L360: */
  619. }
  620. /* L370: */
  621. }
  622. }
  623. }
  624. return 0;
  625. /* End of CGEMM . */
  626. } /* cgemm_ */