Line data Source code
1 : #pragma once 2 : 3 : #include "CUDADefines.h" 4 : #include "TypeTraits.hpp" 5 : #include <thrust/complex.h> 6 : #include <complex> 7 : 8 : namespace elsa::fn 9 : { 10 : namespace detail 11 : { 12 : struct imag_fn { 13 : template <class T> 14 : __host__ __device__ constexpr auto operator()(const T&) const noexcept 15 : -> std::enable_if_t<!is_complex_v<T>, T> 16 : { 17 : return 0; 18 : } 19 : 20 : template <class T> 21 : __host__ __device__ constexpr auto 22 : operator()(const thrust::complex<T>& arg) const noexcept 23 : -> decltype(std::declval<thrust::complex<T>>().imag()) 24 29 : { 25 29 : return arg.imag(); 26 29 : } 27 : 28 : template <class T> 29 : __host__ constexpr auto operator()(const std::complex<T>& arg) const noexcept 30 : -> decltype(std::imag(std::declval<std::complex<T>>())) 31 : { 32 : return std::imag(arg); 33 : } 34 : }; 35 : } // namespace detail 36 : 37 : static constexpr __device__ detail::imag_fn imag; 38 : } // namespace elsa::fn