ATLAS Offline Software
Loading...
Searching...
No Matches
conifer Namespace Reference

Classes

class  BDT
class  DecisionTree
class  OpAdd

Functions

constexpr int floorlog2 (int x)
template<int B>
constexpr int pow (int x)
constexpr int pow2 (int x)
template<class T, class Op>
reduce (std::vector< T > x, Op op)

Function Documentation

◆ floorlog2()

int conifer::floorlog2 ( int x)
constexpr

Definition at line 25 of file conifer.h.

25{ return (x < 2) ? 0 : 1 + floorlog2(x / 2); }
#define x
constexpr int floorlog2(int x)
Definition conifer.h:25

◆ pow()

template<int B>
int conifer::pow ( int x)
constexpr

Definition at line 27 of file conifer.h.

27 {
28 return x == 0 ? 1 : B * pow<B>(x - 1);
29}
constexpr int pow(int x)
Definition conifer.h:27

◆ pow2()

int conifer::pow2 ( int x)
constexpr

Definition at line 31 of file conifer.h.

31{ return pow<2>(x); }

◆ reduce()

template<class T, class Op>
T conifer::reduce ( std::vector< T > x,
Op op )

Definition at line 33 of file conifer.h.

33 {
34 int N = x.size();
35 int leftN = pow2(floorlog2(N - 1)) > 0 ? pow2(floorlog2(N - 1)) : 0;
36 // static constexpr int rightN = N - leftN > 0 ? N - leftN : 0;
37 if (N == 1) {
38 return x.at(0);
39 } else if (N == 2) {
40 return op(x.at(0), x.at(1));
41 } else {
42 std::vector<T> left(x.begin(), x.begin() + leftN);
43 std::vector<T> right(x.begin() + leftN, x.end());
44 return op(reduce<T, Op>(std::move(left), op), reduce<T, Op>(std::move(right), op));
45 }
46}
static const std::map< unsigned int, unsigned int > pow2
T reduce(std::vector< T > x, Op op)
Definition conifer.h:33