libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmComplexTypes.c 787B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplex_t* x0, const cmComplexR_t* x1, unsigned n )
  2. {
  3. unsigned i;
  4. for(i=0; i<n; ++i)
  5. {
  6. cmReal_t ab = x0[i].r * x1[i].r;
  7. cmReal_t bd = x0[i].i * x1[i].i;
  8. cmReal_t bc = x0[i].i * x1[i].r;
  9. cmReal_t ad = x0[i].r * x1[i].i;
  10. y[i].r = ab - bd;
  11. y[i].i = bc + ad;
  12. }
  13. }
  14. void cmVOCR_Abs( cmReal_t* y, const cmComplexR_t* x, unsigned n )
  15. {
  16. for(i=0; i<n; ++i)
  17. y[i] = cmAbsR(x[i]);
  18. }
  19. void cmVOCR_MultR_VV( cmComplexR_t* y, const cmReal_t* x, unsigned n )
  20. {
  21. unsigned i;
  22. for(i=0; i<n; ++i)
  23. {
  24. y[i].r *= x[i];
  25. y[i].i *= x[i];
  26. }
  27. }
  28. void cmVOCR_DivR_VV( cmComplexR_t* y, const cmReal_t* x, unsigned n )
  29. {
  30. unsigned i;
  31. for(i=0; i<n; ++i)
  32. {
  33. y[i].r /= x[i];
  34. y[i].i /= x[i];
  35. }
  36. }