Line data Source code
1 : #pragma once 2 : 3 : #include "CUDADefines.h" 4 : #include <thrust/complex.h> 5 : #include <complex> 6 : 7 : namespace elsa::fn 8 : { 9 : namespace detail 10 : { 11 : struct sign_fn { 12 : template <class T> 13 : __host__ constexpr auto operator()(const T& arg) const noexcept 14 9472 : { 15 9472 : return (T{0} < arg) - (arg < T{0}); 16 9472 : } 17 : 18 : template <class T> 19 : __host__ __device__ constexpr auto 20 : operator()(const thrust::complex<T>& arg) const noexcept -> T 21 105 : { 22 105 : if (arg.real() > 0) { 23 68 : return T{1}; 24 68 : } else if (arg.real() < 0) { 25 57 : return T{-1}; 26 >1844*10^16 : } else { 27 >1844*10^16 : return (*this)(arg.imag()); 28 >1844*10^16 : } 29 105 : } 30 : }; 31 : } // namespace detail 32 : 33 : static constexpr __device__ detail::sign_fn sign; 34 : } // namespace elsa::fn