16 #ifndef dealii_numbers_h 17 #define dealii_numbers_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/types.h> 27 #ifdef DEAL_II_WITH_CUDA 28 # include <cuda_runtime_api.h> 29 # define DEAL_II_CUDA_HOST_DEV __host__ __device__ 31 # define DEAL_II_CUDA_HOST_DEV 34 DEAL_II_NAMESPACE_OPEN
40 DEAL_II_NAMESPACE_CLOSE
44 #ifdef DEAL_II_WITH_ADOLC 45 #include <adolc/adouble.h> 46 #include <deal.II/differentiation/ad/adolc_math.h> 52 #ifdef DEAL_II_WITH_TRILINOS 58 template <
typename Number> DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
59 sqrt(const ::VectorizedArray<Number> &);
60 template <
typename Number> DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
61 abs(const ::VectorizedArray<Number> &);
62 template <
typename Number> DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
63 max(const ::VectorizedArray<Number> &, const ::VectorizedArray<Number> &);
64 template <
typename Number> DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number>
65 min (const ::VectorizedArray<Number> &, const ::VectorizedArray<Number> &);
67 pow(const ::VectorizedArray<Number> &,
const Number p);
69 sin(const ::VectorizedArray<Number> &);
71 cos(const ::VectorizedArray<Number> &);
73 tan(const ::VectorizedArray<Number> &);
75 exp(const ::VectorizedArray<Number> &);
77 log(const ::VectorizedArray<Number> &);
80 DEAL_II_NAMESPACE_OPEN
102 static const double E = 2.7182818284590452354;
107 static const double LOG2E = 1.4426950408889634074;
112 static const double LOG10E = 0.43429448190325182765;
117 static const double LN2 = 0.69314718055994530942;
122 static const double LN10 = 2.30258509299404568402;
127 static const double PI = 3.14159265358979323846;
132 static const double PI_2 = 1.57079632679489661923;
137 static const double PI_4 = 0.78539816339744830962;
142 static const double SQRT2 = 1.41421356237309504880;
147 static const double SQRT1_2 = 0.70710678118654752440;
163 bool is_nan (
const double x);
180 bool is_finite (
const std::complex<double> &x);
186 bool is_finite (
const std::complex<float> &x);
196 bool is_finite (
const std::complex<long double> &x);
208 template <
typename Number1,
typename Number2>
222 template <
typename Number1,
typename Number2>
233 template <
typename Number>
247 template <
typename Number1,
typename Number2>
261 template <
typename Number1,
typename Number2>
277 template <
typename Number1,
typename Number2>
291 template <
typename Number1,
typename Number2>
305 template <
typename number>
329 DEAL_II_CUDA_HOST_DEV
330 const number &
conjugate (
const number &x);
340 DEAL_II_CUDA_HOST_DEV
357 template <
typename number>
379 std::complex<number>
conjugate (
const std::complex<number> &x);
402 return std::isnan(x);
407 return std::isfinite(x);
434 inline bool is_finite (
const std::complex<long double> &x)
443 template <
typename number>
444 DEAL_II_CUDA_HOST_DEV
453 template <
typename number>
454 DEAL_II_CUDA_HOST_DEV
463 template <
typename number>
472 template <
typename number>
481 template <
typename number>
490 template <
typename number>
494 return std::norm (x);
509 template <
typename T>
514 template <
typename NumberType>
526 template<
typename From,
typename To>
534 template<
typename F,
typename T>
535 static constexpr
auto test(
int) ->
536 decltype(f(static_cast<T>(std::declval<F>())),
true)
541 template<
typename F,
typename T>
542 static constexpr
auto test(...) ->
bool 549 static bool const value = test<From,To>(0);
562 template <
typename T>
565 static DEAL_II_CUDA_HOST_DEV
const T &value (
const T &t)
581 typename std::enable_if<
582 !std::is_same<
typename std::decay<T>::type,
typename std::decay<F>::type>::value &&
583 std::is_constructible<T,F>::value
593 typename std::enable_if<
594 !std::is_same<
typename std::decay<T>::type,
typename std::decay<F>::type>::value &&
595 !std::is_constructible<T,F>::value &&
599 return static_cast<T
>(f);
609 typename std::enable_if<
610 !std::is_same<
typename std::decay<T>::type,
typename std::decay<F>::type>::value &&
611 !std::is_constructible<T,F>::value &&
621 template <
typename T>
624 static const std::complex<T> &value (
const std::complex<T> &t)
629 static std::complex<T> value (
const T &t)
631 return std::complex<T>(t);
635 template <
typename U>
636 static std::complex<T> value (
const std::complex<U> &t)
638 return std::complex<T>(
639 NumberType<T>::value(t.real()),
640 NumberType<T>::value(t.imag()));
648 #ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING 663 const adouble &value_2);
676 template <
typename Number>
679 const Number &value_2)
696 template <
typename Number>
699 const adouble &value_2)
719 const adouble &value_2);
733 template <
typename Number>
736 const Number &value_2)
754 template <
typename Number>
757 const adouble &value_2)
766 template <
typename Number1,
typename Number2>
774 template <
typename Number1,
typename Number2>
782 template <
typename Number>
790 template <
typename Number1,
typename Number2>
798 template <
typename Number1,
typename Number2>
806 template <
typename Number1,
typename Number2>
814 template <
typename Number1,
typename Number2>
822 DEAL_II_NAMESPACE_CLOSE
static const number & conjugate(const number &x)
static const double SQRT2
bool value_is_less_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
bool value_is_zero(const Number &value)
static real_type abs(const number &x)
bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
bool is_finite(const double x)
static real_type abs_square(const number &x)
bool values_are_not_equal(const Number1 &value_1, const Number2 &value_2)
static const bool is_complex
bool is_nan(const double x)
bool value_is_greater_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
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)
T min(const T &t, const MPI_Comm &mpi_communicator)
static const double LOG2E
static const double SQRT1_2
T max(const T &t, const MPI_Comm &mpi_communicator)
static const double LOG10E