dune-common  2.7.0
Classes | Namespaces | Macros | Functions
math.hh File Reference

Some useful basic math stuff. More...

#include <cmath>
#include <complex>
#include <limits>
#include <type_traits>
#include <dune/common/typeutilities.hh>

Go to the source code of this file.

Classes

struct  Dune::StandardMathematicalConstants< T >
 Standard implementation of MathematicalConstants. More...
 
struct  Dune::MathematicalConstants< Field >
 Provides commonly used mathematical constants. More...
 
struct  Dune::Factorial< m >
 Calculates the factorial of m at compile time. More...
 
struct  Dune::Factorial< 0 >
 end of recursion of factorial via specialization More...
 
struct  Dune::MathOverloads::ADLTag
 Tag to make sure the functions in this namespace can be found by ADL. More...
 
struct  Dune::MathImpl::isUnorderedImpl
 

Namespaces

 Dune
 Dune namespace.
 
 Dune::MathOverloads
 namespace for customization of math functions with Dune-Semantics
 
 Dune::MathImpl
 

Macros

#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction)
 
#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function)
 

Functions

template<class Mantissa , class Exponent >
constexpr Mantissa Dune::power (Mantissa m, Exponent p)
 Power method for integer exponents. More...
 
template<class T >
constexpr static T Dune::factorial (const T &n) noexcept
 calculate the factorial of n as a constexpr More...
 
template<class T , T n>
constexpr static auto Dune::factorial (std::integral_constant< T, n >) noexcept
 calculate the factorial of n as a constexpr More...
 
template<class T >
constexpr static T Dune::binomial (const T &n, const T &k) noexcept
 calculate the binomial coefficient n over k as a constexpr More...
 
template<class T , T n, T k>
constexpr static auto Dune::binomial (std::integral_constant< T, n >, std::integral_constant< T, k >) noexcept
 calculate the binomial coefficient n over k as a constexpr More...
 
template<class T , T n>
constexpr static auto Dune::binomial (std::integral_constant< T, n >, std::integral_constant< T, n >) noexcept
 
template<class K >
Dune::conjugateComplex (const K &x)
 compute conjugate complex of x More...
 
template<class T >
int Dune::sign (const T &val)
 Return the sign of the value. More...
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isNaN, isnan)
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isInf, isinf)
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isFinite, isfinite)
 
template<class T >
auto Dune::MathOverloads::isUnordered (const T &t1, const T &t2, PriorityTag< 1 >, ADLTag) -> decltype(isUnordered(t1, t2))
 
template<class T >
auto Dune::MathOverloads::isUnordered (const T &t1, const T &t2, PriorityTag< 0 >, ADLTag)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isNaN)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isInf)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isFinite)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isNaN (const T &t, PriorityTag< 2 >, ADLTag)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isInf (const T &t, PriorityTag< 2 >, ADLTag)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isFinite (const T &t, PriorityTag< 2 >, ADLTag)
 

Detailed Description

Some useful basic math stuff.

Macro Definition Documentation

◆ DUNE_COMMON_MATH_ISFUNCTION

#define DUNE_COMMON_MATH_ISFUNCTION (   function,
  stdfunction 
)
Value:
template<class T> \
auto function(const T &t, PriorityTag<1>, ADLTag) \
-> decltype(function(t)) { \
return function(t); \
} \
template<class T> \
auto function(const T &t, PriorityTag<0>, ADLTag) { \
using std::stdfunction; \
return stdfunction(t); \
} \
static_assert(true, "Require semicolon to unconfuse editors")

◆ DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR

#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (   function)
Value:
struct function##Impl { \
template<class T> \
constexpr auto operator()(const T &t) const { \
return function(t, PriorityTag<10>{}, MathOverloads::ADLTag{}); \
} \
}; \
static_assert(true, "Require semicolon to unconfuse editors")