32 #ifndef MCKL_INTERNAL_CONST_MATH_HPP 33 #define MCKL_INTERNAL_CONST_MATH_HPP 41 #include <type_traits> 51 : ncol_(m + 1), data_((n + 1) * (m + 1))
53 std::fill(data_.begin(), data_.end(), 0);
55 for (std::size_t j = 1; j <= m; ++j) {
57 for (std::size_t i = j + 1; i <= n; ++i) {
58 get(i, j) = j *
get(i - 1, j) +
get(i - 1, j - 1);
65 return data_[i * ncol_ + j];
72 double &
get(std::size_t i, std::size_t j) {
return data_[i * ncol_ + j]; }
75 template <
unsigned long long U,
76 int N = std::numeric_limits<unsigned long long>::digits - 1>
79 static constexpr
unsigned long long M = 1ULL << N;
82 static constexpr
int value = M <= U ? N :
Log2L<U, N - 1>::value;
85 template <
unsigned long long U>
89 static constexpr
int value = 0;
96 static constexpr
int value = N + 1;
99 template <
typename UIntType, UIntType U>
100 class Log2 :
public Log2L<U, std::numeric_limits<UIntType>::digits - 1>
104 template <
unsigned long long B,
unsigned N,
bool = N % 2 == 0>
107 static constexpr
unsigned long long b =
PowL<B, N / 2>::value;
110 static constexpr
unsigned long long value = b * b;
113 template <
unsigned long long B,
unsigned N>
117 static constexpr
unsigned long long value = B *
PowL<B, N - 1>::value;
120 template <
unsigned long long B>
124 static constexpr
unsigned long long value = 1;
127 template <
typename UIntType,
unsigned long long B,
unsigned N>
135 int Q = (std::numeric_limits<unsigned long long>::digits <
136 std::numeric_limits<long double>::digits ?
137 std::numeric_limits<unsigned long long>::digits :
138 std::numeric_limits<long double>::digits) -
144 static constexpr
long double value =
148 template <
int P,
int Q>
152 static constexpr
long double value =
static_cast<long double>(1ULL << P);
155 template <
typename RealType,
int P,
bool = P >= 0>
159 static constexpr RealType value =
static_cast<RealType
>(
Pow2L<P>::value);
162 template <
typename RealType,
int P>
163 class Pow2Impl<RealType, P, false>
166 static constexpr RealType value =
167 static_cast<RealType
>(1.0L /
Pow2L<-P>::value);
170 template <
typename RealType,
int P>
171 using Pow2 = Pow2Impl<RealType, P>;
173 template <
typename UIntType,
unsigned N>
177 static constexpr UIntType value = N *
Factorial<UIntType, N - 1>::value;
180 template <
typename UIntType>
184 static constexpr UIntType value = 1;
187 template <
typename UIntType>
191 static constexpr UIntType value = 1;
198 #endif // MCKL_INTERNAL_CONST_MATH_HPP
StirlingMatrix2(std::size_t n, std::size_t m)
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
double operator()(std::size_t i, std::size_t j) const
Pow2Impl< RealType, P > Pow2