dsplib
1.1.0
C++ DSP library for MATLAB-like coding
Loading...
Searching...
No Matches
include
dsplib
fft.h
1
#pragma once
2
3
#include <dsplib/array.h>
4
5
#include <memory>
6
7
namespace
dsplib {
8
12
class
FftPlanC
13
{
14
public
:
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
42
class
FftPlanR
43
{
44
public
:
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
65
std::shared_ptr<
FftPlanC
> fft_plan_c(
int
n);
66
71
std::shared_ptr<
FftPlanR
> fft_plan_r(
int
n);
72
79
arr_cmplx
fft(
span_t
<
cmplx_t
> x);
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
84
arr_cmplx
fft(
span_t
<
cmplx_t
> x,
int
n);
85
86
//Fast Fourier Transform (real)
87
arr_cmplx
fft(
span_t
<real_t> x);
88
arr_cmplx
fft(
span_t
<real_t> x,
int
n);
89
90
arr_cmplx
rfft(
span_t
<real_t> x);
// equal `fft(x)`
91
arr_cmplx
rfft(
span_t
<real_t> x,
int
n);
// equal `fft(x, n)`
92
93
}
// namespace dsplib
dsplib::FftPlanC
FFT c2c base class.
Definition
fft.h:13
dsplib::FftPlanC::solve
virtual void solve(span_t< cmplx_t > x, mut_span_t< cmplx_t > r) const
c2c FFT solve
Definition
fft.h:24
dsplib::FftPlanR
FFT r2c base class.
Definition
fft.h:43
dsplib::FftPlanR::solve
virtual void solve(span_t< real_t > x, mut_span_t< cmplx_t > r) const
r2c FFT solve
Definition
fft.h:54
dsplib::base_array< cmplx_t >
dsplib::inplace_span_t
Definition
span.h:465
dsplib::mut_span_t
Definition
span.h:27
dsplib::span_t
Definition
span.h:295
dsplib::cmplx_t
Definition
types.h:102
Generated by
1.9.8