numeric
IntegerPartitioning.hpp
Go to the documentation of this file.
1 #ifndef __NUMERIC_INTEGER_PARTITIONING_HPP__
2 #define __NUMERIC_INTEGER_PARTITIONING_HPP__
3 
4 #include <map>
5 #include <set>
6 #include <vector>
7 #include <sstream>
8 #include <iostream>
9 #include <boost/foreach.hpp>
10 
11 namespace numeric {
12 
13 typedef std::vector<int> IntegerPartition;
14 
32 {
33 public:
34  typedef std::map<size_t, std::set< IntegerPartition > > PartitionsMap;
35 
36 public:
37 
46  void compute(size_t number);
47 
52  std::string toString() const;
53 
58  static std::string toString(const IntegerPartition& partition);
59 
64  static std::string toString(const std::vector<IntegerPartition>& partitionList);
65 
70  PartitionsMap getPartitionsMap() const { return mPartitionsMap; }
71 
76  static size_t multiplicity(const IntegerPartition& partition, int value);
77 
78 private:
79  PartitionsMap mPartitionsMap;
80 
81 };
82 
83 std::ostream& operator<<(std::ostream& os, const IntegerPartition& list);
84 std::ostream& operator<<(std::ostream& os, const std::vector<IntegerPartition>& list);
85 
86 } // end namespace numeric
87 #endif // __NUMERIC_INTEGER_PARTITIONING_HPP__
Computer integer partitions.
Definition: IntegerPartitioning.hpp:31
Definition: Circle.hpp:6
PartitionsMap getPartitionsMap() const
Definition: IntegerPartitioning.hpp:70
void compute(size_t number)
Definition: IntegerPartitioning.cpp:78
std::vector< int > IntegerPartition
Definition: IntegerPartitioning.hpp:13
std::map< size_t, std::set< IntegerPartition > > PartitionsMap
Definition: IntegerPartitioning.hpp:34
std::ostream & operator<<(std::ostream &os, const IntegerPartition &list)
Definition: IntegerPartitioning.cpp:19
std::string toString() const
Definition: IntegerPartitioning.cpp:121
static size_t multiplicity(const IntegerPartition &partition, int value)
Definition: IntegerPartitioning.cpp:5