Performs all-nearest-neighbors. More...
Public Member Functions | |
| AllkNN () | |
| Constructors are generally very simple in FASTlib; most of the work is done by Init(). | |
| void | ComputeBaseCase_ (TreeType *query_node, TreeType *reference_node) |
| Performs exhaustive computation between two leaves. | |
| void | ComputeDualNeighborsRecursion_ (TreeType *query_node, TreeType *reference_node, double lower_bound_distance) |
| The recursive function for dual tree. | |
| void | ComputeNaive (ArrayList< index_t > *resulting_neighbors, ArrayList< double > *distances) |
| Does the entire computation naively. | |
| void | ComputeNeighbors (ArrayList< index_t > *resulting_neighbors, ArrayList< double > *distances) |
| Computes the nearest neighbors and stores them in *results. | |
| void | ComputeSingleNeighborsRecursion_ (index_t point_id, Vector &point, TreeType *reference_node, double *min_dist_so_far) |
| void | Destruct () |
| Initializes the AllNN structure for naive computation. | |
| void | Init (const Matrix &references_in, index_t leaf_size, index_t knns, const char *mode="dual") |
| void | Init (const Matrix &queries_in, const Matrix &references_in, index_t leaf_size, index_t knns, const char *mode="dual") |
| void | Init (const Matrix &references_in, struct datanode *module_in) |
| Use this if you want to run allknn it on a single dataset the query tree and reference tree are the same. | |
| void | Init (const Matrix &queries_in, const Matrix &references_in, struct datanode *module_in) |
| Setup the class and build the trees. | |
| void | InitNaive (const Matrix &references_in, index_t knns) |
| void | InitNaive (const Matrix &queries_in, const Matrix &references_in, index_t knns) |
| double | MinNodeDistSq_ (TreeType *query_node, TreeType *reference_node) |
| Computes the minimum squared distance between the bounding boxes of two nodes. | |
| double | MinPointNodeDistSq_ (const Vector &query_point, TreeType *reference_node) |
| Computes the minimum squared distances between a point and a node's bounding box. | |
| ~AllkNN () | |
| The tree is the only member we are responsible for deleting. | |
Friends | |
| class | TestAllkNN |
Performs all-nearest-neighbors.
This class will build the trees and perform the recursive computation.
Definition at line 57 of file allknn.h.
| AllkNN::AllkNN | ( | ) | [inline] |
| AllkNN::~AllkNN | ( | ) | [inline] |
Performs exhaustive computation between two leaves.
Definition at line 211 of file allknn.h.
References BinarySpaceTree< TBound, TDataset, TStatistic >::begin(), la::DistanceSqEuclidean(), BinarySpaceTree< TBound, TDataset, TStatistic >::end(), and MinPointNodeDistSq_().
Referenced by ComputeDualNeighborsRecursion_(), and ComputeNaive().
| void AllkNN::ComputeDualNeighborsRecursion_ | ( | TreeType * | query_node, | |
| TreeType * | reference_node, | |||
| double | lower_bound_distance | |||
| ) | [inline] |
The recursive function for dual tree.
Definition at line 287 of file allknn.h.
References ComputeBaseCase_(), BinarySpaceTree< TBound, TDataset, TStatistic >::left(), MinNodeDistSq_(), and BinarySpaceTree< TBound, TDataset, TStatistic >::right().
Referenced by ComputeNeighbors().
| void AllkNN::ComputeNaive | ( | ArrayList< index_t > * | resulting_neighbors, | |
| ArrayList< double > * | distances | |||
| ) | [inline] |
Does the entire computation naively.
Definition at line 782 of file allknn.h.
References ComputeBaseCase_(), ArrayList< TElem >::Init(), GenVector< T >::length(), and ArrayList< TElem >::size().
| void AllkNN::ComputeNeighbors | ( | ArrayList< index_t > * | resulting_neighbors, | |
| ArrayList< double > * | distances | |||
| ) | [inline] |
Computes the nearest neighbors and stores them in *results.
Definition at line 716 of file allknn.h.
References GenVector< T >::Alias(), ComputeDualNeighborsRecursion_(), fx_timer_start(), fx_timer_stop(), ArrayList< TElem >::Init(), GenVector< T >::length(), MinNodeDistSq_(), and ArrayList< TElem >::size().
Referenced by NaiveKde< TKernel >::Init().
| void AllkNN::Destruct | ( | ) | [inline] |
Initializes the AllNN structure for naive computation.
This means that we simply ignore the tree building.
Definition at line 654 of file allknn.h.
References GenVector< T >::Destruct().
| void AllkNN::Init | ( | const Matrix & | references_in, | |
| struct datanode * | module_in | |||
| ) | [inline] |
Use this if you want to run allknn it on a single dataset the query tree and reference tree are the same.
Definition at line 524 of file allknn.h.
References fx_param_int(), fx_param_str(), fx_timer_start(), fx_timer_stop(), GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
| void AllkNN::Init | ( | const Matrix & | queries_in, | |
| const Matrix & | references_in, | |||
| struct datanode * | module_in | |||
| ) | [inline] |
Setup the class and build the trees.
Note: we are initializing with const references to prevent local copies of the data.
Definition at line 470 of file allknn.h.
References fx_param_int(), fx_param_str(), fx_timer_start(), fx_timer_stop(), GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
Referenced by NaiveKde< TKernel >::Init().
Computes the minimum squared distance between the bounding boxes of two nodes.
Definition at line 192 of file allknn.h.
Referenced by ComputeDualNeighborsRecursion_(), and ComputeNeighbors().
| double AllkNN::MinPointNodeDistSq_ | ( | const Vector & | query_point, | |
| TreeType * | reference_node | |||
| ) | [inline] |
Computes the minimum squared distances between a point and a node's bounding box.
Definition at line 201 of file allknn.h.
Referenced by ComputeBaseCase_().
1.6.3