Template Struct KDTreeEigenMatrixAdaptor
Defined in File nanoflann.hpp
Struct Documentation
-
template<class MatrixType, int32_t DIM = -1, class Distance = nanoflann::metric_L2, bool row_major = true>
struct KDTreeEigenMatrixAdaptor An L2-metric KD-tree adaptor for working with data directly stored in an Eigen Matrix, without duplicating the data storage. You can select whether a row or column in the matrix represents a point in the state space.
Example of usage:
Eigen::Matrix<num_t,Eigen::Dynamic,Eigen::Dynamic> mat; // Fill out "mat"... using my_kd_tree_t = nanoflann::KDTreeEigenMatrixAdaptor< Eigen::Matrix<num_t,Dynamic,Dynamic>>; const int max_leaf = 10; my_kd_tree_t mat_index(mat, max_leaf); mat_index.index->...
- Template Parameters:
DIM – If set to >0, it specifies a compile-time fixed dimensionality for the points in the data set, allowing more compiler optimizations.
Distance – The distance metric to use: nanoflann::metric_L1, nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc.
row_major – If set to true the rows of the matrix are used as the points, if set to false the columns of the matrix are used as the points.
Interface expected by KDTreeSingleIndexAdaptor
Public Types
-
using self_t = KDTreeEigenMatrixAdaptor<MatrixType, DIM, Distance, row_major>
-
using num_t = typename MatrixType::Scalar
-
using IndexType = typename MatrixType::Index
-
using index_t = KDTreeSingleIndexAdaptor<metric_t, self_t, row_major ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime, IndexType>
Public Functions
-
inline explicit KDTreeEigenMatrixAdaptor(const Dimension dimensionality, const std::reference_wrapper<const MatrixType> &mat, const int leaf_max_size = 10)
Constructor: takes a const ref to the matrix object with the data points.
-
inline ~KDTreeEigenMatrixAdaptor()
-
inline void query(const num_t *query_point, const Size num_closest, IndexType *out_indices, num_t *out_distances) const
Query for the num_closest closest points to a given point (entered as query_point[0:dim-1]). Note that this is a short-cut method for index->findNeighbors(). The user can also call index->… methods as desired.
Note
If L2 norms are used, all returned distances are actually squared distances.