HM3
Hierarchical Multi-physics Multi-scale Methods
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
hm3::math Namespace Reference

Math utilities. More...

Functions

template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ilog (Int b, Int n)
 Computes the logarithm log_b(n) for (b,n) integers. More...
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ipow (Int b, Int e)
 Computes integer pow using exponentiation by squaring Complexiy O(log(e))
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int factorial (const Int n) noexcept
 Computes the factorial of n. More...
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int binomial_coefficient (const Int n, const Int m) noexcept
 Computes the binomial coefficient (n m) More...
 
template<typename Float , CONCEPT_REQUIRES_(std::is_floating_point< Float >{}) >
constexpr Float floor (Float x)
 Constexpr version of cmath floor. More...
 

Detailed Description

Math utilities.

Function Documentation

template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int hm3::math::ilog ( Int  b,
Int  n 
)

Computes the logarithm log_b(n) for (b,n) integers.

Warning
overflows for N > b^64.
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int hm3::math::factorial ( const Int  n)
noexcept

Computes the factorial of n.

Parameters
n[in] number whose factorial will be computed

TODO: assert on overflow

Referenced by binomial_coefficient().

template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int hm3::math::binomial_coefficient ( const Int  n,
const Int  m 
)
noexcept

Computes the binomial coefficient (n m)

TODO: assert n - m >= 0 for unsigned types

References factorial().

Referenced by hm3::geometry::square< Nd >::no_edges().

template<typename Float , CONCEPT_REQUIRES_(std::is_floating_point< Float >{}) >
constexpr Float hm3::math::floor ( Float  x)

Constexpr version of cmath floor.

TODO: there has to be a better way