21 m_SetQuantity(SetQuantity),
22 m_SubsetQuantity(SubsetQuantity)
51 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics] No valid choice of set or subset!" << endl;
66 m_Subset.push_back(currentSubset[currentMapping[
i]]);
75 delete[] currentSubset;
76 delete[] currentMapping;
99 for (
int i = 0;
i <
k;
i++)
112 if (size < 2)
return false;
115 while ((permutation[i] > permutation[i+1]) && (i != 0))
119 if ((i == 0) && (permutation[0] > permutation[1]))
return false;
122 for (j = i + 2; j <
size; j++ )
124 if ((permutation[j] > permutation[i]) && (permutation[j] < permutation[k]))
132 int tmp = permutation[
i];
133 permutation[
i] = permutation[
k];
134 permutation[
k] =
tmp;
137 for (j = i + 1; j <= ((size +
i) / 2); j++)
139 int tmp = permutation[
j];
140 permutation[
j] = permutation[size + i -
j];
141 permutation[size + i -
j] =
tmp;
162 if ( subset[0] < n-k )
166 for ( j = 0; j < k-1; j++ )
168 if ( subset[j] + 1 < subset[j+1] )
174 for ( i = 0; i < jsave; i++ ) subset[i] = i;
175 subset[jsave] = subset[jsave] + 1;
193 LogDebug(
"Combinatorics") <<
"Nothing to do." << endl;
216 if (p1.size() != p2.size())
218 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutation] permutations have different size!" << endl;
222 Float_t p1_sum = 0.0;
223 Float_t p2_sum = 0.0;
226 for (
UInt_t i = 0;
i < p1.size();
i++) p1_sum += (1 << p1.at(
i));
227 for (
UInt_t i = 0;
i < p2.size();
i++) p2_sum += (1 << p2.at(
i));
229 return (p1_sum == p2_sum ? 1 : 0);
242 vector< vector <UInt_t> > FinalCombinations;
246 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_2] Nothing to do." << endl;
247 return FinalCombinations;
253 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_2] Subset must be 4." << endl;
254 return FinalCombinations;
260 return FinalCombinations;
273 vector< vector <UInt_t> > FinalCombinations;
277 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_0] Nothing to do." << endl;
278 return FinalCombinations;
284 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_0] Subset must be 4." << endl;
285 return FinalCombinations;
291 return FinalCombinations;
299 vector <vector <UInt_t> > &
p2)
301 Bool_t Skip = kFALSE;
303 p2.push_back(
p1.at(0));
314 if (!Skip)
p2.push_back(
p1.at(
i));
325 vector <vector <UInt_t> > &
p2)
327 Bool_t Skip = kFALSE;
329 p2.push_back(
p1.at(0));
340 if (!Skip)
p2.push_back(
p1.at(
i));
355 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutation_2_0] permutation has wrong size!" << endl;
360 if ( ((1 << p1.at(0)) + (1 << p1.at(1)) == (1 << p2.at(0)) + (1 << p2.at(1)) ) &&
361 p1.at(2) == p2.at(2) && p1.at(3) == p2.at(3) )
378 if (p1.size() != 4 && p2.size() != 4)
380 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutationTwoByTwo] permutation(s) have wrong size!" << endl;
385 if ( ((1 << p1.at(0)) + (1 << p1.at(1)) == (1 << p2.at(0)) + (1 << p2.at(1)) ) &&
386 ((1 << p1.at(2)) + (1 << p1.at(3)) == (1 << p2.at(2)) + (1 << p2.at(3)) ) )
403 if (p1.size() != p2.size())
405 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutationTwoByTwo] permutation(s) have wrong size!" << endl;
423 vector < vector <UInt_t> > FinalCombinations;
427 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinationsThreeByOne] Nothing to do." << endl;
428 return FinalCombinations;
436 for (
UInt_t j = 1;
j < RotatingPermutation.size();
j++)
438 FinalCombinations.push_back(
Rotate(RotatingPermutation,
j));
441 return FinalCombinations;
453 if (permutation.size() <= digm_)
455 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::Rotate] WARNING: More rotations than digm_ in permutation!" << endl;
461 tmp.push_back(permutation.at(
i));
463 for (
UInt_t j = 0;
j < permutation.size() - digm_;
j++)
465 p.push_back(permutation.at(
j + digm_));
467 for (
UInt_t k = 0;
k < digm_;
k++) p.push_back(tmp.at(
k));
492 LogDebug(
"Combinatorics") <<
"**************" << endl;
493 LogDebug(
"Combinatorics") <<
"Permutations: " <<
p.size() << endl;
Int_t EqualPermutation_2_2(std::vector< UInt_t > permutation1, std::vector< UInt_t > permutation2)
std::vector< std::vector< UInt_t > > GetCombinations()
std::vector< std::vector< UInt_t > > m_Permutations
Int_t EqualPermutation_2_0(std::vector< UInt_t > permutation1, std::vector< UInt_t > permutation2)
Int_t EqualPermutation_N_1(std::vector< UInt_t > permutation1, std::vector< UInt_t > permutation2)
std::vector< std::vector< UInt_t > > GetCombinations_N_1()
std::vector< UInt_t > Rotate(std::vector< UInt_t > permutation, UInt_t digits)
Combinatorics(Int_t Set, Int_t Subset)
Int_t CalculatePermutations()
const Int_t m_SubsetQuantity
std::vector< UInt_t > m_Subset
Bool_t next_subset(int n, int k, int *subset)
const Int_t m_SetQuantity
std::vector< std::vector< UInt_t > > GetCombinations_2_0()
std::vector< std::vector< UInt_t > > m_Combinations
Bool_t next_permutation(int size, int *permutation)
std::vector< std::vector< UInt_t > > GetPermutations()
std::vector< std::vector< UInt_t > > GetCombinations_2_2()
void Skip_2_0(std::vector< std::vector< UInt_t > > permutation1, std::vector< std::vector< UInt_t > > &permutation2)
std::vector< std::vector< double > > tmp
void Skip_2_2(std::vector< std::vector< UInt_t > > permutation1, std::vector< std::vector< UInt_t > > &permutation2)
void initial_permutation(int size, int *permutation)
void initial_subset(int k, int *subset)
Int_t EqualPermutation(std::vector< UInt_t > permutation1, std::vector< UInt_t > permutation2)
void Print(std::vector< UInt_t > permutation)
tuple size
Write out results.