Symmetric Polynomials  V3.1
A C++ library for generating symmetric polynomials with relations
Generators.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <algorithm>
3 #include <vector>
4 #include <array>
5 #include "General.hpp"
6 
9 
10 namespace symmp
11 {
12 
24  template <class spec_t, class gen_t>
26  {
27  public:
28  const gen_t &operator*() const;
29  bool operator!=(const FactoryGenerator &other) const;
30  spec_t &operator++();
31  static spec_t end();
32  protected:
33  bool completed;
34  gen_t generated;
35  };
36 
45  template <class T>
47  {
48  const T n;
49 
50  public:
53  size_t size() const;
54 
58 
61  class ConstIterator : public FactoryGenerator<PermutationGenerator::ConstIterator, std::vector<T>>
62  {
63  void update();
64  friend class PermutationGenerator;
65  friend class FactoryGenerator<PermutationGenerator::ConstIterator, std::vector<T>>;
66  };
67 
71 
74  ConstIterator end() const;
75  };
76 
85  template <class T>
87  {
88  const T total, choices;
89 
90  public:
93  auto size() const;
94 
98  CombinationGenerator(T total, T choices);
99 
102  class ConstIterator : public FactoryGenerator<CombinationGenerator::ConstIterator, std::vector<T>>
103  {
104  void update();
105  friend class CombinationGenerator;
106  friend class FactoryGenerator<CombinationGenerator::ConstIterator, std::vector<T>>;
107  T total, choices;
108  };
109 
113 
117  };
118 
123  template <class T>
124  std::vector<std::vector<T>> all_permutations(T n);
125 
131  template <class T>
132  std::vector<std::vector<T>> all_combinations(T n, T m);
133 }
134 #include "impl/Generators.ipp"
Contains general operations on vectors: hashing, computing degrees.
Constant iterator that is used in a ranged for loop to generate the combinations.
Definition: Generators.hpp:103
Generates all combinations on a number of letters making a number of choices.
Definition: Generators.hpp:87
CombinationGenerator(T total, T choices)
Sets up the generator.
auto size() const
Computes total number of combinations.
Prototype for coroutine-like iterators that generate elements such as combinations.
Definition: Generators.hpp:26
bool operator!=(const FactoryGenerator &other) const
Inequality of iterators (used to detect if generation has been completed)
spec_t & operator++()
Generates next element.
static spec_t end()
Terminal iterator.
bool completed
1 if the iterator is end() i.e. if all elements have been generated
Definition: Generators.hpp:33
const gen_t & operator*() const
Returns the generated element.
gen_t generated
The currently generated element.
Definition: Generators.hpp:34
Constant iterator that is used in a ranged for loop to generate the permutations.
Definition: Generators.hpp:62
Generates all permutations on a number of letters.
Definition: Generators.hpp:47
size_t size() const
Computes total number of permutations.
PermutationGenerator(T n)
Constructor sets up the generator.
ConstIterator begin() const
Begin iterator.
The namespace which contains every method and class in the library.
Definition: General.hpp:16
std::vector< std::vector< T > > all_combinations(T n, T m)
Returns vector of all combinations on n letters choosing m many.
std::vector< std::vector< T > > all_permutations(T n)
Returns vector of all permutations on n letters.