Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Kernel::NearestNeighbours< N > Class Template Reference

#include <NearestNeighbours.h>

Public Types

using NearestNeighbourResults = std::vector< std::tuple< VectorType, size_t, double > >
 
using VectorType = Eigen::Matrix< double, N, 1 >
 

Public Member Functions

NearestNeighbourResults findNearest (const VectorType &pos, const size_t k=1, const double error=0.0)
 Find the k nearest neighbours to a given point. More...
 
 NearestNeighbours (const NearestNeighbours &)=delete
 
 NearestNeighbours (const std::vector< VectorType > &points)
 Create a nearest neighbour search object. More...
 
 ~NearestNeighbours ()
 

Private Member Functions

NearestNeighbourResults makeResults (const size_t k, const std::unique_ptr< ANNidx[]> nnIndexList, const std::unique_ptr< ANNdist[]> nnDistList)
 Helper function to create a instance of NearestNeighbourResults. More...
 

Private Attributes

std::unique_ptr< NNDataPointsm_dataPoints
 handle to the list of data points to search through More...
 
std::unique_ptr< ANNkd_tree > m_kdTree
 handle to the ANN KD-tree used for searching More...
 

Detailed Description

template<int N = 3>
class Mantid::Kernel::NearestNeighbours< N >

Definition at line 84 of file NearestNeighbours.h.

Member Typedef Documentation

◆ NearestNeighbourResults

template<int N = 3>
using Mantid::Kernel::NearestNeighbours< N >::NearestNeighbourResults = std::vector<std::tuple<VectorType, size_t, double> >

Definition at line 89 of file NearestNeighbours.h.

◆ VectorType

template<int N = 3>
using Mantid::Kernel::NearestNeighbours< N >::VectorType = Eigen::Matrix<double, N, 1>

Definition at line 88 of file NearestNeighbours.h.

Constructor & Destructor Documentation

◆ NearestNeighbours() [1/2]

template<int N = 3>
Mantid::Kernel::NearestNeighbours< N >::NearestNeighbours ( const std::vector< VectorType > &  points)
inline

Create a nearest neighbour search object.

Parameters
points:: vector of Eigen::Vectors to search through

Definition at line 95 of file NearestNeighbours.h.

◆ ~NearestNeighbours()

template<int N = 3>
Mantid::Kernel::NearestNeighbours< N >::~NearestNeighbours ( )
inline

Definition at line 108 of file NearestNeighbours.h.

◆ NearestNeighbours() [2/2]

template<int N = 3>
Mantid::Kernel::NearestNeighbours< N >::NearestNeighbours ( const NearestNeighbours< N > &  )
delete

Member Function Documentation

◆ findNearest()

template<int N = 3>
NearestNeighbourResults Mantid::Kernel::NearestNeighbours< N >::findNearest ( const VectorType pos,
const size_t  k = 1,
const double  error = 0.0 
)
inline

Find the k nearest neighbours to a given point.

This is a thin wrapper around the ANN library annkSearch method

Parameters
pos:: the position to find th k nearest neighbours of
k:: the number of neighbours to find
error:: error term for finding approximate nearest neighbours. if zero then exact neighbours will be found. (default = 0.0).
Returns
vector neighbours as tuples of (position, index, distance)

Definition at line 122 of file NearestNeighbours.h.

References error.

Referenced by Mantid::MDAlgorithms::IntegrateEllipsoidsTwoStep::exec().

◆ makeResults()

template<int N = 3>
NearestNeighbourResults Mantid::Kernel::NearestNeighbours< N >::makeResults ( const size_t  k,
const std::unique_ptr< ANNidx[]>  nnIndexList,
const std::unique_ptr< ANNdist[]>  nnDistList 
)
inlineprivate

Helper function to create a instance of NearestNeighbourResults.

Parameters
k:: the number of neighbours searched for
nnIndexList:: the ordered list of indicies matching the closest k neighbours
nnDistList:: the ordered list of distances matching the closest k neighbours
Returns
a new NearestNeighbourResults object from the found items

Definition at line 148 of file NearestNeighbours.h.

Member Data Documentation

◆ m_dataPoints

template<int N = 3>
std::unique_ptr<NNDataPoints> Mantid::Kernel::NearestNeighbours< N >::m_dataPoints
private

handle to the list of data points to search through

Definition at line 164 of file NearestNeighbours.h.

◆ m_kdTree

template<int N = 3>
std::unique_ptr<ANNkd_tree> Mantid::Kernel::NearestNeighbours< N >::m_kdTree
private

handle to the ANN KD-tree used for searching

Definition at line 166 of file NearestNeighbours.h.


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