File indexing completed on 2025-09-16 08:39:06
0001
0002
0003
0004
0005
0006
0007
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 }
0028 }
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 }
0042 }
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 }
0073
0074 template <typename T>
0075 struct is_complex_type : public detail::is_complex_type_impl<T> {};
0076
0077
0078
0079
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