eDSP
0.0.1
A cross-platform DSP library written in C++.
|
Enumerations | |
enum | CorrelationScale { CorrelationScale::None, CorrelationScale::Biased, CorrelationScale::Unbiased } |
The ScaleOpt enum defines the normalization option of the correlation function. More... | |
enum | SpectralScale { SpectralScale::Linear, SpectralScale::Logarithmic } |
The SpectralScale enum represent the scale used to represent the power spectral density. More... | |
Functions | |
template<typename InputIt , typename OutputIt , typename RAllocator = std::allocator<meta::value_type_t<InputIt>>, typename CAllocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>> | |
void | cepstrum (InputIt first, InputIt last, OutputIt d_first) |
Computes the cepstrum of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt , typename RAllocator = std::allocator<meta::value_type_t<InputIt>>, typename CAllocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>> | |
void | conv (InputIt first1, InputIt last1, InputIt first2, OutputIt d_first) |
Computes the convolution between the range [first1, last1) and the range [first2, last2), and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt , typename RAllocator = std::allocator<meta::value_type_t<InputIt>>, typename CAllocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>> | |
void | xcorr (InputIt first, InputIt last, OutputIt d_first, CorrelationScale scale=CorrelationScale::None) |
Computes the autocorrelation of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt , typename RAllocator = std::allocator<meta::value_type_t<InputIt>>, typename CAllocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>> | |
void | xcorr (InputIt first1, InputIt last1, InputIt first2, OutputIt d_first, CorrelationScale scale=CorrelationScale::None) |
Computes the correlation between the range [first1, last1) and the [first2, last2), and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | dct (InputIt first, InputIt last, OutputIt d_first) |
Computes the Discrete-Cosine-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | idct (InputIt first, InputIt last, OutputIt d_first) |
Computes the Inverse-Discrete-Cosine-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename Integer > | |
constexpr Integer | make_fft_size (Integer real_size) noexcept |
Computes the expected DFT size for a real-to-complex DFT transform. More... | |
template<typename Integer > | |
constexpr Integer | make_ifft_size (Integer complex_size) noexcept |
Computes the expected IDFT size for a complex-to-real IDFT transform. More... | |
template<typename InputIt , typename OutputIt > | |
void | cdft (InputIt first, InputIt last, OutputIt d_first) |
Computes the complex-to-complex Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | cidft (InputIt first, InputIt last, OutputIt d_first) |
Computes the complex-to-complex Inverse-Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | dft (InputIt first, InputIt last, OutputIt d_first) |
Computes the real-to-complex Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | idft (InputIt first, InputIt last, OutputIt d_first) |
Computes the complex-to-real Inverse-Discrete-Fourier-Transform of the complex range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt > | |
void | hartley (InputIt first, InputIt last, OutputIt d_first) |
Computes the Discrete-Hartley-Transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt , typename Allocator = std::allocator<std::complex<meta::value_type_t<InputIt>>>> | |
void | hilbert (InputIt first, InputIt last, OutputIt d_first) |
Computes the Discrete-Time analytic signal using Hilbert transform of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
template<typename InputIt , typename OutputIt , typename Allocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>> | |
void | periodogram (InputIt first, InputIt last, OutputIt d_first, SpectralScale scale) |
Computes the periodogram of the range [first, last) and stores the result in another range, beginning at d_first. More... | |
|
strong |
|
strong |
|
inline |
Computes the complex-to-complex Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
The DFT transforms a sequence of \( N \) complex numbers \( x_n \) into another sequence of complex numbers \( X_k \):
\[ {\displaystyle {\begin{aligned}X_{k}&=\sum _{n=0}^{N-1}x_{n}\cdot e^{-{\frac {2\pi i}{N}}kn}\\&=\sum _{n=0}^{N-1}x_{n}\cdot [\cos(2\pi kn/N)-i\cdot \sin(2\pi kn/N)],\end{aligned}}} \]
T | Underlying type to perform the arithmetic operations (float, double or long double). |
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the cepstrum of the range [first, last) and stores the result in another range, beginning at d_first.
The Cepstrum is the result of taking the inverse Fourier transform (IDFT) of the logarithm of the estimated spectrum of a signal:
\[ {\displaystyle C_K =\left|{\mathcal {F}}^{-1}\left\{\log \left(\left|{\mathcal {F}}\{f(t)\}\right|^{2}\right)\right\}\right|^{2}} \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the complex-to-complex Inverse-Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
The IDFT transforms a sequence of \( N \) complex numbers \( X_k \) into another sequence of complex numbers \( x_n \):
\[ {\displaystyle x_{n}={\frac {1}{N}}\sum _{k=0}^{N-1}X_{k}e^{{\frac {2\pi i}{N}}kn}\quad \quad n=0,\dots ,N-1.} \]
T | Underlying type to perform the arithmetic operations (float, double or long double). |
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the convolution between the range [first1, last1) and the range [first2, last2), and stores the result in another range, beginning at d_first.
The result of conv can be interpreted as an estimate of how the shape of one range is modified by the other. It is defined as:
\[ {\displaystyle (f*g)[n]=\sum _{m=-M}^{M}f[n-m]g[m].} \]
first1 | Input iterator defining the beginning of the first input range. |
last1 | Input iterator defining the ending of the first input range. |
first2 | Input iterator defining the beginning of the second input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the Discrete-Cosine-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
The DCT-II is computed as follows:
\[ {\displaystyle X_{k}=\sum _{n=0}^{N-1}{x_{n}\cos \left[{\frac {\pi }{N}}\left(n+{\frac {1}{2}}\right)k\right]}} \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
void edsp::spectral::dft | ( | InputIt | first, |
InputIt | last, | ||
OutputIt | d_first | ||
) |
Computes the real-to-complex Discrete-Fourier-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
When the input data are purely real number, the DFT output satisfies the “Hermitian” redundancy: \( F(i) \) is the conjugate of \( F(N - i) \), where \( N \) is the size of the DFT. To benefit from this property (speed and space advantages), the input and output arrays are of different sizes and types: the input is \( N \) real numbers, while the output is \( \frac{N}{2} + 1 \) complex numbers (the non-redundant outputs) where the division is rounded down.
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the Discrete-Hartley-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
The DHT transforms a sequence of \( N \) real numbers \( x_n \) into another sequence of real numbers \( H_k \):
\[ {\displaystyle H_{k}=\sum _{n=0}^{N-1}x_{n}\operatorname {cas} \left({\frac {2\pi }{N}}nk\right)=\sum _{n=0}^{N-1}x_{n} \left[\cos \left({\frac {2\pi }{N}}nk\right)+\sin \left({\frac {2\pi }{N}}nk\right)\right]\quad \quad k=0,\dots ,N-1} \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the Discrete-Time analytic signal using Hilbert transform of the range [first, last) and stores the result in another range, beginning at d_first.
The Discrete-time analytic is the complex helical sequence obtained from a real data sequence. The analytic signal \( A_k = A_r + iA_i \) has a real part, \( A_r \), which is the original data, and an imaginary part, \( A_i \), which contains the Hilbert transform. The imaginary part is a version of the original real sequence with a 90° phase shift.
The Hilbert transform is computed as follows:
\[ {\displaystyle {\widehat {s}}(t)={\mathcal {H}}\{s\}(t)=(h*s)(t)={\frac {1}{\pi }}\int _{-\infty }^{\infty }{\frac {s(\tau )}{t-\tau }}\,d\tau .\,} \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
inline |
Computes the Inverse-Discrete-Cosine-Transform of the range [first, last) and stores the result in another range, beginning at d_first.
The IDCT-II is computed as follows:
\[ {\displaystyle X_{k}={\frac {1}{2}}x_{0}+\sum _{n=1}^{N-1}{x_{n}\cos \left[{\frac {\pi }{N}}n\left(k+{\frac {1}{2}}\right)\right]}} \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
void edsp::spectral::idft | ( | InputIt | first, |
InputIt | last, | ||
OutputIt | d_first | ||
) |
Computes the complex-to-real Inverse-Discrete-Fourier-Transform of the complex range [first, last) and stores the result in another range, beginning at d_first.
When the input data are purely real number, the DFT output satisfies the “Hermitian” redundancy: \( F(i) \) is the conjugate of \( F(N - i) \), where \( N \) is the size of the DFT. To benefit from this property (speed and space advantages), the input and output arrays are of different sizes and types: the input is \( N \) real numbers, while the output is \( \frac{N}{2} + 1 \) complex numbers (the non-redundant outputs) where the division is rounded down.
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
|
noexcept |
Computes the expected DFT size for a real-to-complex DFT transform.
|
noexcept |
Computes the expected IDFT size for a complex-to-real IDFT transform.
|
inline |
Computes the periodogram of the range [first, last) and stores the result in another range, beginning at d_first.
The periodogram is an estimate of the spectral density of a signal.
\[ {\displaystyle S\left({\tfrac {k}{NT}}\right)=\left|\sum _{n}x_{N}[n]\cdot e^{-i2\pi {\frac {kn}{N}}}\right|^{2}} \]
where T, is the inverse of the sample rate \( f_s \).
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
scale | Scale to be used in the output |
|
inline |
Computes the autocorrelation of the range [first, last) and stores the result in another range, beginning at d_first.
The result of xcorr can be interpreted as an estimate of the correlation between two random sequences or as the deterministic correlation between two deterministic signals.
\[ R_{xx}(k) = \sum_{n=-\infty}^{\infty} x(n)x(n-k) \]
first | Input iterator defining the beginning of the input range. |
last | Input iterator defining the ending of the input range. |
d_first | Output iterator defining the beginning of the destination range. |
scale | Scale factor to use. |
|
inline |
Computes the correlation between the range [first1, last1) and the [first2, last2), and stores the result in another range, beginning at d_first.
The result of xcorr can be interpreted as an estimate of the correlation between two random sequences or as the deterministic correlation between two deterministic signals.
\[ R_{x_1 x_2}(k) = \sum_{n=-\infty}^{\infty} x_1(n)x_2(n-k) \]
first1 | Input iterator defining the beginning of the first input range. |
last1 | Input iterator defining the ending of the first input range. |
first2 | Input iterator defining the beginning of the second input range. |
d_first | Output iterator defining the beginning of the destination range. |
scale | Scale factor to use. |