commit ff5431e539194ee55e83755e9ff0de2cd27da3d5 parent f8fc519c0354c6aae22482d251805212ca61e493 Author: d.levin256@gmail.com <d.levin256@gmail.com> Date: Fri, 1 Dec 2023 22:17:51 +0000 compound_type_traits for std::complex Diffstat:
M | include/kfr/simd/complex.hpp | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/include/kfr/simd/complex.hpp b/include/kfr/simd/complex.hpp @@ -27,6 +27,7 @@ #include "constants.hpp" #include "impl/function.hpp" #include "operators.hpp" +#include <complex> CMT_PRAGMA_MSVC(warning(push)) CMT_PRAGMA_MSVC(warning(disable : 4814)) @@ -183,6 +184,29 @@ struct compound_type_traits<kfr::complex<T>> return index == 0 ? value.real() : value.imag(); } }; + +#ifndef KFR_STD_COMPLEX +template <typename T> +struct compound_type_traits<std::complex<T>> +{ + constexpr static size_t width = 2; + constexpr static size_t deep_width = width * compound_type_traits<T>::width; + using subtype = T; + using deep_subtype = cometa::deep_subtype<T>; + constexpr static bool is_scalar = false; + constexpr static size_t depth = cometa::compound_type_traits<T>::depth + 1; + template <typename U> + using rebind = std::complex<U>; + template <typename U> + using deep_rebind = std::complex<typename compound_type_traits<subtype>::template deep_rebind<U>>; + + static constexpr subtype at(const std::complex<T>& value, size_t index) + { + return index == 0 ? value.real() : value.imag(); + } +}; +#endif + } // namespace cometa namespace kfr {