ecgen namespace
Set Partition
A set partition of the set [n] = {1,2,3,...,n} is a collection B0, B1, ... Bj of disjoint subsets of [n] whose union is [n]. Each Bj is called a block. Below we show the partitions of [4]. The periods separtate the individual sets so that, for example, 1.23.4 is the partition {{1},{2,3},{4}}. 1 block: 1234 2 blocks: 123.4 124.3 134.2 1.234 12.34 13.24 14.23 3 blocks: 1.2.34 1.24.3 14.2.3 13.2.4 12.3.4 4 blocks: 1.2.3.4
Each partition above has its blocks listed in increasing order of smallest element; thus block 0 contains element 1, block1 contains the smallest element not in block 0, and so on. A Restricted Growth string (or RG string) is a sring a[1..n] where a[i] is the block in whcih element i occurs. Restricted Growth strings are often called restricted growth functions. Here are the RG strings corresponding to the partitions shown above.
1 block: 0000 2 blocks: 0001, 0010, 0100, 0111, 0011, 0101, 0110 3 blocks: 0122, 0121, 0112, 0120, 0102,
...more
Reference: Frank Ruskey. Simple combinatorial Gray codes constructed by reversing sublists. Lecture Notes in Computer Science, #762, 201-208. Also downloadable from http:/
Classes
- class EcGen
- A class for saying hello in multiple languages.
Enums
- enum class LanguageCode { EN, DE, ES, FR }
Functions
- auto EMK_gen(size_t n, size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > > -> auto
- EMK (GEN)
- auto EMK_neg(size_t n, size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > > -> auto
- EMK (NEG)
-
template<typename Container>auto EMK(size_t n, size_t k, Container& lst) -> cppcoro::generator< Container & > -> auto
- Generate all combinations in reverse order by homogeneous revolving-door.
-
template<size_t N, size_t K>auto Combination() -> auto constexpr
- The number of combinations.
- auto BRGC_gen(size_t n) -> cppcoro::recursive_generator< size_t > -> auto
- Generate reflexed Gray code.
-
template<typename Container>auto BRGC(size_t n) -> cppcoro::generator< Container & > -> auto
- Binary Reflexed Gray Code (less efficiency)
- auto SJT_gen(size_t n) -> cppcoro::generator< size_t > -> auto
- SJT.
- auto Ehr_gen(size_t n) -> cppcoro::generator< size_t > -> auto
- Ehr.
-
template<size_t N>auto Factorial() -> auto constexpr
- Factorial, N!, the number of permutations.
-
template<typename Container>auto SJT(Container& perm) -> cppcoro::generator< Container & > -> auto
- SJT permutation by adjacent transposition (less efficiency)
-
template<typename Container>auto Ehr(Container& perm) -> cppcoro::generator< Container & > -> auto
- Ehr permutation by star transposition (less efficiency)
-
template<size_t N, size_t K>auto Stirling2nd() -> auto constexpr
- Stirling number of second kind.
- auto set_partition_gen(size_t n, size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > > -> auto
- Set the partition gen object.
Enum documentation
enum class ecgen:: LanguageCode
#include <ecgen/greeter.h>
Language codes to be used with the EcGen class
Function documentation
auto ecgen:: EMK_gen(size_t n,
size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > >
#include <ecgen/combin.hpp>
EMK (GEN)
| Parameters | |
|---|---|
| n in | |
| k in | |
| Returns | cppcoro::recursive_generator<std::pair<size_t, size_t>> |
auto ecgen:: EMK_neg(size_t n,
size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > >
#include <ecgen/combin.hpp>
EMK (NEG)
| Parameters | |
|---|---|
| n in | |
| k in | |
| Returns | cppcoro::recursive_generator<std::pair<size_t, size_t>> |
#include <ecgen/combin.hpp>
template<typename Container>
auto ecgen:: EMK(size_t n,
size_t k,
Container& lst) -> cppcoro::generator< Container & >
Generate all combinations in reverse order by homogeneous revolving-door.
| Parameters | |
|---|---|
| n in | |
| k in | |
| lst | |
| Returns | recursive_generator<std::vector<size_t>> |
#include <ecgen/combin.hpp>
template<size_t N, size_t K>
auto ecgen:: Combination() constexpr
The number of combinations.
| Template parameters | |
|---|---|
| N | |
| K | |
| Returns | constexpr auto |
The Combination() function is a template function that calculates the number of combinations of K elements from a set of N elements at compile-time.
auto ecgen:: BRGC_gen(size_t n) -> cppcoro::recursive_generator< size_t >
#include <ecgen/gray_code.hpp>
Generate reflexed Gray code.
| Parameters | |
|---|---|
| n in | |
| Returns | cppcoro::recursive_generator<size_t> |
#include <ecgen/gray_code.hpp>
template<typename Container>
auto ecgen:: BRGC(size_t n) -> cppcoro::generator< Container & >
Binary Reflexed Gray Code (less efficiency)
| Template parameters | |
|---|---|
| Container | |
| Parameters | |
| n in | |
| Returns | cppcoro::generator<Container&> |
auto ecgen:: SJT_gen(size_t n) -> cppcoro::generator< size_t >
#include <ecgen/perm.hpp>
SJT.
| Parameters | |
|---|---|
| n in | |
| Returns | cppcoro::generator<size_t> |
auto ecgen:: Ehr_gen(size_t n) -> cppcoro::generator< size_t >
#include <ecgen/perm.hpp>
Ehr.
| Parameters | |
|---|---|
| n in | |
| Returns | cppcoro::generator<size_t> |
#include <ecgen/perm.hpp>
template<size_t N>
auto ecgen:: Factorial() constexpr
Factorial, N!, the number of permutations.
| Template parameters | |
|---|---|
| N | |
| Returns | constexpr auto |
The Factorial() function is a template function that calculates the factorial of a given number N at compile-time.
#include <ecgen/perm.hpp>
template<typename Container>
auto ecgen:: SJT(Container& perm) -> cppcoro::generator< Container & >
SJT permutation by adjacent transposition (less efficiency)
| Template parameters | |
|---|---|
| Container | |
| Parameters | |
| perm in | |
| Returns | cppcoro::generator<Container&> |
#include <ecgen/perm.hpp>
template<typename Container>
auto ecgen:: Ehr(Container& perm) -> cppcoro::generator< Container & >
Ehr permutation by star transposition (less efficiency)
| Template parameters | |
|---|---|
| Container | |
| Parameters | |
| perm in | |
| Returns | cppcoro::generator<Container&> |
#include <ecgen/set_partition.hpp>
template<size_t N, size_t K>
auto ecgen:: Stirling2nd() constexpr
Stirling number of second kind.
| Template parameters | |
|---|---|
| N | |
| K | |
| Returns | constexpr auto |
auto ecgen:: set_partition_gen(size_t n,
size_t k) -> cppcoro::recursive_generator< std::pair< size_t, size_t > >
#include <ecgen/set_partition.hpp>
Set the partition gen object.
| Parameters | |
|---|---|
| n in | |
| k in | |
| Returns | cppcoro::recursive_generator<std::pair<size_t, size_t>> |