dune-common 2.9.0
Loading...
Searching...
No Matches
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 >
 
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

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

Macros

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

Functions

template<class Base , class Exponent >
constexpr Base Dune::power (Base m, Exponent p)
 Power method for integer exponents.
 
template<class T >
static constexpr T Dune::factorial (const T &n) noexcept
 calculate the factorial of n as a constexpr
 
template<class T , T n>
static constexpr auto Dune::factorial (std::integral_constant< T, n >) noexcept
 calculate the factorial of n as a constexpr
 
template<class T >
static constexpr T Dune::binomial (const T &n, const T &k) noexcept
 calculate the binomial coefficient n over k as a constexpr
 
template<class T , T n, T k>
static constexpr auto Dune::binomial (std::integral_constant< T, n >, std::integral_constant< T, k >) noexcept
 calculate the binomial coefficient n over k as a constexpr
 
template<class T , T n>
static constexpr 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
 
template<class T >
int Dune::sign (const T &val)
 Return the sign of the value.
 
 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")