27 using id_type =
unsigned int;
28 using set_type = std::vector<id_type>;
31 using RGS_type = std::vector<unsigned int>;
33 template <
typename T>
Partitioner(T
const &set) : m_set(enumerate_elements(set))
38 std::vector<RestrictedGrowthString> construct_all_m_blocks_partitions_of_the_set_by_algorithm_u(
39 unsigned int nb_blocks)
42 std::vector<RestrictedGrowthString> result;
47 result.emplace_back(RGS_type(m_set.size(), 0));
49 else if (nb_blocks == m_set.size())
51 RGS_type v(m_set.size());
52 std::iota(std::begin(v), std::end(v), 0);
53 result.emplace_back(v);
57 assert((1 < nb_blocks) && (nb_blocks < m_set.size()));
58 auto n = m_set.size();
59 a = RGS_type(n + 1, 0);
60 for (
unsigned int j = 1; j <= nb_blocks; ++j)
62 a[n - nb_blocks + j] = j - 1;
67 for (
auto &it : m_partitions)
70 result.emplace_back(it);
81 std::vector<RGS_type> m_partitions;
86 m_partitions.push_back(a);
89 void f(
unsigned int mu,
unsigned int nu,
unsigned int sigma)
97 f(mu - 1, nu - 1, (mu + sigma) % 2);
110 else if (nu > mu + 1)
112 if ((mu + sigma) % 2 == 1)
121 if ((a[nu] + sigma) % 2 == 1)
133 if ((a[nu] + sigma) % 2 == 1)
145 void b(
unsigned int mu,
unsigned int nu,
unsigned int sigma)
149 while (a[nu] < mu - 1)
157 else if (nu > mu + 1)
159 if ((a[nu] + sigma) % 2 == 1)
168 while (a[nu] < mu - 1)
171 if ((a[nu] + sigma) % 2 == 1)
181 if ((mu + sigma) % 2 == 1)
197 b(mu - 1, nu - 1, (mu + sigma) % 2);
201 template <
typename T> set_type enumerate_elements(T
const &set)
const
203 std::vector<id_type> v(set.size());
204 std::iota(v.begin(), v.end(), 1);