|
|
Go to the documentation of this file.
22 m_SetQuantity(SetQuantity),
23 m_SubsetQuantity(SubsetQuantity) {
43 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics] No valid choice of set or subset!" << endl;
55 m_Subset.push_back(currentSubset[currentMapping[
i]]);
62 delete[] currentSubset;
63 delete[] currentMapping;
72 for (
int i = 0;
i <
size;
i++) {
81 for (
int i = 0;
i <
k;
i++) {
95 while ((permutation[
i] > permutation[
i + 1]) && (
i != 0)) {
98 if ((
i == 0) && (permutation[0] > permutation[1]))
103 if ((permutation[
j] > permutation[
i]) && (permutation[
j] < permutation[
k])) {
110 int tmp = permutation[
i];
111 permutation[
i] = permutation[
k];
112 permutation[
k] =
tmp;
115 for (
j =
i + 1;
j <= ((
size +
i) / 2);
j++) {
116 int tmp = permutation[
j];
117 permutation[
j] = permutation[
size +
i -
j];
137 if (subset[0] <
n -
k) {
140 for (
j = 0;
j <
k - 1;
j++) {
141 if (subset[
j] + 1 < subset[
j + 1]) {
146 for (
i = 0;
i < jsave;
i++)
148 subset[jsave] = subset[jsave] + 1;
161 LogDebug(
"Combinatorics") <<
"Nothing to do." << endl;
180 if (
p1.size() !=
p2.size()) {
181 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutation] permutations have different size!" << endl;
185 Float_t p1_sum = 0.0;
186 Float_t p2_sum = 0.0;
189 for (UInt_t
i = 0;
i <
p1.size();
i++)
190 p1_sum += (1 <<
p1.at(
i));
191 for (UInt_t
i = 0;
i <
p2.size();
i++)
192 p2_sum += (1 <<
p2.at(
i));
194 return (p1_sum == p2_sum ? 1 : 0);
205 vector<vector<UInt_t> > FinalCombinations;
208 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_2] Nothing to do." << endl;
209 return FinalCombinations;
214 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_2] Subset must be 4." << endl;
215 return FinalCombinations;
221 return FinalCombinations;
232 vector<vector<UInt_t> > FinalCombinations;
235 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_0] Nothing to do." << endl;
236 return FinalCombinations;
241 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::GetCombinations_2_0] Subset must be 4." << endl;
242 return FinalCombinations;
248 return FinalCombinations;
255 Bool_t Skip = kFALSE;
257 p2.push_back(
p1.at(0));
259 for (UShort_t
i = 1;
i <
p1.size();
i++) {
260 for (UShort_t
j = 0;
j <
p2.size();
j++) {
266 p2.push_back(
p1.at(
i));
276 Bool_t Skip = kFALSE;
278 p2.push_back(
p1.at(0));
280 for (UShort_t
i = 1;
i <
p1.size();
i++) {
281 for (UShort_t
j = 0;
j <
p2.size();
j++) {
287 p2.push_back(
p1.at(
i));
299 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutation_2_0] permutation has wrong size!" << endl;
304 if (((1 <<
p1.at(0)) + (1 <<
p1.at(1)) == (1 <<
p2.at(0)) + (1 <<
p2.at(1))) &&
p1.at(2) ==
p2.at(2) &&
305 p1.at(3) ==
p2.at(3)) {
319 if (
p1.size() != 4 &&
p2.size() != 4) {
320 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutationTwoByTwo] permutation(s) have wrong size!"
326 if (((1 <<
p1.at(0)) + (1 <<
p1.at(1)) == (1 <<
p2.at(0)) + (1 <<
p2.at(1))) &&
327 ((1 <<
p1.at(2)) + (1 <<
p1.at(3)) == (1 <<
p2.at(2)) + (1 <<
p2.at(3)))) {
341 if (
p1.size() !=
p2.size()) {
342 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::EqualPermutationTwoByTwo] permutation(s) have wrong size!"
359 vector<vector<UInt_t> > FinalCombinations;
362 LogDebug(
"Combinatorics") <<
"[Combinatorics::GetCombinationsThreeByOne] Nothing to do." << endl;
363 return FinalCombinations;
370 for (UInt_t
j = 1;
j < RotatingPermutation.size();
j++) {
371 FinalCombinations.push_back(
Rotate(RotatingPermutation,
j));
374 return FinalCombinations;
384 if (permutation.size() <= digm_) {
385 edm::LogWarning(
"Combinatorics") <<
"[Combinatorics::Rotate] WARNING: More rotations than digm_ in permutation!"
390 for (UInt_t
i = 0;
i < digm_;
i++) {
391 tmp.push_back(permutation.at(
i));
393 for (UInt_t
j = 0;
j < permutation.size() - digm_;
j++) {
394 p.push_back(permutation.at(
j + digm_));
396 for (UInt_t
k = 0;
k < digm_;
k++)
397 p.push_back(
tmp.at(
k));
407 for (UShort_t
i = 0;
i <
p.size();
i++) {
417 LogDebug(
"Combinatorics") <<
"**************" << endl;
418 LogDebug(
"Combinatorics") <<
"Permutations: " <<
p.size() << endl;
421 for (UShort_t
i = 0;
i <
p.size();
i++) {
422 for (UShort_t
j = 0;
j < (
p.at(0)).
size();
j++)
std::vector< UInt_t > Rotate(const std::vector< UInt_t > &permutation, UInt_t digits)
std::vector< std::vector< UInt_t > > GetCombinations_N_1()
void Skip_2_2(const std::vector< std::vector< UInt_t > > &permutation1, std::vector< std::vector< UInt_t > > &permutation2)
Int_t CalculatePermutations()
const Int_t m_SubsetQuantity
std::vector< UInt_t > m_Subset
void Print(const std::vector< UInt_t > &permutation)
void initial_subset(int k, int *subset)
std::vector< std::vector< UInt_t > > GetPermutations()
std::vector< std::vector< UInt_t > > GetCombinations_2_0()
Bool_t next_subset(int n, int k, int *subset)
Int_t EqualPermutation_2_2(const std::vector< UInt_t > &permutation1, const std::vector< UInt_t > &permutation2)
void Skip_2_0(const std::vector< std::vector< UInt_t > > &permutation1, std::vector< std::vector< UInt_t > > &permutation2)
std::vector< std::vector< UInt_t > > GetCombinations()
const Int_t m_SetQuantity
std::vector< std::vector< UInt_t > > m_Combinations
std::vector< std::vector< UInt_t > > m_Permutations
std::vector< std::vector< UInt_t > > GetCombinations_2_2()
void initial_permutation(int size, int *permutation)
Int_t EqualPermutation(const std::vector< UInt_t > &permutation1, const std::vector< UInt_t > &permutation2)
Int_t EqualPermutation_2_0(const std::vector< UInt_t > &permutation1, const std::vector< UInt_t > &permutation2)
Combinatorics(Int_t Set, Int_t Subset)
Bool_t next_permutation(int size, int *permutation)
Int_t EqualPermutation_N_1(const std::vector< UInt_t > &permutation1, const std::vector< UInt_t > &permutation2)