Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
CommonTools
Statistics
src
SequentialPartitionGenerator.cc
Go to the documentation of this file.
1
#include "
CommonTools/Statistics/interface/SequentialPartitionGenerator.h
"
2
3
SequentialPartitionGenerator::SequentialPartitionGenerator
(
int
n
,
int
k
,
int
pmin ) :
4
the_n(n), the_k(k), the_pmin(pmin), the_pmax(n) {}
5
6
SequentialPartitionGenerator::SequentialPartitionGenerator
(
int
n
,
int
k
,
int
pmin,
int
pmax) :
7
the_n(n), the_k(k), the_pmin(pmin), the_pmax(pmax) {}
8
9
SequentialPartitionGenerator::Partition
SequentialPartitionGenerator::next_partition
()
10
{
11
bool
done
=
next_part
(
the_part
);
12
if
(done)
13
{
14
return
the_part
;
15
};
16
SequentialPartitionGenerator::Partition
empty
;
17
return
empty
;
18
}
19
20
bool
SequentialPartitionGenerator::first_part
(
21
SequentialPartitionGenerator::Partition
&
p
,
int
k
,
int
n
,
int
pmin,
int
pmax )
const
22
{
23
n_first
++;
24
bool
done
=
false
;
25
switch
(k) {
26
case
1:
27
p[0]=
std::min
(pmax,n);
28
return
(n<=pmax && p[0]>=pmin);
29
case
2:
30
for
(
int
i
=
std::min
(pmax,n-1);
i
>=pmin;
i
--) {
31
if
((done=(
i
>=n-
i
&& n-
i
>=pmin))) {p[0]=
i
;p[1]=n-
i
;}
32
return
done
;
33
}
34
default
:
35
Partition
pp
(p.begin()+1,p.end());
36
for
(
int
i
=
std::min
(pmax,n-k+1);
i
>=pmin;
i
--) {
37
p[0]=
i
;
38
done=this->
first_part
(
pp
,k-1,n-p[0],pmin,p[0]);
39
if
(done) {
copy
(
pp
.begin(),
pp
.end(),p.begin()+1);}
40
return
done
;
41
}
42
}
43
return
done
;
44
}
45
46
bool
SequentialPartitionGenerator::next_part
(
47
SequentialPartitionGenerator::Partition
&
p
)
const
48
{
49
n_next
++;
50
bool
done
=
false
;
51
int
k
=p.size();
52
switch
(k) {
53
case
0:
// empty partition: first call to next_part, initialize
54
p.insert(p.begin(),
the_k
,0);
55
return
this->
first_part
(p,
the_k
,
the_n
,
the_pmin
,
the_pmax
);
56
case
1:
57
return
false
;
58
default
:
59
int
n
=0;
60
for
(
int
i
=0;
i
<
k
;
i
++) n=n+p[
i
];
61
SequentialPartitionGenerator::Partition
pp
(p.begin()+1,p.end());
62
done = (
pp
.size()>1 ? this->
next_part
(
pp
) :
false
);
63
if
(done)
64
{
65
copy
(
pp
.begin(),
pp
.end(),p.begin()+1);
66
}
else
{
67
done = (p[0]==1 ?
false
:
68
this->
first_part
(
pp
,k-1,n-p[0]+1,
the_pmin
,p[0]-1));
69
if
(done) { --p[0];
copy
(
pp
.begin(),
pp
.end(),p.begin()+1); }
70
};
71
return
done
;
72
};
73
return
done
;
74
}
relativeConstraints.empty
empty
Definition:
relativeConstraints.py:45
run_regression.done
done
Definition:
run_regression.py:387
i
int i
Definition:
DBlmapReader.cc:9
createTree.pp
tuple pp
Definition:
createTree.py:15
SequentialPartitionGenerator::the_part
Partition the_part
Definition:
SequentialPartitionGenerator.h:33
SequentialPartitionGenerator::SequentialPartitionGenerator
SequentialPartitionGenerator(int n, int k, int pmin=1)
Definition:
SequentialPartitionGenerator.cc:3
min
#define min(a, b)
Definition:
mlp_lapack.h:161
SequentialPartitionGenerator::the_pmax
int the_pmax
Definition:
SequentialPartitionGenerator.h:32
SequentialPartitionGenerator.h
SequentialPartitionGenerator::n_next
int n_next
Definition:
SequentialPartitionGenerator.h:35
SequentialPartitionGenerator::next_part
bool next_part(Partition &p) const
Definition:
SequentialPartitionGenerator.cc:46
filterCSVwithJSON.copy
tuple copy
Definition:
filterCSVwithJSON.py:35
gen::k
int k[5][pyjets_maxn]
Definition:
Cascade2Hadronizer.cc:81
SequentialPartitionGenerator::first_part
bool first_part(Partition &p, int k, int n, int pmin, int pmax) const
Definition:
SequentialPartitionGenerator.cc:20
SequentialPartitionGenerator::the_pmin
int the_pmin
Definition:
SequentialPartitionGenerator.h:31
SequentialPartitionGenerator::Partition
std::vector< int > Partition
Definition:
SequentialPartitionGenerator.h:12
n
int n
Definition:
DTDataIntegrityTask.cc:33
SequentialPartitionGenerator::next_partition
Partition next_partition()
Definition:
SequentialPartitionGenerator.cc:9
AlCaHLTBitMon_ParallelJobs.p
tuple p
Definition:
AlCaHLTBitMon_ParallelJobs.py:152
SequentialPartitionGenerator::the_k
int the_k
Definition:
SequentialPartitionGenerator.h:30
SequentialPartitionGenerator::n_first
int n_first
Definition:
SequentialPartitionGenerator.h:34
SequentialPartitionGenerator::the_n
int the_n
Definition:
SequentialPartitionGenerator.h:29
Generated for CMSSW Reference Manual by
1.8.5