41 lines
646 B
C++
41 lines
646 B
C++
#pragma once
|
|
#include <cstdint>
|
|
|
|
namespace bts {
|
|
|
|
struct MathUtils {
|
|
/**
|
|
* Compute 'N!'
|
|
*/
|
|
template <std::uint32_t N>
|
|
static constexpr std::uint32_t factorial();
|
|
|
|
/**
|
|
* Compute 'n!'
|
|
*/
|
|
template <typename T>
|
|
static T factorial(T n);
|
|
|
|
/**
|
|
* Compute 'n!/(n-a)!'
|
|
*/
|
|
template <class T>
|
|
static T factorial_trunc(T n, T a);
|
|
|
|
/**
|
|
* Compute 'N choose A'
|
|
*/
|
|
template <std::uint32_t N, std::uint32_t A>
|
|
static constexpr std::uint32_t choose();
|
|
|
|
/**
|
|
* Compute 'n choose a'
|
|
*/
|
|
template <typename T>
|
|
static T choose(T n, T a);
|
|
};
|
|
|
|
} // namespace bts
|
|
|
|
#include "MathUtils.cc"
|