85 std::vector<std::vector<int>>
partitions(
int n);
92 std::vector<int64_t>
bell_num(
int n);
198 std::vector<int> &partition,
199 std::vector<std::vector<int>> &result);
210 std::vector<int> &partition,
211 std::vector<std::vector<int>> &result);
222 std::vector<int> &composition,
223 std::vector<std::vector<int>> &result);
249 std::vector<std::vector<int>> &
necklaces);
276 template <
typename T>
286 template <
typename T>
287 std::vector<std::vector<T>>
combinations(
const std::vector<T> &vec,
int r);
A class providing various combinatorial functions and algorithms.
void gen_dyck_words(std::string prefix, int open, int close, std::vector< std::string > &dyck_words)
Generate Dyck words.
int64_t subfactorial(int n)
Calculate the subfactorial (!n) or derangement of n.
int phi(int n)
Calculate Euler's totient function (φ)
int64_t necklaces(int n, int k)
Calculate the number of necklaces of length n with k colors.
void gen_compositions(int n, int max, std::vector< int > &composition, std::vector< std::vector< int >> &result)
Generate compositions of a positive integer.
void gen_partition_distinct(int n, int max, std::vector< int > &partition, std::vector< std::vector< int >> &result)
Generate distinct partitions of a positive integer.
void generatePartitions(int n, int max, std::vector< int > &partition, std::vector< std::vector< int >> &result)
Generate partitions of a positive integer.
int64_t lyndonWords(int n)
Calculate the number of Lyndon words of length n.
std::vector< int64_t > bell_num(int n)
Calculate the Bell numbers.
int64_t dyck_words(int n)
Calculate the number of Dyck words of length 2n.
int64_t binom_coeff(int n, int r)
Calculate the binomial coefficient (n choose r)
void gen_necklaces(std::vector< int > &necklace, int index, int n, int k, std::vector< std::vector< int >> &necklaces)
Generate necklaces.
int64_t factorial(int n)
Calculate the factorial of a number.
std::vector< std::vector< int > > partitions(int n)
Generate all partitions of a positive integer n.
std::vector< int > gray_code(int n)
Generate the Gray code sequence of length n.
std::vector< std::vector< int > > partition_distinct(int n)
Generate all distinct partitions of a positive integer n.
std::vector< int > divisors(int n)
Calculate the divisors of a positive integer.
int64_t permutation(int n, int r)
Calculate the number of permutations (nPr)
int64_t stirling_num(int n, int k)
Calculate the Stirling number of the second kind.
int64_t combination(int n, int r)
Calculate the number of combinations (nCr)
std::vector< std::vector< int > > compositions(int n)
Generate all compositions of a positive integer n.
void gen_lyndon_words(std::string prefix, int n, int max, std::vector< std::string > &lyndonWords)
Generate Lyndon words.
int64_t subsequences(int n, int k)
Calculate the number of subsequences of length k from n items.
std::vector< std::vector< T > > combinations(const std::vector< T > &vec, int r)
Generate all combinations of a vector.
std::vector< std::string > generateLyndonWords(int n)
Generate all Lyndon words of length n.
std::vector< std::vector< T > > permutations(const std::vector< T > &vec)
Generate all permutations of a vector.
std::vector< std::string > gen_dyck_words_until(int n)
Generate Dyck words up to length n.
std::vector< std::vector< int > > generateNecklaces(int n, int k)
Generate all necklaces of length n with k colors.
The source C++ openGPMP namespace.