13#ifndef COMBINATORICS_HH
14#define COMBINATORICS_HH
41 for (
int i=2; i<=k; ++i)
64 size_t n = std::accumulate(begin(ks),end(ks),0);
68 for (
size_t i=1; i<=k; ++i)
99 for (
int i=0; i<=m; ++i)
120 static_assert(d>=1,
"multiindices only defined for d>0");
123 std::array<size_t,d> ks;
141 std::copy(begin(hs),end(hs),begin(ks));
160 if (std::accumulate(first,last,0)==m)
163 first = std::find_if(first,last,std::bind2nd(std::not_equal_to<int>(),0));
std::array< size_t, d > multiIndex(size_t m, size_t n)
Random access to multiindices.
size_t multinomial(std::array< size_t, m > const &ks)
Computes the multinomial coefficient , where .
constexpr int binomial(int n, int k)
Computes the binomial coefficient .
void next_multiindex(It first, It last, int const m)
Computes the next nonnegative multiindex of order m.
constexpr int numberOfMultiindices(int d, int m)
Computes the number of multiindices of order m and dimension d.