diff options
author | dario mambro <dario.mambro@gmail.com> | 2020-03-30 05:50:26 +0200 |
---|---|---|
committer | dario mambro <dario.mambro@gmail.com> | 2020-03-30 05:50:26 +0200 |
commit | a1cfad4a794b903ed970212080784ea75b8ceeef (patch) | |
tree | 8c5d23425da98c008611a2feca166d5712dbe7cb | |
parent | 1c193e9c3d4a16a8430a685a3ab6950bd92dc2d5 (diff) | |
download | pffft-a1cfad4a794b903ed970212080784ea75b8ceeef.tar.gz |
optional c++11 AlignedVector alias
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | pffft.hpp | 17 | ||||
-rw-r--r-- | test_pffft.cpp | 12 |
3 files changed, 34 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 75f787c..1d957b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,12 @@ add_executable( test_pffft_cpp test_pffft.cpp ) target_compile_definitions(test_pffft_cpp PRIVATE _USE_MATH_DEFINES) target_link_libraries( test_pffft_cpp PFFFT ${ASANLIB} ) +add_executable( test_pffft_cpp_11 test_pffft.cpp ) +target_compile_definitions(test_pffft_cpp_11 PRIVATE _USE_MATH_DEFINES) +target_link_libraries( test_pffft_cpp_11 PFFFT ${ASANLIB} ) + +set_property(TARGET test_pffft_cpp_11 PROPERTY CXX_STANDARD 11) +set_property(TARGET test_pffft_cpp_11 PROPERTY CXX_STANDARD_REQUIRED ON) add_executable(test_pffastconv test_pffastconv.c ) target_compile_definitions(test_pffastconv PRIVATE _USE_MATH_DEFINES) @@ -52,6 +52,12 @@ template<typename T> class Setup; } +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) + +template<typename T> +using AlignedVector = typename std::vector< T, PFAlloc<T> > ; + +#endif // T can be float, double, std::complex<float> or std::complex<double> template<typename T> @@ -61,10 +67,21 @@ public: typedef typename Setup<T>::Scalar Scalar; typedef T value_type; +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) + + using ValueVector = AlignedVector<T>; + using ComplexVector = AlignedVector<std::complex<Scalar>>; + using InternalLayoutVector = AlignedVector<Scalar>; + +#else + typedef std::vector< T, PFAlloc<T> > ValueVector; typedef std::vector< std::complex<Scalar>, PFAlloc< std::complex<Scalar> > > ComplexVector; typedef std::vector< Scalar, PFAlloc<Scalar> > InternalLayoutVector; +#endif + + // static retrospection functions static bool isComplexTransform() { return sizeof(T) != sizeof(Scalar); } diff --git a/test_pffft.cpp b/test_pffft.cpp index 29cecbb..08dbdaf 100644 --- a/test_pffft.cpp +++ b/test_pffft.cpp @@ -77,12 +77,22 @@ Ttest(int N, bool useOrdered) Fft fft = Fft(N); // instantiate and prepareLength() for length N - // with C++11 and auto - this gets a bit easier +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) + + pffft::AlignedVector<T> X = fft.valueVector(); // for X = input vector + pffft::AlignedVector<std::complex<Scalar>> Y = fft.spectrumVector(); // for Y = forward(X) + pffft::AlignedVector<Scalar> R = fft.internalLayoutVector(); // for R = forwardInternalLayout(X) + pffft::AlignedVector<T> Z = fft.valueVector(); // for Z = inverse(Y) = inverse( forward(X) ) + // or Z = inverseInternalLayout(R) +#else + +// with C++11 and auto - this gets a bit easier typename Fft::ValueVector X = fft.valueVector(); // for X = input vector typename Fft::ComplexVector Y = fft.spectrumVector(); // for Y = forward(X) typename Fft::InternalLayoutVector R = fft.internalLayoutVector(); // for R = forwardInternalLayout(X) typename Fft::ValueVector Z = fft.valueVector(); // for Z = inverse(Y) = inverse( forward(X) ) // or Z = inverseInternalLayout(R) +#endif // work with complex - without the capabilities of a higher c++ standard Scalar* Xs = reinterpret_cast<Scalar*>(X.data()); // for X = input vector |