OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType > Struct Template Reference

An L2-metric KD-tree adaptor for working with data directly stored in an Eigen Matrix, without duplicating the data storage. More...

#include <nanoflann.hpp>

+ Collaboration diagram for nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >:

Public Types

typedef KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType > self_t
 
typedef MatrixType::Scalar num_t
 
typedef Distance::template traits< num_t, self_t >::distance_t metric_t
 
typedef KDTreeSingleIndexAdaptor< metric_t, self_t, DIM, IndexType > index_t
 

Public Member Functions

 KDTreeEigenMatrixAdaptor (const int dimensionality, const MatrixType &mat, const int leaf_max_size=10)
 The kd-tree index for the user to call its methods as usual with any other FLANN index.
 
 ~KDTreeEigenMatrixAdaptor ()
 
void query (const num_t *query_point, const size_t num_closest, IndexType *out_indices, num_t *out_distances_sq, const int=10) const
 Query for the num_closest closest points to a given point (entered as query_point[0:dim-1]).
 
Interface expected by KDTreeSingleIndexAdaptor
const self_tderived () const
 
self_tderived ()
 
size_t kdtree_get_point_count () const
 
num_t kdtree_distance (const num_t *p1, const size_t idx_p2, size_t size) const
 
num_t kdtree_get_pt (const size_t idx, int dim) const
 
template<class BBOX >
bool kdtree_get_bbox (BBOX &bb) const
 

Public Attributes

index_tindex
 
const MatrixType & m_data_matrix
 

Detailed Description

template<class MatrixType, int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
struct nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >

An L2-metric KD-tree adaptor for working with data directly stored in an Eigen Matrix, without duplicating the data storage.

Each row in the matrix represents a point in the state space.

Example of usage:

Eigen::Matrix<num_t,Dynamic,Dynamic> mat;
// Fill out "mat"...
const int max_leaf = 10;
my_kd_tree_t mat_index(dimdim, mat, max_leaf );
mat_index.index->buildIndex();
mat_index.index->...
An L2-metric KD-tree adaptor for working with data directly stored in an Eigen Matrix,...
Template Parameters
DIMIf set to >0, it specifies a compile-time fixed dimensionality for the points in the data set, allowing more compiler optimizations.
DistanceThe distance metric to use: nanoflann::metric_L1, nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc.
IndexTypeThe type for indices in the KD-tree index (typically, size_t of int)

Definition at line 1540 of file nanoflann.hpp.

Member Typedef Documentation

◆ index_t

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
typedef KDTreeSingleIndexAdaptor<metric_t, self_t, DIM, IndexType> nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::index_t

Definition at line 1544 of file nanoflann.hpp.

◆ metric_t

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
typedef Distance::template traits<num_t,self_t>::distance_t nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::metric_t

Definition at line 1543 of file nanoflann.hpp.

◆ num_t

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
typedef MatrixType::Scalar nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::num_t

Definition at line 1542 of file nanoflann.hpp.

◆ self_t

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
typedef KDTreeEigenMatrixAdaptor<MatrixType, DIM, Distance, IndexType> nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::self_t

Definition at line 1541 of file nanoflann.hpp.

Constructor & Destructor Documentation

◆ KDTreeEigenMatrixAdaptor()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::KDTreeEigenMatrixAdaptor ( const int dimensionality,
const MatrixType & mat,
const int leaf_max_size = 10 )
inline

The kd-tree index for the user to call its methods as usual with any other FLANN index.

Constructor: takes a const ref to the matrix object with the data points

Definition at line 1549 of file nanoflann.hpp.

1551 : m_data_matrix(mat) {
1552 const size_t dims = mat.cols();
1553 if (DIM > 0 && static_cast<int>(dims) != DIM)
1554 throw std::runtime_error(
1555 "Data set dimensionality does not match the 'DIM' template argument");
1556 index = new index_t(
1557 dims, *this /* adaptor */,
1558 nanoflann::KDTreeSingleIndexAdaptorParams(leaf_max_size, dims));
1559 index->buildIndex();
1560 }
void buildIndex()
Builds the index.
KDTreeSingleIndexAdaptor< metric_t, self_t, DIM, IndexType > index_t
Parameters (see http://code.google.com/p/nanoflann/ for help choosing the parameters)

References nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::buildIndex().

+ Here is the call graph for this function:

◆ ~KDTreeEigenMatrixAdaptor()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::~KDTreeEigenMatrixAdaptor ( )
inline

Definition at line 1566 of file nanoflann.hpp.

1566 {
1567 delete index;
1568 }

Member Function Documentation

◆ derived() [1/2]

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
self_t & nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::derived ( )
inline

Definition at line 1592 of file nanoflann.hpp.

1592 {
1593 return *this;
1594 }

◆ derived() [2/2]

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
const self_t & nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::derived ( ) const
inline

Definition at line 1589 of file nanoflann.hpp.

1589 {
1590 return *this;
1591 }

◆ kdtree_distance()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
num_t nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::kdtree_distance ( const num_t * p1,
const size_t idx_p2,
size_t size ) const
inline

Definition at line 1602 of file nanoflann.hpp.

1603 {
1604 num_t s = 0;
1605 for (size_t i = 0; i < size; i++) {
1606 const num_t d = p1[i] - m_data_matrix.coeff(idx_p2, i);
1607 s += d * d;
1608 }
1609 return s;
1610 }
platform_constant Fraction s[Q]
constexpr int d() any_platform

◆ kdtree_get_bbox()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
template<class BBOX >
bool nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::kdtree_get_bbox ( BBOX & bb) const
inline

Definition at line 1621 of file nanoflann.hpp.

1621 {
1622 return false;
1623 }

◆ kdtree_get_point_count()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
size_t nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::kdtree_get_point_count ( ) const
inline

Definition at line 1597 of file nanoflann.hpp.

1597 {
1598 return m_data_matrix.rows();
1599 }

◆ kdtree_get_pt()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
num_t nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::kdtree_get_pt ( const size_t idx,
int dim ) const
inline

Definition at line 1613 of file nanoflann.hpp.

1613 {
1614 return m_data_matrix.coeff(idx, dim);
1615 }

◆ query()

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
void nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::query ( const num_t * query_point,
const size_t num_closest,
IndexType * out_indices,
num_t * out_distances_sq,
const int = 10 ) const
inline

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
nChecks_IGNORED is ignored but kept for compatibility with the original FLANN interface.

Definition at line 1577 of file nanoflann.hpp.

1579 {
1581 num_closest);
1582 resultSet.init(out_indices, out_distances_sq);
1583 index->findNeighbors(resultSet, query_point, nanoflann::SearchParams());
1584 }
void findNeighbors(RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const
Find set of nearest neighbors to vec[0:dim-1].
Search options for KDTreeSingleIndexAdaptor::findNeighbors()

References nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::findNeighbors(), and nanoflann::KNNResultSet< DistanceType, IndexType, CountType >::init().

+ Here is the call graph for this function:

Member Data Documentation

◆ index

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
index_t* nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::index

Definition at line 1546 of file nanoflann.hpp.

◆ m_data_matrix

template<class MatrixType , int DIM = -1, class Distance = nanoflann::metric_L2, typename IndexType = size_t>
const MatrixType& nanoflann::KDTreeEigenMatrixAdaptor< MatrixType, DIM, Distance, IndexType >::m_data_matrix

Definition at line 1570 of file nanoflann.hpp.


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