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 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #include "cmPrefix.h"
  4. #include "cmGlobal.h"
  5. #include "cmFloatTypes.h"
  6. #include "cmComplexTypes.h"
  7. void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplexS_t* x0, const cmComplexR_t* x1, unsigned n )
  8. {
  9. unsigned i;
  10. for(i=0; i<n; ++i)
  11. {
  12. y[i] = x0[i] * x1[i];
  13. /*
  14. cmReal_t ab = x0[i].r * x1[i].r;
  15. cmReal_t bd = x0[i].i * x1[i].i;
  16. cmReal_t bc = x0[i].i * x1[i].r;
  17. cmReal_t ad = x0[i].r * x1[i].i;
  18. y[i].r = ab - bd;
  19. y[i].i = bc + ad;
  20. */
  21. }
  22. }
  23. void cmVOCR_MultVFV( cmComplexR_t* y, const float* x, unsigned n )
  24. {
  25. unsigned i;
  26. for(i=0; i<n; ++i)
  27. {
  28. y[i] *= x[i];
  29. }
  30. }
  31. void cmVOCR_DivVFV( cmComplexR_t* y, const float* x, unsigned n )
  32. {
  33. unsigned i;
  34. for(i=0; i<n; ++i)
  35. {
  36. y[i] /= x[i];
  37. }
  38. }
  39. void cmVOCR_Abs( cmSample_t* y, const cmComplexR_t* x, unsigned n )
  40. {
  41. unsigned i;
  42. for(i=0; i<n; ++i)
  43. y[i] = (cmSample_t)cmCabsR(x[i]);
  44. }
  45. void cmVOCR_DivR_VV( cmComplexR_t* y, const cmReal_t* x, unsigned n )
  46. {
  47. unsigned i;
  48. for(i=0; i<n; ++i)
  49. {
  50. y[i] /= x[i];
  51. //y[i].r /= x[i];
  52. //y[i].i /= x[i];
  53. }
  54. }