A computation class for dual-tree and naive all-nearest-neighbors. More...
Public Member Functions | |
void | ComputeNaive (GenVector< index_t > *results, GenVector< double > *distances) |
Computes the nearest neighbors naively. | |
void | ComputeNaive (ArrayList< index_t > *results) |
Computes the nearest neighbors naively. | |
void | ComputeNeighbors (GenVector< index_t > *results, GenVector< double > *distances) |
Computes the nearest neighbors and stores them in results if provided. | |
void | ComputeNeighbors (ArrayList< index_t > *results) |
Computes the nearest neighbors and stores them in results if provided. | |
void | Destruct () |
void | EmitResults (GenVector< index_t > *results, GenVector< double > *distances) |
Initialize and fill an ArrayList of results. | |
void | EmitResults (ArrayList< index_t > *results) |
Initialize and fill an ArrayList of results. | |
void | GNPBaseCase_ (TreeType *query_node, TreeType *reference_node) |
Performs exhaustive computation between two nodes. | |
void | GNPBaseCase_ (QueryTree *query_node, ReferenceTree *reference_node) |
Performs exhaustive computation between two nodes. | |
void | GNPRecursion_ (TreeType *query_node, TreeType *reference_node, double lower_bound_distance) |
Performs one node-node comparison in the GNP algorithm and recurses upon all child combinations if no prune. | |
void | GNPRecursion_ (QueryTree *query_node, ReferenceTree *reference_node, double lower_bound_distance) |
Performs one node-node comparison in the GNP algorithm and recurses upon all child combinations if no prune. | |
void | Init (const Matrix &references_in, fx_module *module_in) |
void | Init (const Matrix &queries_in, const Matrix &references_in, struct datanode *module_in) |
Read parameters, alias data into the class, and build the trees. | |
void | Init (const Matrix &queries_in, const Matrix &references_in, struct datanode *module_in) |
Read parameters, copy data into the class, and build the trees. | |
void | InitNaive (const Matrix &references_in, fx_module *module_in) |
Initializes the AllNN structure for naive computation. | |
void | InitNaive (const Matrix &queries_in, const Matrix &references_in, fx_module *module_in) |
Initializes the AllNN structure for naive computation. | |
void | InitNaive (const Matrix &queries_in, const Matrix &references_in, struct datanode *module_in) |
Initializes the AllNN structure for naive computation. | |
double | MinNodeDistSq_ (TreeType *query_node, TreeType *reference_node) |
Computes the minimum squared distance between the bounding boxes of two nodes. | |
double | MinNodeDistSq_ (QueryTree *query_node, ReferenceTree *reference_node) |
Computes the minimum squared distance between the bounding boxes of two nodes. |
A computation class for dual-tree and naive all-nearest-neighbors.
This class builds trees for (assumed distinct) input query and reference sets on Init. The all-nearest-neighbors computation is then performed by calling ComputeNeighbors or ComputeNaive.
This class is only intended to compute once per instantiation.
Example use:
AllNN allnn; struct datanode* allnn_module; ArrayList<index_t> results; allnn_module = fx_submodule(NULL, "allnn", "allnn"); allnn.Init(query_set, reference_set, allnn_module); allnn.ComputeNeighbors(&results);
This class builds trees for (assumed distinct) input query and reference sets on Init. It can also handle monochromatic cases where the query and the reference trees are the same The all-nearest-neighbors computation is then performed by calling ComputeNeighbors or ComputeNaive.
This class is only intended to compute once per instantiation.
Example use:
AllNN allnn; struct datanode* allnn_module; ArrayList<index_t> results; allnn_module = fx_submodule(NULL, "allnn", "allnn"); allnn.Init(query_set, reference_set, allnn_module); allnn.ComputeNeighbors(&results);
Definition at line 107 of file allnn.h.
void AllNN::ComputeNaive | ( | GenVector< index_t > * | results, | |
GenVector< double > * | distances | |||
) | [inline] |
Computes the nearest neighbors naively.
Definition at line 717 of file allnn.h.
References EmitResults(), fx_timer_start(), fx_timer_stop(), and GNPBaseCase_().
void AllNN::ComputeNaive | ( | ArrayList< index_t > * | results | ) | [inline] |
Computes the nearest neighbors naively.
Definition at line 635 of file allnn.h.
References EmitResults(), fx_timer_start(), fx_timer_stop(), and GNPBaseCase_().
void AllNN::ComputeNeighbors | ( | GenVector< index_t > * | results, | |
GenVector< double > * | distances | |||
) | [inline] |
Computes the nearest neighbors and stores them in results if provided.
Definition at line 688 of file allnn.h.
References EmitResults(), fx_result_int(), fx_timer_start(), fx_timer_stop(), GNPRecursion_(), and MinNodeDistSq_().
void AllNN::ComputeNeighbors | ( | ArrayList< index_t > * | results | ) | [inline] |
Computes the nearest neighbors and stores them in results if provided.
Definition at line 605 of file allnn.h.
References EmitResults(), fx_result_int(), fx_timer_start(), fx_timer_stop(), GNPRecursion_(), and MinNodeDistSq_().
void AllNN::EmitResults | ( | GenVector< index_t > * | results, | |
GenVector< double > * | distances | |||
) | [inline] |
Initialize and fill an ArrayList of results.
Definition at line 739 of file allnn.h.
References GenVector< T >::Init(), GenVector< T >::length(), and ArrayList< TElem >::length().
void AllNN::EmitResults | ( | ArrayList< index_t > * | results | ) | [inline] |
Initialize and fill an ArrayList of results.
Definition at line 657 of file allnn.h.
References ArrayList< TElem >::Init(), and ArrayList< TElem >::size().
Referenced by ComputeNaive(), and ComputeNeighbors().
Performs exhaustive computation between two nodes.
Note that naive also makes use of this function.
Definition at line 254 of file allnn.h.
References BinarySpaceTree< TBound, TDataset, TStatistic >::begin(), la::DistanceSqEuclidean(), and BinarySpaceTree< TBound, TDataset, TStatistic >::end().
void AllNN::GNPBaseCase_ | ( | QueryTree * | query_node, | |
ReferenceTree * | reference_node | |||
) | [inline] |
Performs exhaustive computation between two nodes.
Note that naive also makes use of this function.
Definition at line 296 of file allnn.h.
References BinarySpaceTree< TBound, TDataset, TStatistic >::begin(), la::DistanceSqEuclidean(), and BinarySpaceTree< TBound, TDataset, TStatistic >::end().
Referenced by ComputeNaive(), and GNPRecursion_().
void AllNN::GNPRecursion_ | ( | TreeType * | query_node, | |
TreeType * | reference_node, | |||
double | lower_bound_distance | |||
) | [inline] |
Performs one node-node comparison in the GNP algorithm and recurses upon all child combinations if no prune.
Definition at line 332 of file allnn.h.
References GNPBaseCase_(), GNPRecursion_(), BinarySpaceTree< TBound, TDataset, TStatistic >::left(), MinNodeDistSq_(), and BinarySpaceTree< TBound, TDataset, TStatistic >::right().
void AllNN::GNPRecursion_ | ( | QueryTree * | query_node, | |
ReferenceTree * | reference_node, | |||
double | lower_bound_distance | |||
) | [inline] |
Performs one node-node comparison in the GNP algorithm and recurses upon all child combinations if no prune.
Definition at line 373 of file allnn.h.
References GNPBaseCase_(), BinarySpaceTree< TBound, TDataset, TStatistic >::left(), MinNodeDistSq_(), and BinarySpaceTree< TBound, TDataset, TStatistic >::right().
Referenced by ComputeNeighbors(), and GNPRecursion_().
void AllNN::Init | ( | const Matrix & | queries_in, | |
const Matrix & | references_in, | |||
struct datanode * | module_in | |||
) | [inline] |
Read parameters, alias data into the class, and build the trees.
WARNING !!!!! The algorithm will rearrange m the input matrices references_in, queries_in
Definition at line 479 of file allnn.h.
References fx_param_int(), fx_timer_start(), fx_timer_stop(), GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
void AllNN::Init | ( | const Matrix & | queries_in, | |
const Matrix & | references_in, | |||
struct datanode * | module_in | |||
) | [inline] |
Read parameters, copy data into the class, and build the trees.
Definition at line 505 of file allnn.h.
References fx_param_int(), fx_timer_start(), fx_timer_stop(), GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
void AllNN::InitNaive | ( | const Matrix & | references_in, | |
fx_module * | module_in | |||
) | [inline] |
Initializes the AllNN structure for naive computation.
We have no need to build trees for naive.
Definition at line 646 of file allnn.h.
References GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
void AllNN::InitNaive | ( | const Matrix & | queries_in, | |
const Matrix & | references_in, | |||
fx_module * | module_in | |||
) | [inline] |
Initializes the AllNN structure for naive computation.
We have no need to build trees for naive.
Definition at line 603 of file allnn.h.
References GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
void AllNN::InitNaive | ( | const Matrix & | queries_in, | |
const Matrix & | references_in, | |||
struct datanode * | module_in | |||
) | [inline] |
Initializes the AllNN structure for naive computation.
We have no need to build trees for naive.
Definition at line 562 of file allnn.h.
References GenVector< T >::Init(), ArrayList< TElem >::Init(), and GenVector< T >::SetAll().
double AllNN::MinNodeDistSq_ | ( | QueryTree * | query_node, | |
ReferenceTree * | reference_node | |||
) | [inline] |
Computes the minimum squared distance between the bounding boxes of two nodes.
Definition at line 286 of file allnn.h.
Referenced by ComputeNeighbors(), and GNPRecursion_().