ndtree
nd-octree data-structure and algorithms
ndtree::v1::math Namespace Reference

Mathematical utilities. More...

Functions

template<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ipow (const Int b, const Int e)
 Computes b^e for (b,e) integers. More...
 
template<class Float , CONCEPT_REQUIRES_(std::is_floating_point< Float >{}) >
constexpr Float floor (Float x)
 Constexpr version of cmath floor. More...
 
template<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int factorial (const Int n) noexcept
 Computes the factorial of n. More...
 
template<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int binomial_coefficient (const Int n, const Int m) noexcept
 Computes the binomial coefficient (n m) More...
 

Detailed Description

Mathematical utilities.

Function Documentation

template<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ndtree::v1::math::ipow ( const Int  b,
const Int  e 
)
template<class Float , CONCEPT_REQUIRES_(std::is_floating_point< Float >{}) >
constexpr Float ndtree::v1::math::floor ( Float  x)

Constexpr version of cmath floor.

TODO: there has to be a better way

Referenced by ndtree::v1::tree< nd >::sibling_group().

template<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ndtree::v1::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<class Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr Int ndtree::v1::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().