1 #ifndef __SDR_FFTPLAN_NATIVE_HH__
2 #define __SDR_FFTPLAN_NATIVE_HH__
10 template <
class Scalar>
26 err <<
"Can not construct FFT plan: input & output buffers are of different size!";
31 err <<
"Can not construct FFT plan: input or output buffer is empty!";
35 if (
_N != std::pow(2.0, std::log2(
_N))) {
36 err <<
"Can not construct FFT plan: input and output buffer length must be a power of 2!";
41 int dir_fac = (dir==FFT::FORWARD) ? 1 : -1;
42 for (
size_t i=0; i<
_N; i++) {
54 _calc(
reinterpret_cast< std::complex<Scalar>
>(
_in.
data()),
55 reinterpret_cast< std::complex<Scalar>
>(
_out.
data()),
_N, 1);
60 void _calc(std::complex<Scalar> *a, std::complex<Scalar> *b,
size_t N,
size_t stride) {
62 if (1 == N) { b[0] = a[0];
return; }
64 _calc(a, b, N/2, 2*stride);
65 _calc(a+stride, b+N/2, N/2, 2*stride);
67 for (
size_t i=0; i<N/2; i++) {
68 std::complex<SScalar> tmp = b[i];
88 #endif // __SDR_FFTPLAN_NATIVE_HH__
virtual ~FFTPlan()
Destructor.
Definition: fftplan_native.hh:48
void operator()()
Performs the FFT.
Definition: fftplan_native.hh:53
Direction
Direction type.
Definition: fftplan.hh:17
Definition: autocast.hh:8
bool isEmpty() const
Returns true if the buffer is invalid/empty.
Definition: buffer.hh:77
Buffer< std::complex< Scalar > > _in
The input buffer.
Definition: fftplan_native.hh:79
size_t size() const
Returns the number of elements of type T in this buffer.
Definition: buffer.hh:166
char * data() const
Returns the pointer to the data of the buffer view.
Definition: buffer.hh:69
Buffer< std::complex< Scalar > > _out
The output buffer.
Definition: fftplan_native.hh:81
void _calc(std::complex< Scalar > *a, std::complex< Scalar > *b, size_t N, size_t stride)
Actual FFT implmenetation.
Definition: fftplan_native.hh:60
Buffer< std::complex< SScalar > > _lut
The exp(-i 2 pi k / N) look-up table.
Definition: fftplan_native.hh:83
The configuration error class.
Definition: exception.hh:24
Traits< Scalar >::SScalar SScalar
The super-scalar of the input type.
Definition: fftplan_native.hh:15
void unref()
Dereferences the buffer.
Definition: buffer.cc:63
FFTPlan(const Buffer< std::complex< Scalar > > &in, const Buffer< std::complex< Scalar > > &out, FFT::Direction dir)
Constructs a FFT plan for the input and output buffers.
Definition: fftplan_native.hh:19
Forward declaration of type tratis template.
Definition: traits.hh:20
A typed buffer.
Definition: buffer.hh:111
size_t _N
FFT size, needs to be a power of 2.
Definition: fftplan_native.hh:77