cmmult.c 871 B

123456789101112131415161718192021222324252627282930
  1. /* cmmult.c CCMATH mathematics library source code.
  2. *
  3. * Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
  4. * This code may be redistributed under the terms of the GNU library
  5. * public license (LGPL). ( See the lgpl.license file for details.)
  6. * ------------------------------------------------------------------------
  7. */
  8. #include <stdlib.h>
  9. #include "ccmath.h"
  10. void cmmult(Cpx * cm, Cpx * a, Cpx * b, int n, int m, int l)
  11. {
  12. Cpx z, *q0, *p, *q;
  13. int i, j, k;
  14. q0 = (Cpx *) calloc(m, sizeof(Cpx));
  15. for (i = 0; i < l; ++i, ++cm) {
  16. for (k = 0, p = b + i; k < m; p += l)
  17. q0[k++] = *p;
  18. for (j = 0, p = a, q = cm; j < n; ++j, q += l) {
  19. for (k = 0, z.re = z.im = 0.; k < m; ++k, ++p) {
  20. z.re += p->re * q0[k].re - p->im * q0[k].im;
  21. z.im += p->im * q0[k].re + p->re * q0[k].im;
  22. }
  23. *q = z;
  24. }
  25. }
  26. free(q0);
  27. }