269template <
typename  Index, 
typename Value>
 
  283   ,fBoundaries(nullptr)
 
 
  291template <
typename  Index, 
typename Value>
 
  305   ,fBoundaries(nullptr)
 
 
  343template <
typename  Index, 
typename Value>
 
  357   ,fBoundaries(nullptr)
 
 
  372template <
typename  Index, 
typename Value>
 
  375   if (fAxis) 
delete [] fAxis;
 
  376   if (fValue) 
delete [] fValue;
 
  377   if (fIndPoints) 
delete [] fIndPoints;
 
  378   if (fRange) 
delete [] fRange;
 
  379   if (fBoundaries) 
delete [] fBoundaries;
 
 
  410template <
typename  Index, 
typename Value>
 
  414   fNNodes = fNPoints/fBucketSize-1;
 
  415   if (fNPoints%fBucketSize) fNNodes++;
 
  416   fTotalNodes = fNNodes + fNPoints/fBucketSize + ((fNPoints%fBucketSize)?1:0);
 
  419   for ( ;(fNNodes+1)>(1<<fRowT0);fRowT0++) {}
 
  431   fRange = 
new Value[2*fNDim];
 
  432   fIndPoints= 
new Index[fNPoints];
 
  433   for (Index i=0; i<fNPoints; i++) fIndPoints[i] = i;
 
  435   fValue = 
new Value[fNNodes];
 
  437   fCrossNode = (1<<(fRowT0+1))-1;
 
  438   if (fCrossNode<fNNodes) fCrossNode = 2*fCrossNode+1;
 
  442   Int_t   filled = ((1<<fRowT0)-
over)*fBucketSize;
 
  443   fOffset = fNPoints-filled;
 
  509         fRange[2*
idim] = min; fRange[2*
idim+1] = max;
 
 
  542template <
typename  Index, 
typename Value>
 
  547      Error(
"FindNearestNeighbors", 
"Working arrays must be allocated by the user!");
 
  551      dist[i]=std::numeric_limits<Value>::max();
 
  554   MakeBoundariesExact();
 
  555   UpdateNearestNeighbors(0, point, 
kNN, 
ind, dist);
 
 
  562template <
