16#ifndef dealii_numbers_h
17#define dealii_numbers_h
24#ifdef DEAL_II_COMPILER_CUDA_AWARE
25# include <cuComplex.h>
33#ifdef DEAL_II_COMPILER_CUDA_AWARE
34# define DEAL_II_CUDA_HOST_DEV __host__ __device__
36# define DEAL_II_CUDA_HOST_DEV
59 template <
typename Number>
81#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512
83#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256
85#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128
105#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__ALTIVEC__)
107#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512 && defined(__AVX512F__)
109#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256 && defined(__AVX__)
111#elif DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__SSE2__)
123template <
typename Number,
135#ifdef DEAL_II_WITH_ADOLC
138# include <adolc/adouble.h>
144#ifdef DEAL_II_TRILINOS_WITH_SACADO
146# include <Sacado.hpp>
152 template <
typename Number, std::
size_t w
idth>
153 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
154 sqrt(const ::VectorizedArray<Number, width> &);
155 template <
typename Number, std::
size_t w
idth>
156 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
157 abs(const ::VectorizedArray<Number, width> &);
158 template <
typename Number, std::
size_t w
idth>
159 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
160 max(const ::VectorizedArray<Number, width> &,
161 const ::VectorizedArray<Number, width> &);
162 template <
typename Number, std::
size_t w
idth>
163 DEAL_II_ALWAYS_INLINE ::VectorizedArray<Number, width>
164 min(const ::VectorizedArray<Number, width> &,
165 const ::VectorizedArray<Number, width> &);
166 template <
typename Number,
size_t w
idth>
168 pow(const ::VectorizedArray<Number, width> &,
const Number p);
169 template <
typename Number,
size_t w
idth>
171 sin(const ::VectorizedArray<Number, width> &);
172 template <
typename Number,
size_t w
idth>
174 cos(const ::VectorizedArray<Number, width> &);
175 template <
typename Number,
size_t w
idth>
177 tan(const ::VectorizedArray<Number, width> &);
178 template <
typename Number,
size_t w
idth>
180 exp(const ::VectorizedArray<Number, width> &);
181 template <
typename Number,
size_t w
idth>
183 log(const ::VectorizedArray<Number, width> &);
208 static constexpr double E = 2.7182818284590452354;
213 static constexpr double LOG2E = 1.4426950408889634074;
218 static constexpr double LOG10E = 0.43429448190325182765;
223 static constexpr double LN2 = 0.69314718055994530942;
228 static constexpr double LN10 = 2.30258509299404568402;
233 static constexpr double PI = 3.14159265358979323846;
238 static constexpr double PI_2 = 1.57079632679489661923;
243 static constexpr double PI_4 = 0.78539816339744830962;
248 static constexpr double SQRT2 = 1.41421356237309504880;
253 static constexpr double SQRT1_2 = 0.70710678118654752440;
260 template <
typename Number,
typename =
void>
267 template <
typename Number>
288 is_finite(
const std::complex<double> &x);
306 is_finite(
const std::complex<long double> &x);
318 template <
typename Number1,
typename Number2>
332 template <
typename Number1,
typename Number2>
343 template <
typename Number>
357 template <
typename Number1,
typename Number2>
371 template <
typename Number1,
typename Number2>
374 const Number2 &value_2);
388 template <
typename Number1,
typename Number2>
402 template <
typename Number1,
typename Number2>
405 const Number2 &value_2);
415 template <
typename number>
456 template <
typename Dummy = number>
458 typename std::enable_if<std::is_same<Dummy, number>::value &&
463 template <
typename Dummy = number>
465 typename std::enable_if<std::is_same<Dummy, number>::value &&
482 template <
typename number>
508 static constexpr std::complex<number>
509 conjugate(
const std::complex<number> &x);
525 abs(
const std::complex<number> &x);
533 return std::isnan(x);
541 return std::isfinite(x);
574 template <
typename number>
583 template <
typename number>
584 template <
typename Dummy>
586 typename std::enable_if<std::is_same<Dummy, number>::value &&
596 template <
typename number>
597 template <
typename Dummy>
599 typename std::enable_if<std::is_same<Dummy, number>::value &&
609 template <
typename number>
618 template <
typename number>
619 constexpr std::complex<number>
627 template <
typename number>
636 template <
typename number>
654 template <
typename T>
659 template <
typename NumberType>
671 template <
typename From,
typename To>
676 template <
typename T>
679 template <
typename F,
typename T>
680 static constexpr auto
681 test(
int) ->
decltype(
f(
static_cast<T
>(std::declval<F>())),
true)
686 template <
typename F,
typename T>
687 static constexpr auto
694 static bool const value = test<From, To>(0);
701 template <
typename T>
718 template <
typename F>
721 typename std::enable_if<
722 !std::is_same<
typename std::decay<T>::type,
723 typename std::decay<F>::type>
::value &&
724 std::is_constructible<T, F>::value>::type * =
nullptr)
730 template <
typename F>
733 typename std::enable_if<
734 !std::is_same<
typename std::decay<T>::type,
735 typename std::decay<F>::type>
::value &&
736 !std::is_constructible<T, F>::value &&
739 return static_cast<T
>(f);
746 template <
typename F>
749 typename std::enable_if<
750 !std::is_same<
typename std::decay<T>::type,
751 typename std::decay<F>::type>
::value &&
752 !std::is_constructible<T, F>::value &&
760 template <
typename T>
763 static constexpr const std::complex<T> &
769 static constexpr std::complex<T>
772 return std::complex<T>(t);
776 template <
typename U>
777 static constexpr std::complex<T>
785#ifdef DEAL_II_COMPILER_CUDA_AWARE
792 return make_cuComplex(t, 0.f);
799 static cuDoubleComplex
802 return make_cuDoubleComplex(t, 0.);
810#ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
837 template <
typename Number>
857 template <
typename Number>
892 template <
typename Number>
913 template <
typename Number>
925 template <
typename Number1,
typename Number2>
933 template <
typename Number1,
typename Number2>
941 template <
typename Number>
949 template <
typename Number1,
typename Number2>
957 template <
typename Number1,
typename Number2>
966 template <
typename Number1,
typename Number2>
974 template <
typename Number1,
typename Number2>
977 const Number2 &value_2)
#define DEAL_II_ALWAYS_INLINE
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
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)
static constexpr double SQRT2
constexpr bool value_is_zero(const Number &value)
bool values_are_not_equal(const Number1 &value_1, const Number2 &value_2)
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 > 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_CUDA_HOST_DEV
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 T value(const F &f, typename std::enable_if< !std::is_same< typename std::decay< T >::type, typename std::decay< F >::type >::value &&std::is_constructible< T, F >::value >::type *=nullptr)
static constexpr const T & value(const T &t)
static T value(const F &f, typename std::enable_if< !std::is_same< typename std::decay< T >::type, typename std::decay< F >::type >::value &&!std::is_constructible< T, F >::value &&!is_explicitly_convertible< const F, T >::value &&Differentiation::AD::is_ad_number< F >::value >::type *=nullptr)
static constexpr T value(const F &f, typename std::enable_if< !std::is_same< typename std::decay< T >::type, typename std::decay< F >::type >::value &&!std::is_constructible< T, F >::value &&is_explicitly_convertible< const F, T >::value >::type *=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 std::enable_if< std::is_same< Dummy, number >::value &&!is_cuda_compatible< Dummy >::value, real_type >::type abs_square(const number &x)
static constexpr const number & conjugate(const number &x)
static constexpr bool is_complex
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)