Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef COMBINATORICS_H
00009 #define COMBINATORICS_H
00010
00011
00012 #include <vector>
00013
00014
00015 #include <TROOT.h>
00016
00017 class Combinatorics
00018 {
00019
00020 public:
00021
00022 Combinatorics(Int_t Set, Int_t Subset);
00023 virtual ~Combinatorics();
00024
00025 std::vector < std::vector <UInt_t> > GetPermutations();
00026 std::vector < std::vector <UInt_t> > GetCombinations();
00027 std::vector < std::vector <UInt_t> > GetCombinations_2_0();
00028 std::vector < std::vector <UInt_t> > GetCombinations_2_2();
00029 std::vector < std::vector <UInt_t> > GetCombinations_N_1();
00030
00031 Int_t EqualPermutation(std::vector<UInt_t> permutation1,
00032 std::vector<UInt_t> permutation2);
00033 Int_t EqualPermutation_2_0(std::vector<UInt_t> permutation1,
00034 std::vector<UInt_t> permutation2);
00035 Int_t EqualPermutation_2_2(std::vector<UInt_t> permutation1,
00036 std::vector<UInt_t> permutation2);
00037 Int_t EqualPermutation_N_1(std::vector<UInt_t> permutation1,
00038 std::vector<UInt_t> permutation2);
00039
00040 void Print(std::vector<UInt_t> permutation);
00041 void Print(std::vector <std::vector <UInt_t> > permutations);
00042
00043 private:
00044
00045 Int_t CalculatePermutations();
00046
00047 void initial_permutation(int size, int *permutation);
00048 Bool_t next_permutation(int size, int *permutation);
00049 void initial_subset(int k, int *subset);
00050 Bool_t next_subset(int n, int k, int *subset);
00051
00052 void Skip_2_0(std::vector <std::vector <UInt_t> > permutation1,
00053 std::vector <std::vector <UInt_t> > &permutation2);
00054 void Skip_2_2(std::vector <std::vector <UInt_t> > permutation1,
00055 std::vector <std::vector <UInt_t> > &permutation2);
00056
00057 std::vector<UInt_t> Rotate(std::vector <UInt_t> permutation, UInt_t digits);
00058
00059 const Int_t m_SetQuantity;
00060 const Int_t m_SubsetQuantity;
00061
00062 std::vector<UInt_t> m_Subset;
00063 std::vector <std::vector <UInt_t> > m_Permutations;
00064 std::vector <std::vector <UInt_t> > m_Combinations;
00065 };
00066
00067 #endif