CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CommonTools/Statistics/interface/SequentialPartitionGenerator.h

Go to the documentation of this file.
00001 #ifndef SequentialPartitionGenerator_H
00002 #define SequentialPartitionGenerator_H
00003 
00004 #include <vector>
00005 #include <algorithm>
00006 
00010 class SequentialPartitionGenerator {
00011 public:
00012   typedef std::vector<int> Partition;
00013 
00014 public:
00015 
00016   /***
00017    *   Generates a (number-theoretic) partition of n into k partitions,
00018    *   the invidual "partitions" being between pmin and pmax.
00019    */
00020   SequentialPartitionGenerator(int n, int k, int pmin=1 );
00021   SequentialPartitionGenerator(int n, int k, int pmin, int pmax );
00026   Partition next_partition();
00027 
00028 private:
00029   int the_n;
00030   int the_k;
00031   int the_pmin;
00032   int the_pmax;
00033   Partition the_part;
00034   mutable int n_first;
00035   mutable int n_next;
00036 
00037 private:
00038   bool first_part(Partition& p, int k, int n, int pmin, int pmax) const;
00039   bool next_part(Partition& p) const;
00040 };
00041 
00042 #endif