typename Index, 
typename Value>
 
  567   DistanceToNode(point, 
inode, min, max);
 
  568   if (min > dist[
kNN-1]){
 
  572   if (IsTerminal(
inode)) {
 
  597      UpdateNearestNeighbors(GetLeft(
inode), point, 
kNN, 
ind, dist);
 
  598      UpdateNearestNeighbors(GetRight(
inode), point, 
kNN, 
ind, dist);
 
  600      UpdateNearestNeighbors(GetRight(
inode), point, 
kNN, 
ind, dist);
 
  601      UpdateNearestNeighbors(GetLeft(
inode), point, 
kNN, 
ind, dist);
 
 
  609template <
typename Index, 
typename Value>
 
  634template <
typename Index, 
typename Value>
 
  671template <
typename  Index, 
typename Value>
 
  702template <
typename  Index, 
typename Value>
 
  713      if (IsTerminal(
inode)){
 
  721            if (
indexIP>=fNPoints) 
continue;
 
 
  748template <
typename  Index, 
typename Value>
 
  751   MakeBoundariesExact();
 
  752   UpdateRange(0, point, 
range, res);
 
 
  758template <
typename  Index, 
typename Value>
 
  762   DistanceToNode(point, 
inode, min, max);
 
  774         res.push_back(fIndPoints[
ipoint]);
 
  777         res.push_back(fIndPoints[
ipoint]);
 
  783   if (IsTerminal(
inode)){
 
  789         d = Distance(point, fIndPoints[
ipoint]);
 
  791            res.push_back(fIndPoints[
ipoint]);
 
  798      UpdateRange(GetLeft(
inode),point, 
range, res);
 
  799      UpdateRange(GetRight(
inode),point, 
range, res);
 
  801      UpdateRange(GetLeft(
inode),point, 
range, res);
 
  802      UpdateRange(GetRight(
inode),point, 
range, res);
 
 
  811template <
typename Index, 
typename Value>
 
  814   if (!IsTerminal(node)){
 
  815      printf(
"GetPointsIndexes() only for terminal nodes, use GetNodePointsIndexes() instead\n");
 
  818   Int_t offset = (node >= fCrossNode) ? (node-fCrossNode)*fBucketSize : fOffset+(node-fNNodes)*fBucketSize;
 
  819   return &fIndPoints[
offset];
 
 
  840template <
typename Index, 
typename Value>
 
  844   if (IsTerminal(node)){
 
  846      Index 
offset = (node >= fCrossNode) ? (node-fCrossNode)*fBucketSize : fOffset+(node-fNNodes)*fBucketSize;
 
  876      GetNodePointsIndexes(fTotalNodes-1, 
f1, 
l1, f2, 
l2);
 
 
  894template <
typename Index, 
typename Value>
 
  897   if (IsTerminal(
inode)){
 
  899      if (
inode!=fTotalNodes-1) 
return fBucketSize;
 
  901         if (fOffset%fBucketSize==0) 
return fBucketSize;
 
  902         else return fOffset%fBucketSize;
 
 
  917template <
typename  Index, 
typename Value>
 
  942template <
typename  Index, 
typename Value>
 
  945   if (fAxis || fValue) {
 
  946      Error(
"SetData", 
"The tree has already been built, no updates possible");
 
  951      fData = 
new Value*[fNDim];
 
 
  962template <
typename  Index, 
typename Value>
 
  979template <
typename  Index, 
typename Value>
 
 1033template <
typename Index, 
typename Value>
 
 1039   Int_t totNodes = fNNodes + fNPoints/fBucketSize + ((fNPoints%fBucketSize)?1:0);
 
 1053      if(IsTerminal(cn)) CookBoundaries(
inode, 
kTRUE);
 
 1054      cbounds = &fBoundaries[fNDimm*cn];
 
 1060      cbounds = &fBoundaries[fNDimm*cn];
 
 
 1068template <
typename Index, 
typename Value>
 
 1083   while(
pn >= 0 && 
nvals < fNDimm){
 
 
 1113template <
typename Index, 
typename Value>
 
 1123   fBoundaries = 
new Value[fTotalNodes*fNDimm];
 
 1129         min[
idim]= std::numeric_limits<Value>::max();
 
 1130         max[
idim]=-std::numeric_limits<Value>::max();
 
 1155      left = GetLeft(
inode)*fNDimm;
 
 1156      right = GetRight(
inode)*fNDimm;
 
 
 1172template <
typename  Index, 
typename Value>
 
 1175   for (;
inode<fNNodes;){
 
 
 1184template <
typename  Index, 
typename Value>
 
 1187   if(!fBoundaries) MakeBoundaries();
 
 
 1195template <
typename  Index, 
typename Value>
 
 1198   if(!fBoundaries) MakeBoundariesExact();
 
 
 1205template <
typename  Index, 
typename Value>
 
 1208   if(!fBoundaries) MakeBoundaries();
 
 1209   return &fBoundaries[node*2*fNDim];
 
 
 1215template <
typename  Index, 
typename Value>
 
 1218   if(!fBoundaries) MakeBoundariesExact();
 
 1219   return &fBoundaries[node*2*fNDim];
 
 
#define templateClassImp(name)
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
 
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
 
TKDTreeIF * TKDTreeTestBuild()
 
TKDTree< Int_t, Float_t > TKDTreeIF
 
R__EXTERN TRandom * gRandom
 
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
 
Class implementing a kd-tree.
 
void FindPoint(Value *point, Index &index, Int_t &iter)
find the index of point works only if we keep fData pointers
 
void SetData(Index npoints, Index ndim, UInt_t bsize, Value **data)
Set the data array. See the constructor function comments for details.
 
~TKDTree() override
Destructor By default, the original data is not owned by kd-tree and is not deleted with it.
 
void GetNodePointsIndexes(Int_t node, Int_t &first1, Int_t &last1, Int_t &first2, Int_t &last2) const
Return the indices of points in that node Indices are returned as the first and last value of the par...
 
Value * GetBoundaryExact(const Int_t node)
Get a boundary.
 
void FindBNodeA(Value *point, Value *delta, Int_t &inode)
find the smallest node covering the full range - start
 
void UpdateRange(Index inode, Value *point, Value range, std::vector< Index > &res)
Internal recursive function with the implementation of range searches.
 
Index FindNode(const Value *point) const
returns the index of the terminal node to which point belongs (index in the fAxis,...
 
Value KOrdStat(Index ntotal, Value *a, Index k, Index *index) const
copy of the TMath::KOrdStat because I need an Index work array
 
Value * GetBoundariesExact()
Get the boundaries.
 
void MakeBoundariesExact()
Build boundaries for each node.
 
void CookBoundaries(const Int_t node, Bool_t left)
define index of this terminal node
 
void MakeBoundaries(Value *range=nullptr)
Build boundaries for each node.
 
void UpdateNearestNeighbors(Index inode, const Value *point, Int_t kNN, Index *ind, Value *dist)
Update the nearest neighbors values by examining the node inode.
 
Double_t Distance(const Value *point, Index ind, Int_t type=2) const
Find the distance between point of the first argument and the point at index value ind Type argument ...
 
Index * GetPointsIndexes(Int_t node) const
return the indices of the points in that terminal node for all the nodes except last,...
 
void Spread(Index ntotal, Value *a, Index *index, Value &min, Value &max) const
Calculate spread of the array a.
 
void Build()
Build the kd-tree.
 
void DistanceToNode(const Value *point, Index inode, Value &min, Value &max, Int_t type=2)
Find the minimal and maximal distance from a given point to a given node.
 
TKDTree()
Default constructor. Nothing is built.
 
void FindInRange(Value *point, Value range, std::vector< Index > &res)
Find all points in the sphere of a given radius "range" around the given point 1st argument - the poi...
 
Index GetNPointsNode(Int_t node) const
Get number of points in this node for all the terminal nodes except last, the size is fBucketSize for...
 
Value * GetBoundaries()
Get the boundaries.
 
Value * GetBoundary(const Int_t node)
Get a boundary.
 
void FindNearestNeighbors(const Value *point, Int_t k, Index *ind, Value *dist)
Find kNN nearest neighbors to the point in the first argument Returns 1 on success,...
 
kNN::Event describes point in input variable vector-space, with additional functionality like distanc...
 
Mother of all ROOT objects.
 
Double_t Rndm() override
Machine independent random number generator.
 
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
 
Double_t Sqrt(Double_t x)
Returns the square root of x.
 
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
 
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
 
static uint64_t sum(uint64_t i)