🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

38 lines
1.3 KiB

  1. #ifndef ALCOMPLEX_H
  2. #define ALCOMPLEX_H
  3. #include <complex>
  4. #include "alspan.h"
  5. /**
  6. * Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is
  7. * FFT and 1 is inverse FFT. Applies the Discrete Fourier Transform (DFT) to
  8. * the data supplied in the buffer, which MUST BE power of two.
  9. */
  10. void complex_fft(const al::span<std::complex<double>> buffer, const double sign);
  11. /**
  12. * Calculate the frequency-domain response of the time-domain signal in the
  13. * provided buffer, which MUST BE power of two.
  14. */
  15. inline void forward_fft(const al::span<std::complex<double>> buffer)
  16. { complex_fft(buffer, -1.0); }
  17. /**
  18. * Calculate the time-domain signal of the frequency-domain response in the
  19. * provided buffer, which MUST BE power of two.
  20. */
  21. inline void inverse_fft(const al::span<std::complex<double>> buffer)
  22. { complex_fft(buffer, 1.0); }
  23. /**
  24. * Calculate the complex helical sequence (discrete-time analytical signal) of
  25. * the given input using the discrete Hilbert transform (In-place algorithm).
  26. * Fills the buffer with the discrete-time analytical signal stored in the
  27. * buffer. The buffer is an array of complex numbers and MUST BE power of two,
  28. * and the imaginary components should be cleared to 0.
  29. */
  30. void complex_hilbert(const al::span<std::complex<double>> buffer);
  31. #endif /* ALCOMPLEX_H */