npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::KDTree< Point, Numeric > Class Template Reference

#include <KDTree.hh>

Public Types

typedef Point value_type
 
typedef Numeric coord_type
 

Public Member Functions

 KDTree (const std::vector< Point > &points, const unsigned *dimsToUse, unsigned nDimsToUse)
 
const std::vector< Point > & inputPoints () const
 
unsigned nPoints () const
 
unsigned nNodes () const
 
unsigned dim () const
 
unsigned pointIndex (const unsigned i) const
 
unsigned nCdf (const Numeric *limit, unsigned limitDim) const
 
unsigned nInBox (const BoxND< Numeric > &box) const
 
unsigned nInBox (const BoxND< Numeric > &box, const std::vector< BoundaryInclusion > &bv) const
 
template<class Result >
void visitInBox (AbsVisitor< Point, Result > &visitor, const BoxND< Numeric > &box) const
 

Detailed Description

template<class Point, typename Numeric = double>
class npstat::KDTree< Point, Numeric >

Basic k-d tree template. See, for example, http://en.wikipedia.org/wiki/K-d_tree for the computational geometry ideas behind this type of space partitioning.

Intended for speeding up the construction of empirical copulas or copula densities. Can also be used for "sliding window" kernel density estimation, local regression, etc.

Class Point must possess operator[] which returns an object or reference to Numeric or some other type which can be automatically converted to Numeric.

Constructor & Destructor Documentation

◆ KDTree()

template<class Point , typename Numeric = double>
npstat::KDTree< Point, Numeric >::KDTree ( const std::vector< Point > &  points,
const unsigned *  dimsToUse,
unsigned  nDimsToUse 
)

For efficiency reasons, this class will not make an internal copy of the "points" vector. This vector must not be modified after KDTree construction. Otherwise tree pointers will become invalid.

The arguments "dimsToUse" (and "nDimsToUse" which is the length of the "dimsToUse" array) specify which point dimensions should be used to construct the tree.

Member Function Documentation

◆ dim()

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::dim ( ) const
inline

The tree dimensionality (less or equal to the dimensionality of points used to construct the tree)

◆ inputPoints()

template<class Point , typename Numeric = double>
const std::vector<Point>& npstat::KDTree< Point, Numeric >::inputPoints ( ) const
inline

Return the reference to the vector of points used to construct the tree

◆ nCdf()

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::nCdf ( const Numeric *  limit,
unsigned  limitDim 
) const

Number of points whose coordinates are all equal to or below the corresponding coordinates of the "limit" array. The length of this array must be equal to the tree dimensionality.

◆ nInBox() [1/2]

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::nInBox ( const BoxND< Numeric > &  box) const
inline

Number of points whose coordinates are all inside the given box (including the upper boundaries). The box dimensionality must be equal to the tree dimensionality.

◆ nInBox() [2/2]

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::nInBox ( const BoxND< Numeric > &  box,
const std::vector< BoundaryInclusion > &  bv 
) const

Number of points whose coordinates are all inside the given box with the boundary inclusion handling provided. The box dimensionality must be equal to the tree dimensionality and to the size of the boundary inclusion vector.

◆ nNodes()

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::nNodes ( ) const
inline

Total number of nodes (trunk and leaf)

◆ nPoints()

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::nPoints ( ) const
inline

The size of the vector of points used to construct the tree

◆ pointIndex()

template<class Point , typename Numeric = double>
unsigned npstat::KDTree< Point, Numeric >::pointIndex ( const unsigned  i) const
inline

The point dimensions used for tree construction

◆ visitInBox()

template<class Point , typename Numeric = double>
template<class Result >
void npstat::KDTree< Point, Numeric >::visitInBox ( AbsVisitor< Point, Result > &  visitor,
const BoxND< Numeric > &  box 
) const

Visit all points inside the given box (including the upper boundaries). This function will not call either "clear()" or "result()" methods of the visitor object, only "process".


The documentation for this class was generated from the following file: