Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:39:06

0001 //  Copyright John Maddock 2018.
0002 //  Use, modification and distribution are subject to the
0003 //  Boost Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //
0007 // Tools for operator on complex as well as scalar types.
0008 //
0009 
0010 #ifndef BOOST_MATH_TOOLS_COMPLEX_HPP
0011 #define BOOST_MATH_TOOLS_COMPLEX_HPP
0012 
0013 #include <boost/math/tools/config.hpp>
0014 #include <boost/math/tools/is_detected.hpp>
0015 
0016 #ifdef BOOST_MATH_ENABLE_CUDA
0017 
0018 #include <cuda/std/utility>
0019 #include <cuda/std/complex>
0020 
0021 namespace boost {
0022 namespace math {
0023 
0024 template <typename T>
0025 using complex = cuda::std::complex<T>;
0026 
0027 } // namespace math
0028 } // namespace boost
0029 
0030 #else
0031 
0032 #include <utility>
0033 #include <complex>
0034 
0035 namespace boost {
0036 namespace math {
0037 
0038 template <typename T>
0039 using complex = std::complex<T>;
0040 
0041 } // namespace math
0042 } // namespace boost
0043 
0044 #endif
0045 
0046 namespace boost {
0047    namespace math {
0048       namespace tools {
0049 
0050          namespace detail {
0051          template <typename T, typename = void>
0052          struct is_complex_type_impl
0053          {
0054             static constexpr bool value = false;
0055          };
0056 
0057          #ifndef BOOST_MATH_ENABLE_CUDA
0058          template <typename T>
0059          struct is_complex_type_impl<T, void_t<decltype(std::declval<T>().real()), 
0060                                                decltype(std::declval<T>().imag())>>
0061          {
0062             static constexpr bool value = true;
0063          };
0064          #else
0065          template <typename T>
0066          struct is_complex_type_impl<T, void_t<decltype(cuda::std::declval<T>().real()), 
0067                                                decltype(cuda::std::declval<T>().imag())>>
0068          {
0069             static constexpr bool value = true;
0070          };
0071          #endif
0072          } // Namespace detail
0073 
0074          template <typename T>
0075          struct is_complex_type : public detail::is_complex_type_impl<T> {};
0076          
0077          //
0078          // Use this trait to typecast integer literals to something
0079          // that will interoperate with T:
0080          //
0081          template <class T, bool = is_complex_type<T>::value>
0082          struct integer_scalar_type
0083          {
0084             typedef int type;
0085          };
0086          template <class T>
0087          struct integer_scalar_type<T, true>
0088          {
0089             typedef typename T::value_type type;
0090          };
0091          template <class T, bool = is_complex_type<T>::value>
0092          struct unsigned_scalar_type
0093          {
0094             typedef unsigned type;
0095          };
0096          template <class T>
0097          struct unsigned_scalar_type<T, true>
0098          {
0099             typedef typename T::value_type type;
0100          };
0101          template <class T, bool = is_complex_type<T>::value>
0102          struct scalar_type
0103          {
0104             typedef T type;
0105          };
0106          template <class T>
0107          struct scalar_type<T, true>
0108          {
0109             typedef typename T::value_type type;
0110          };
0111 
0112 
0113 } } }
0114 
0115 #endif // BOOST_MATH_TOOLS_COMPLEX_HPP