dsplib 1.1.0
C++ DSP library for MATLAB-like coding
Loading...
Searching...
No Matches
fft.h
1#pragma once
2
3#include <dsplib/array.h>
4
5#include <memory>
6
7namespace dsplib {
8
13{
14public:
15 virtual ~FftPlanC() = default;
16
17 [[nodiscard]] virtual arr_cmplx solve(span_t<cmplx_t> x) const = 0;
18
24 virtual void solve(span_t<cmplx_t> x, mut_span_t<cmplx_t> r) const {
25 r = this->solve(x);
26 }
27
28 //inplace FFT implementation
29 virtual void solve(inplace_cmplx inp) const {
30 //default non optimal implementation with temp array
31 auto x = inp.get();
32 const auto y = this->solve(x);
33 x.assign(y);
34 }
35
36 [[nodiscard]] virtual int size() const noexcept = 0;
37};
38
43{
44public:
45 virtual ~FftPlanR() = default;
46
47 [[nodiscard]] virtual arr_cmplx solve(span_t<real_t> x) const = 0;
48
54 virtual void solve(span_t<real_t> x, mut_span_t<cmplx_t> r) const {
55 r = this->solve(x);
56 }
57
58 [[nodiscard]] virtual int size() const noexcept = 0;
59};
60
65std::shared_ptr<FftPlanC> fft_plan_c(int n);
66
71std::shared_ptr<FftPlanR> fft_plan_r(int n);
72
80
81//n-point DFT
82// if x.size() is less than n, then X is padded with trailing zeros to length n
83// if x.size() is greater than n, then x is truncated to length n
84arr_cmplx fft(span_t<cmplx_t> x, int n);
85
86//Fast Fourier Transform (real)
87arr_cmplx fft(span_t<real_t> x);
88arr_cmplx fft(span_t<real_t> x, int n);
89
90arr_cmplx rfft(span_t<real_t> x); // equal `fft(x)`
91arr_cmplx rfft(span_t<real_t> x, int n); // equal `fft(x, n)`
92
93} // namespace dsplib
FFT c2c base class.
Definition fft.h:13
virtual void solve(span_t< cmplx_t > x, mut_span_t< cmplx_t > r) const
c2c FFT solve
Definition fft.h:24
FFT r2c base class.
Definition fft.h:43
virtual void solve(span_t< real_t > x, mut_span_t< cmplx_t > r) const
r2c FFT solve
Definition fft.h:54
Definition span.h:465
Definition span.h:27
Definition span.h:295
Definition types.h:102