utrnhm.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* utrnhm.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 utrnhm(Cpx * hm, Cpx * a, Cpx * b, int n)
  11. {
  12. Cpx z, *q0, *p, *s, *t;
  13. int i, j, k;
  14. q0 = (Cpx *) calloc(n, sizeof(Cpx));
  15. for (i = 0; i < n; ++i) {
  16. for (j = 0, t = b; j < n; ++j) {
  17. z.re = z.im = 0.;
  18. for (k = 0, s = a + i * n; k < n; ++k, ++s, ++t) {
  19. z.re += t->re * s->re + t->im * s->im;
  20. z.im += t->im * s->re - t->re * s->im;
  21. }
  22. q0[j] = z;
  23. }
  24. for (j = 0, p = hm + i, t = a; j <= i; ++j, p += n) {
  25. z.re = z.im = 0.;
  26. for (k = 0, s = q0; k < n; ++k, ++t, ++s) {
  27. z.re += t->re * s->re - t->im * s->im;
  28. z.im += t->im * s->re + t->re * s->im;
  29. }
  30. *p = z;
  31. if (j < i) {
  32. z.im = -z.im;
  33. hm[i * n + j] = z;
  34. }
  35. }
  36. }
  37. free(q0);
  38. }