9 template <
typename Index,
typename Value>
class TKDTree :
public TObject
14 TKDTree(Index npoints, Index ndim, UInt_t bsize);
15 TKDTree(Index npoints, Index ndim, UInt_t bsize, Value **data);
20 Double_t Distance(
const Value *point, Index ind, Int_t type=2)
const;
21 void DistanceToNode(
const Value *point, Index inode, Value &min, Value &max, Int_t type=2);
24 Int_t GetLeft(Int_t inode)
const {
return inode*2+1;}
25 Int_t GetRight(Int_t inode)
const {
return (inode+1)*2;}
26 Int_t GetParent(Int_t inode)
const {
return (inode-1)/2;}
29 Index* GetPointsIndexes(Int_t node)
const;
30 void GetNodePointsIndexes(Int_t node, Int_t &first1, Int_t &last1, Int_t &first2, Int_t &last2)
const;
31 UChar_t GetNodeAxis(Int_t
id)
const {
return (id < 0 || id >= fNNodes) ? 0 : fAxis[id];}
32 Value GetNodeValue(Int_t
id)
const {
return (id < 0 || id >= fNNodes) ? 0 : fValue[id];}
33 Int_t GetNNodes()
const {
return fNNodes;}
34 Int_t GetTotalNodes()
const {
return fTotalNodes;}
35 Value* GetBoundaries();
36 Value* GetBoundariesExact();
37 Value* GetBoundary(
const Int_t node);
38 Value* GetBoundaryExact(
const Int_t node);
39 Index GetNPoints() {
return fNPoints; }
40 Index GetNDim() {
return fNDim; }
41 Index GetNPointsNode(Int_t node)
const;
44 Int_t GetRowT0() {
return fRowT0;}
45 Int_t GetCrossNode() {
return fCrossNode;}
46 Int_t GetOffset() {
return fOffset;}
47 Index* GetIndPoints() {
return fIndPoints;}
48 Index GetBucketSize() {
return fBucketSize;}
50 void FindNearestNeighbors(
const Value *point, Int_t k, Index *ind, Value *dist);
51 Index FindNode(
const Value * point)
const;
52 void FindPoint(Value * point, Index &index, Int_t &iter);
53 void FindInRange(Value *point, Value range, std::vector<Index> &res);
54 void FindBNodeA(Value * point, Value * delta, Int_t &inode);
56 Bool_t IsTerminal(Index inode)
const {
return (inode>=fNNodes);}
57 Int_t IsOwner() {
return fDataOwner; }
58 Value KOrdStat(Index ntotal, Value *a, Index k, Index *index)
const;
61 void MakeBoundaries(Value *range = 0x0);
62 void MakeBoundariesExact();
63 void SetData(Index npoints, Index ndim, UInt_t bsize, Value **data);
64 Int_t SetData(Index idim, Value *data);
65 void SetOwner(Int_t owner) { fDataOwner = owner; }
66 void Spread(Index ntotal, Value *a, Index *index, Value &min, Value &max)
const;
69 TKDTree(
const TKDTree &);
70 TKDTree<Index, Value>& operator=(
const TKDTree<Index, Value>&);
71 void CookBoundaries(
const Int_t node, Bool_t left);
73 void UpdateNearestNeighbors(Index inode,
const Value *point, Int_t kNN, Index *ind, Value *dist);
74 void UpdateRange(Index inode, Value *point, Value range, std::vector<Index> &res);
104 typedef TKDTree<Int_t, Double_t> TKDTreeID;
105 typedef TKDTree<Int_t, Float_t> TKDTreeIF;
108 TKDTreeIF * TKDTreeTestBuild();