CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SequentialPartitionGenerator.h
Go to the documentation of this file.
1 #ifndef SequentialPartitionGenerator_H
2 #define SequentialPartitionGenerator_H
3 
4 #include <vector>
5 #include <algorithm>
6 
11 public:
12  typedef std::vector<int> Partition;
13 
14 public:
15 
16  /***
17  * Generates a (number-theoretic) partition of n into k partitions,
18  * the invidual "partitions" being between pmin and pmax.
19  */
20  SequentialPartitionGenerator(int n, int k, int pmin=1 );
21  SequentialPartitionGenerator(int n, int k, int pmin, int pmax );
27 
28 private:
29  int the_n;
30  int the_k;
31  int the_pmin;
32  int the_pmax;
34  mutable int n_first;
35  mutable int n_next;
36 
37 private:
38  bool first_part(Partition& p, int k, int n, int pmin, int pmax) const;
39  bool next_part(Partition& p) const;
40 };
41 
42 #endif
SequentialPartitionGenerator(int n, int k, int pmin=1)
bool first_part(Partition &p, int k, int n, int pmin, int pmax) const