1 #ifndef NPSTAT_KDTREE_HH_
2 #define NPSTAT_KDTREE_HH_
35 template <
class Po
int,
typename Numeric=
double>
39 typedef Point value_type;
40 typedef Numeric coord_type;
52 KDTree(
const std::vector<Point>& points,
53 const unsigned* dimsToUse,
unsigned nDimsToUse);
60 inline const std::vector<Point>&
inputPoints()
const {
return points_;}
63 inline unsigned nPoints()
const {
return nPoints_;}
66 inline unsigned nNodes()
const {
return nodes_.size();}
72 inline unsigned dim()
const {
return dim_;}
77 if (i >= dim_)
throw std::out_of_range(
78 "In npstat::KDTree::pointIndex: index out of range");
88 unsigned nCdf(
const Numeric* limit,
unsigned limitDim)
const;
96 {
return nInBox(box, standardBi_);}
105 const std::vector<BoundaryInclusion>& bv)
const;
112 template <
class Result>
124 inline KDTreeNode() : point(0), split(Numeric()), splitIndex(0),
125 nPoints(0), left(0), right(0) {}
134 unsigned pointLessOrEqual(
const Point* pt,
const Numeric* coord)
const;
135 unsigned coordsLessOrEqual(
const Numeric* c1,
const Numeric* c2)
const;
136 unsigned pointInBox(
const Point* pt,
const BoxND<Numeric>& box,
137 const std::vector<BoundaryInclusion>& bv)
const;
138 bool limitsInBox(
const BoxND<Numeric>& box,
const Numeric* lowerLimit,
139 const Numeric* upperLimit)
const;
141 unsigned addNode(std::vector<const Point*>& pointers,
142 unsigned level,
unsigned ibegin,
unsigned iend);
146 unsigned countBelow(
unsigned inode,
const Numeric* limit,
147 Numeric* upperLimit)
const;
150 unsigned countInBox(
unsigned inode,
const BoxND<Numeric>& box,
151 const std::vector<BoundaryInclusion>& bv,
152 Numeric* lowerLimit, Numeric* upperLimit)
const;
155 template <
class Result>
156 void visitorRecursion(AbsVisitor<Point,Result>& visitor,
157 unsigned inode,
const BoxND<Numeric>& box,
158 Numeric* lowerLimit, Numeric* upperLimit,
159 bool knownInside)
const;
161 const std::vector<Point>& points_;
163 std::vector<KDTreeNode> nodes_;
167 mutable std::vector<Numeric> lolim_;
168 mutable std::vector<Numeric> uplim_;
169 std::vector<BoundaryInclusion> standardBi_;
173 #include "npstat/nm/KDTree.icc"
Interface for piecemeal processing of a data collection.
Enumeration of possible boundary inclusions for an interval.
Template to represent rectangles, boxes, and hyperboxes.
void visitInBox(AbsVisitor< Point, Result > &visitor, const BoxND< Numeric > &box) const
unsigned nPoints() const
Definition: KDTree.hh:63
unsigned nInBox(const BoxND< Numeric > &box) const
Definition: KDTree.hh:95
unsigned nInBox(const BoxND< Numeric > &box, const std::vector< BoundaryInclusion > &bv) const
unsigned pointIndex(const unsigned i) const
Definition: KDTree.hh:75
unsigned dim() const
Definition: KDTree.hh:72
unsigned nNodes() const
Definition: KDTree.hh:66
const std::vector< Point > & inputPoints() const
Definition: KDTree.hh:60
unsigned nCdf(const Numeric *limit, unsigned limitDim) const
KDTree(const std::vector< Point > &points, const unsigned *dimsToUse, unsigned nDimsToUse)
Definition: AbsArrayProjector.hh:14
Definition: AbsVisitor.hh:20