16 #ifndef dealii_numbers_h 17 #define dealii_numbers_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/types.h> 24 #ifdef DEAL_II_COMPILER_CUDA_AWARE 25 # include <cuComplex.h> 32 #ifdef DEAL_II_COMPILER_CUDA_AWARE 33 # define DEAL_II_CUDA_HOST_DEV __host__ __device__ 35 # define DEAL_II_CUDA_HOST_DEV 38 DEAL_II_NAMESPACE_OPEN
41 template <
typename Number>
46 DEAL_II_NAMESPACE_CLOSE
50 #ifdef DEAL_II_WITH_ADOLC 51 # include <deal.II/differentiation/ad/adolc_math.h> 53 # include <adolc/adouble.h> 59 #ifdef DEAL_II_TRILINOS_WITH_SACADO 60 # include <Sacado.hpp> 65 template <
typename Number>
66 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
67 sqrt(const ::VectorizedArray<Number> &);
68 template <
typename Number>
69 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
70 abs(const ::VectorizedArray<Number> &);
71 template <
typename Number>
72 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
73 max(const ::VectorizedArray<Number> &,
74 const ::VectorizedArray<Number> &);
75 template <
typename Number>
76 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
77 min(const ::VectorizedArray<Number> &,
78 const ::VectorizedArray<Number> &);
79 template <
typename Number>
81 pow(const ::VectorizedArray<Number> &,
const Number p);
82 template <
typename Number>
84 sin(const ::VectorizedArray<Number> &);
85 template <
typename Number>
87 cos(const ::VectorizedArray<Number> &);
88 template <
typename Number>
90 tan(const ::VectorizedArray<Number> &);
91 template <
typename Number>
93 exp(const ::VectorizedArray<Number> &);
94 template <
typename Number>
96 log(const ::VectorizedArray<Number> &);
99 DEAL_II_NAMESPACE_OPEN
121 static constexpr
double E = 2.7182818284590452354;
126 static constexpr
double LOG2E = 1.4426950408889634074;
131 static constexpr
double LOG10E = 0.43429448190325182765;
136 static constexpr
double LN2 = 0.69314718055994530942;
141 static constexpr
double LN10 = 2.30258509299404568402;
146 static constexpr
double PI = 3.14159265358979323846;
151 static constexpr
double PI_2 = 1.57079632679489661923;
156 static constexpr
double PI_4 = 0.78539816339744830962;
161 static constexpr
double SQRT2 = 1.41421356237309504880;
166 static constexpr
double SQRT1_2 = 0.70710678118654752440;
173 template <
typename Number,
typename =
void>
180 template <
typename Number>
218 is_finite(
const std::complex<double> &x);
236 is_finite(
const std::complex<long double> &x);
248 template <
typename Number1,
typename Number2>
262 template <
typename Number1,
typename Number2>
273 template <
typename Number>
287 template <
typename Number1,
typename Number2>
301 template <
typename Number1,
typename Number2>
304 const Number2 &value_2);
318 template <
typename Number1,
typename Number2>
332 template <
typename Number1,
typename Number2>
335 const Number2 &value_2);
347 template <
typename number>
372 static constexpr DEAL_II_CUDA_HOST_DEV
const number &
383 template <
typename Dummy = number>
384 static constexpr DEAL_II_CUDA_HOST_DEV
385 typename std::enable_if<std::is_same<Dummy, number>::value &&
390 template <
typename Dummy = number>
392 typename std::enable_if<std::is_same<Dummy, number>::value &&
401 abs(
const number &x);
411 template <
typename number>
432 static constexpr std::complex<number>
433 conjugate(
const std::complex<number> &x);
449 abs(
const std::complex<number> &x);
457 return std::isnan(x);
465 return std::isfinite(x);
498 template <
typename number>
499 constexpr DEAL_II_CUDA_HOST_DEV
const number &
507 template <
typename number>
508 template <
typename Dummy>
509 constexpr DEAL_II_CUDA_HOST_DEV
510 typename std::enable_if<std::is_same<Dummy, number>::value &&
520 template <
typename number>
521 template <
typename Dummy>
523 typename std::enable_if<std::is_same<Dummy, number>::value &&
533 template <
typename number>
542 template <
typename number>
543 constexpr std::complex<number>
551 template <
typename number>
560 template <
typename number>
578 template <
typename T>
583 template <
typename NumberType>
595 template <
typename From,
typename To>
600 template <
typename T>
603 template <
typename F,
typename T>
604 static constexpr
auto 605 test(
int) -> decltype(f(static_cast<T>(std::declval<F>())),
true)
610 template <
typename F,
typename T>
611 static constexpr
auto 618 static bool const value = test<From, To>(0);
634 template <
typename T>
637 static constexpr DEAL_II_CUDA_HOST_DEV
const T &
651 template <
typename F>
652 static constexpr DEAL_II_CUDA_HOST_DEV T
654 typename std::enable_if<
655 !std::is_same<
typename std::decay<T>::type,
656 typename std::decay<F>::type>::value &&
657 std::is_constructible<T, F>::value>::type * =
nullptr)
663 template <
typename F>
666 typename std::enable_if<
667 !std::is_same<
typename std::decay<T>::type,
668 typename std::decay<F>::type>::value &&
669 !std::is_constructible<T, F>::value &&
672 return static_cast<T
>(f);
679 template <
typename F>
682 typename std::enable_if<
683 !std::is_same<
typename std::decay<T>::type,
684 typename std::decay<F>::type>::value &&
685 !std::is_constructible<T, F>::value &&
693 template <
typename T>
696 static constexpr
const std::complex<T> &
697 value(
const std::complex<T> &t)
702 static constexpr std::complex<T>
705 return std::complex<T>(t);
709 template <
typename U>
710 static constexpr std::complex<T>
711 value(
const std::complex<U> &t)
713 return std::complex<T>(NumberType<T>::value(t.real()),
714 NumberType<T>::value(t.imag()));
718 #ifdef DEAL_II_COMPILER_CUDA_AWARE 720 struct NumberType<cuComplex>
725 return make_cuComplex(t, 0.f);
730 struct NumberType<cuDoubleComplex>
732 static cuDoubleComplex
733 value(
const double t)
735 return make_cuDoubleComplex(t, 0.);
743 #ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING 770 template <
typename Number>
790 template <
typename Number>
825 template <
typename Number>
846 template <
typename Number>
858 template <
typename Number1,
typename Number2>
866 template <
typename Number1,
typename Number2>
874 template <
typename Number>
882 template <
typename Number1,
typename Number2>
890 template <
typename Number1,
typename Number2>
899 template <
typename Number1,
typename Number2>
907 template <
typename Number1,
typename Number2>
910 const Number2 &value_2)
916 DEAL_II_NAMESPACE_CLOSE
static constexpr double LOG2E
bool value_is_less_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
static constexpr double LN10
bool value_is_zero(const Number &value)
static constexpr std::enable_if< std::is_same< Dummy, number >::value &&is_cuda_compatible< Dummy >::value, real_type >::type abs_square(const number &x)
static real_type abs(const number &x)
static constexpr double LOG10E
bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
bool is_finite(const double x)
static constexpr double SQRT1_2
static constexpr double E
static constexpr double SQRT2
bool values_are_not_equal(const Number1 &value_1, const Number2 &value_2)
static constexpr double PI_2
bool is_nan(const double x)
bool value_is_greater_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
static constexpr double LN2
bool value_is_greater_than(const Number1 &value_1, const Number2 &value_2)
bool value_is_less_than(const Number1 &value_1, const Number2 &value_2)
static constexpr double PI
T min(const T &t, const MPI_Comm &mpi_communicator)
static constexpr const number & conjugate(const number &x)
static constexpr double PI_4
static constexpr bool is_complex
T max(const T &t, const MPI_Comm &mpi_communicator)