hmgen.c 729 B

123456789101112131415161718192021222324252627282930
  1. /* hmgen.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 hmgen(Cpx * h, double *ev, Cpx * u, int n)
  11. {
  12. Cpx *v, *p;
  13. int i, j;
  14. double e;
  15. v = (Cpx *) calloc(n * n, sizeof(Cpx));
  16. cmcpy(v, u, n * n);
  17. hconj(v, n);
  18. for (i = 0, p = v; i < n; ++i) {
  19. for (j = 0, e = ev[i]; j < n; ++j, ++p) {
  20. p->re *= e;
  21. p->im *= e;
  22. }
  23. }
  24. cmmul(h, u, v, n);
  25. free(v);
  26. }