fix: fix gcc compile issue
This commit is contained in:
@@ -11,7 +11,7 @@ namespace yyccbench::carton::fft {
|
|||||||
using TIndex = size_t;
|
using TIndex = size_t;
|
||||||
using TFloat = float;
|
using TFloat = float;
|
||||||
using TComplex = std::complex<TFloat>;
|
using TComplex = std::complex<TFloat>;
|
||||||
template<size_t N>
|
template<TIndex N>
|
||||||
using TFft = FFT::Fft<TIndex, TFloat, N>;
|
using TFft = FFT::Fft<TIndex, TFloat, N>;
|
||||||
|
|
||||||
constexpr TIndex FFT_POINTS = 1024u;
|
constexpr TIndex FFT_POINTS = 1024u;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#define NS_YYCC_BINSTORE_TYPES ::yycc::carton::binstore::types
|
#define NS_YYCC_BINSTORE_TYPES ::yycc::carton::binstore::types
|
||||||
@@ -221,3 +222,5 @@ namespace yycc::carton::binstore::serdes {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace yycc::carton::binstore::serdes
|
} // namespace yycc::carton::binstore::serdes
|
||||||
|
|
||||||
|
#undef NS_YYCC_BINSTORE_TYPES
|
||||||
|
|||||||
@@ -24,19 +24,19 @@ namespace yycc::carton::fft {
|
|||||||
// We use std::has_single_bit() to check whether given number is an integral power of 2.
|
// We use std::has_single_bit() to check whether given number is an integral power of 2.
|
||||||
// And use (std::bit_width() - 1) to get the exponent of given number based on 2.
|
// And use (std::bit_width() - 1) to get the exponent of given number based on 2.
|
||||||
|
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
struct validate_args {
|
struct validate_args {
|
||||||
private:
|
private:
|
||||||
static constexpr bool is_unsigned_int = std::is_unsigned_v<TIndex> && std::is_integral_v<TIndex>;
|
static constexpr bool is_unsigned_int = std::is_unsigned_v<TIndex> && std::is_integral_v<TIndex>;
|
||||||
static constexpr bool is_float_point = std::is_floating_point_v<TFloat>;
|
static constexpr bool is_float_point = std::is_floating_point_v<TFloat>;
|
||||||
static constexpr bool n_is_pow_2 = std::has_single_bit<TIndex>(static_cast<TIndex>(N)) && N >= static_cast<TIndex>(2);
|
static constexpr bool n_is_pow_2 = std::has_single_bit<TIndex>(static_cast<TIndex>(VN)) && VN >= static_cast<TIndex>(2);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = is_unsigned_int && is_float_point && n_is_pow_2;
|
static constexpr bool value = is_unsigned_int && is_float_point && n_is_pow_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
inline constexpr bool validate_args_v = validate_args<TIndex, TFloat, N>::value;
|
inline constexpr bool validate_args_v = validate_args<TIndex, TFloat, VN>::value;
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
||||||
@@ -44,11 +44,11 @@ namespace yycc::carton::fft {
|
|||||||
|
|
||||||
enum class WindowType { HanningWindow };
|
enum class WindowType { HanningWindow };
|
||||||
|
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
requires util::validate_args_v<TIndex, TFloat, N>
|
requires util::validate_args_v<TIndex, TFloat, VN>
|
||||||
class Window {
|
class Window {
|
||||||
private:
|
private:
|
||||||
static constexpr TIndex N = N;
|
static constexpr TIndex N = VN;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Window(WindowType win_type) : window_type(win_type), window_data(nullptr) {
|
Window(WindowType win_type) : window_type(win_type), window_data(nullptr) {
|
||||||
@@ -102,12 +102,12 @@ namespace yycc::carton::fft {
|
|||||||
|
|
||||||
#pragma region FFT
|
#pragma region FFT
|
||||||
|
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
requires util::validate_args_v<TIndex, TFloat, N>
|
requires util::validate_args_v<TIndex, TFloat, VN>
|
||||||
struct FftProperties {
|
struct FftProperties {
|
||||||
public:
|
public:
|
||||||
using TComplex = std::complex<TFloat>;
|
using TComplex = std::complex<TFloat>;
|
||||||
static constexpr TIndex N = static_cast<TIndex>(N);
|
static constexpr TIndex N = static_cast<TIndex>(VN);
|
||||||
static constexpr TIndex M = static_cast<TIndex>(std::bit_width<TIndex>(N) - 1);
|
static constexpr TIndex M = static_cast<TIndex>(std::bit_width<TIndex>(N) - 1);
|
||||||
static constexpr TIndex HALF_POINT = N >> static_cast<TIndex>(1);
|
static constexpr TIndex HALF_POINT = N >> static_cast<TIndex>(1);
|
||||||
};
|
};
|
||||||
@@ -119,11 +119,11 @@ namespace yycc::carton::fft {
|
|||||||
* @tparam TFloat
|
* @tparam TFloat
|
||||||
* @tparam N
|
* @tparam N
|
||||||
*/
|
*/
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
requires util::validate_args_v<TIndex, TFloat, N>
|
requires util::validate_args_v<TIndex, TFloat, VN>
|
||||||
class Fft {
|
class Fft {
|
||||||
private:
|
private:
|
||||||
using TProperties = FftProperties<TIndex, TFloat, N>;
|
using TProperties = FftProperties<TIndex, TFloat, VN>;
|
||||||
using TComplex = TProperties::TComplex;
|
using TComplex = TProperties::TComplex;
|
||||||
static constexpr TIndex N = TProperties::N;
|
static constexpr TIndex N = TProperties::N;
|
||||||
static constexpr TIndex M = TProperties::M;
|
static constexpr TIndex M = TProperties::M;
|
||||||
@@ -201,12 +201,12 @@ namespace yycc::carton::fft {
|
|||||||
* @tparam N
|
* @tparam N
|
||||||
* @warning This class is \b NOT thread safe. Please use different instance in different thread.
|
* @warning This class is \b NOT thread safe. Please use different instance in different thread.
|
||||||
*/
|
*/
|
||||||
template<typename TIndex, typename TFloat, size_t N>
|
template<typename TIndex, typename TFloat, TIndex VN>
|
||||||
requires util::validate_args_v<TIndex, TFloat, N>
|
requires util::validate_args_v<TIndex, TFloat, VN>
|
||||||
class FriendlyFft {
|
class FriendlyFft {
|
||||||
private:
|
private:
|
||||||
using UnderlyingFft = Fft<TIndex, TFloat, N>;
|
using UnderlyingFft = Fft<TIndex, TFloat, VN>;
|
||||||
using TProperties = FftProperties<TIndex, TFloat, N>;
|
using TProperties = FftProperties<TIndex, TFloat, VN>;
|
||||||
using TComplex = TProperties::TComplex;
|
using TComplex = TProperties::TComplex;
|
||||||
static constexpr TIndex N = TProperties::N;
|
static constexpr TIndex N = TProperties::N;
|
||||||
static constexpr TIndex M = TProperties::M;
|
static constexpr TIndex M = TProperties::M;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace yycctest::carton::fft {
|
|||||||
using TIndex = size_t;
|
using TIndex = size_t;
|
||||||
using TFloat = float;
|
using TFloat = float;
|
||||||
using TComplex = std::complex<TFloat>;
|
using TComplex = std::complex<TFloat>;
|
||||||
template<size_t N>
|
template<TIndex N>
|
||||||
using TFft = FFT::Fft<TIndex, TFloat, N>;
|
using TFft = FFT::Fft<TIndex, TFloat, N>;
|
||||||
|
|
||||||
// YYC MARK:
|
// YYC MARK:
|
||||||
@@ -18,7 +18,7 @@ namespace yycctest::carton::fft {
|
|||||||
constexpr TFloat TOLERANCE = static_cast<TFloat>(0.0003);
|
constexpr TFloat TOLERANCE = static_cast<TFloat>(0.0003);
|
||||||
//constexpr TFloat tolerance = std::numeric_limits<TFloat>::epsilon();
|
//constexpr TFloat tolerance = std::numeric_limits<TFloat>::epsilon();
|
||||||
|
|
||||||
template<size_t N>
|
template<TIndex N>
|
||||||
static void test_fft(const std::vector<TFloat>& real_src, const std::vector<TComplex>& dst) {
|
static void test_fft(const std::vector<TFloat>& real_src, const std::vector<TComplex>& dst) {
|
||||||
// check given data size
|
// check given data size
|
||||||
ASSERT_EQ(real_src.size(), N);
|
ASSERT_EQ(real_src.size(), N);
|
||||||
|
|||||||
Reference in New Issue
Block a user