KMKNN searcher.
Instances of this class are usually constructed using KmknnPrebuilt::initialize()
.
- Template Parameters
-
Distance_ | A distance calculation class satisfying the MockDistance contract. |
Dim_ | Integer type for the number of dimensions. |
Index_ | Integer type for the indices. |
Store_ | Floating point type for the stored data. |
Float_ | Floating point type for the query data and output distances. |
template<class Distance_ , typename Dim_ , typename Index_ , typename Store_ , typename Float_ >
Index_ knncolle::KmknnSearcher< Distance_, Dim_, Index_, Store_, Float_ >::search_all |
( |
const Float_ * |
query, |
|
|
Float_ |
distance, |
|
|
std::vector< Index_ > * |
output_indices, |
|
|
std::vector< Float_ > * |
output_distances |
|
) |
| |
|
inlinevirtual |
Find all neighbors of a new observation within a certain distance. This method is optional and may not be implemented by subclasses, so applications should check can_search_all()
before attempting a call. A run-time exception is thrown if this method is called on a subclass that does not implement it.
- Parameters
-
| query | Pointer to an array of length equal to Prebuilt::num_dimensions() , containing the coordinates of the query point. |
| distance | The distance in which to consider neighbors. |
[out] | output_indices | Pointer to a vector, to be filled with the identities of the nearest neighbors in order of increasing distance. Optionally NULL, in which case no indices are returned. |
[out] | output_distances | Pointer to a vector, to be filled with the distances of the nearest neighbors. This corresponds to the indices reported in output_indices . Optionally NULL, in which case no distances are returned. |
- Returns
- Number of neighbors within
distance
of query
.
Reimplemented from knncolle::Searcher< Index_, Float_ >.
template<class Distance_ , typename Dim_ , typename Index_ , typename Store_ , typename Float_ >
Index_ knncolle::KmknnSearcher< Distance_, Dim_, Index_, Store_, Float_ >::search_all |
( |
Index_ |
i, |
|
|
Float_ |
distance, |
|
|
std::vector< Index_ > * |
output_indices, |
|
|
std::vector< Float_ > * |
output_distances |
|
) |
| |
|
inlinevirtual |
Find all neighbors of the i
-th observation within a certain distance. This method is optional and may not be implemented by subclasses, so applications should check can_search_all()
before attempting a call. A run-time exception is thrown if this method is called on a subclass that does not implement it.
- Parameters
-
| i | The index of the observation of interest. This should be non-negative and less than the total number of observations in Prebuilt::num_observations() . |
| distance | The distance in which to consider neighbors. |
[out] | output_indices | Pointer to a vector, to be filled with the identities of the nearest neighbors in order of increasing distance. This vector is guaranteed to not contain i itself. Optionally NULL, in which case no indices are returned. |
[out] | output_distances | Pointer to a vector, to be filled with the distances of the nearest neighbors. This corresponds to the indices reported in output_indices . Optionally NULL, in which case no distances are returned. |
- Returns
- Number of neighbors within
distance
of i
.
Reimplemented from knncolle::Searcher< Index_, Float_ >.