cvmul.c 868 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* cvmul.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 "ccmath.h"
  9. void cvmul(Cpx * u, Cpx * a, Cpx * v, int n)
  10. {
  11. Cpx *q;
  12. int i, j;
  13. for (i = 0; i < n; ++i, ++u) {
  14. u->re = u->im = 0.;
  15. for (j = 0, q = v; j < n; ++j, ++a, ++q) {
  16. u->re += a->re * q->re - a->im * q->im;
  17. u->im += a->im * q->re + a->re * q->im;
  18. }
  19. }
  20. }
  21. Cpx cvnrm(Cpx * u, Cpx * v, int n)
  22. {
  23. int k;
  24. Cpx z;
  25. z.re = z.im = 0.;
  26. for (k = 0; k < n; ++k, ++u, ++v) {
  27. z.re += u->re * v->re + u->im * v->im;
  28. z.im += u->re * v->im - u->im * v->re;
  29. }
  30. return z;
  31. }