15#ifndef dealii_numbers_h
16#define dealii_numbers_h
23#ifdef DEAL_II_WITH_CUDA
24# include <cuComplex.h>
27#include <Kokkos_Macros.hpp>
34#define DEAL_II_HOST_DEVICE KOKKOS_FUNCTION
35#define DEAL_II_CUDA_HOST_DEV DEAL_II_HOST_DEVICE
36#define DEAL_II_HOST_DEVICE_ALWAYS_INLINE KOKKOS_FORCEINLINE_FUNCTION
42#if (defined(__clang__) && defined(__CUDA__)) || defined(KOKKOS_ENABLE_HIP)
43# define DEAL_II_HOST __host__
50#ifdef DEAL_II_WITH_ADOLC
78 template <
typename Number>
100#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512
102#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256
104#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128
124#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__ALTIVEC__)
126#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512 && defined(__AVX512F__)
128#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256 && defined(__AVX__)
130#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__SSE2__)
132#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__ARM_NEON)
144template <
typename Number,
152#ifdef DEAL_II_WITH_ADOLC
167abs(
const adouble &x);
170abs(
const adtl::adouble &x);
178 template <
typename Number, std::
size_t w
idth>
179 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
180 sqrt(const ::VectorizedArray<Number, width> &);
181 template <
typename Number, std::
size_t w
idth>
182 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
183 abs(const ::VectorizedArray<Number, width> &);
184 template <
typename Number, std::
size_t w
idth>
185 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
186 max(const ::VectorizedArray<Number, width> &,
187 const ::VectorizedArray<Number, width> &);
188 template <
typename Number, std::
size_t w
idth>
189 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
190 min(const ::VectorizedArray<Number, width> &,
191 const ::VectorizedArray<Number, width> &);
192 template <
typename Number,
size_t w
idth>
194 pow(const ::VectorizedArray<Number, width> &,
const Number p);
195 template <
typename Number,
size_t w
idth>
197 sin(const ::VectorizedArray<Number, width> &);
198 template <
typename Number,
size_t w
idth>
200 cos(const ::VectorizedArray<Number, width> &);
201 template <
typename Number,
size_t w
idth>
203 tan(const ::VectorizedArray<Number, width> &);
204 template <
typename Number,
size_t w
idth>
206 exp(const ::VectorizedArray<Number, width> &);
207 template <
typename Number,
size_t w
idth>
209 log(const ::VectorizedArray<Number, width> &);
234 static constexpr double E = 2.7182818284590452354;
239 static constexpr double LOG2E = 1.4426950408889634074;
244 static constexpr double LOG10E = 0.43429448190325182765;
249 static constexpr double LN2 = 0.69314718055994530942;
254 static constexpr double LN10 = 2.30258509299404568402;
259 static constexpr double PI = 3.14159265358979323846;
264 static constexpr double PI_2 = 1.57079632679489661923;
269 static constexpr double PI_4 = 0.78539816339744830962;
274 static constexpr double SQRT2 = 1.41421356237309504880;
279 static constexpr double SQRT1_2 = 0.70710678118654752440;
298 is_finite(
const std::complex<double> &x);
316 is_finite(
const std::complex<long double> &x);
328 template <
typename Number1,
typename Number2>
342 template <
typename Number1,
typename Number2>
353 template <
typename Number>
367 template <
typename Number1,
typename Number2>
381 template <
typename Number1,
typename Number2>
384 const Number2 &value_2);
398 template <
typename Number1,
typename Number2>
412 template <
typename Number1,
typename Number2>
415 const Number2 &value_2);
425 template <
typename number>
481 template <
typename number>
507 static constexpr std::complex<number>
508 conjugate(
const std::complex<number> &x);
524 abs(
const std::complex<number> &x);
532 return std::isnan(x);
540 return std::isfinite(x);
573 template <
typename number>
582 template <
typename number>
591 template <
typename number>
597#ifdef DEAL_II_WITH_ADOLC
609 template <
typename number>
610 constexpr std::complex<number>
618 template <
typename number>
624#ifdef DEAL_II_WITH_ADOLC
633 template <
typename number>
651 template <
typename T>
656 template <
typename NumberType>
668 template <
typename From,
typename To>
673 template <
typename T>
676 template <
typename F,
typename T>
677 static constexpr auto
678 test(
int) ->
decltype(
f(
static_cast<T
>(std::declval<F>())),
true)
683 template <
typename F,
typename T>
684 static constexpr auto
698 template <
typename T>
715 template <
typename F>
718 std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::decay_t<F>> &&
719 std::is_constructible_v<T, F>> * =
nullptr)
725 template <
typename F>
728 std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::decay_t<F>> &&
729 !std::is_constructible_v<T, F> &&
733 return static_cast<T
>(f);
740 template <
typename F>
744 std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::decay_t<F>> &&
745 !std::is_constructible_v<T, F> &&
753 template <
typename T>
756 static constexpr const std::complex<T> &
762 static constexpr std::complex<T>
765 return std::complex<T>(t);
769 template <
typename U>
770 static constexpr std::complex<T>
778#ifdef DEAL_II_WITH_CUDA
785 return make_cuComplex(t, 0.f);
792 static cuDoubleComplex
795 return make_cuDoubleComplex(t, 0.);
803#ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
830 template <
typename Number>
850 template <
typename Number>
885 template <
typename Number>
906 template <
typename Number>
918 template <
typename Number1,
typename Number2>
926 template <
typename Number1,
typename Number2>
927 inline constexpr bool
934 template <
typename Number>
942 template <
typename Number1,
typename Number2>
950 template <
typename Number1,
typename Number2>
959 template <
typename Number1,
typename Number2>
967 template <
typename Number1,
typename Number2>
970 const Number2 &value_2)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static constexpr double LOG10E
static constexpr double PI_2
bool value_is_less_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
static constexpr double E
static constexpr double PI
bool value_is_greater_than(const Number1 &value_1, const Number2 &value_2)
constexpr bool values_are_not_equal(const Number1 &value_1, const Number2 &value_2)
static constexpr double SQRT2
constexpr bool value_is_zero(const Number &value)
static constexpr double SQRT1_2
constexpr bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
static constexpr double PI_4
static constexpr double LN10
static constexpr double LN2
bool value_is_less_than(const Number1 &value_1, const Number2 &value_2)
bool is_finite(const double x)
static constexpr double LOG2E
bool value_is_greater_than_or_equal_to(const Number1 &value_1, const Number2 &value_2)
bool is_nan(const double x)
::VectorizedArray< Number, width > log(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > tan(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
#define DEAL_II_HOST_DEVICE
#define DEAL_II_HOST_DEVICE_ALWAYS_INLINE
static cuComplex value(const float t)
static cuDoubleComplex value(const double t)
static constexpr std::complex< T > value(const std::complex< U > &t)
static constexpr std::complex< T > value(const T &t)
static constexpr const std::complex< T > & value(const std::complex< T > &t)
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE T value(const F &f, std::enable_if_t<!std::is_same_v< std::decay_t< T >, std::decay_t< F > > &&std::is_constructible_v< T, F > > *=nullptr)
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE T value(const F &f, std::enable_if_t<!std::is_same_v< std::decay_t< T >, std::decay_t< F > > &&!std::is_constructible_v< T, F > &&is_explicitly_convertible< const F, T >::value > *=nullptr)
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)
static T value(const F &f, std::enable_if_t<!std::is_same_v< std::decay_t< T >, std::decay_t< F > > &&!std::is_constructible_v< T, F > &&!is_explicitly_convertible< const F, T >::value &&Differentiation::AD::is_ad_number< F >::value > *=nullptr)
static constexpr unsigned int max_width
static constexpr auto test(...) -> bool
static constexpr auto test(int) -> decltype(f(static_cast< T >(std::declval< F >())), true)
std::complex< double > double_type
static constexpr const number & conjugate(const number &x)
static constexpr bool is_complex
static real_type abs(const number &x)
static constexpr real_type abs_square(const number &x)