MLPACK
1.0.4
|
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSearch class. More...
Static Public Member Functions | |
static double | BestDistance () |
Return what should represent the best possible distance with this particular sort policy. | |
template<typename TreeType > | |
static double | BestNodeToNodeDistance (const TreeType *queryNode, const TreeType *referenceNode) |
Return the best possible distance between two nodes. | |
template<typename TreeType > | |
static double | BestNodeToNodeDistance (const TreeType *queryNode, const TreeType *referenceNode, const double centerToCenterDistance) |
Return the best possible distance between two nodes, given that the distance between the centers of the two nodes has already been calculated. | |
template<typename TreeType > | |
static double | BestNodeToNodeDistance (const TreeType *queryNode, const TreeType *referenceNode, const TreeType *referenceChildNode, const double centerToCenterDistance) |
Return the best possible distance between the query node and the reference child node given the base case distance between the query node and the reference node. | |
template<typename TreeType > | |
static double | BestPointToNodeDistance (const arma::vec &queryPoint, const TreeType *referenceNode) |
Return the best possible distance between a node and a point. | |
template<typename TreeType > | |
static double | BestPointToNodeDistance (const arma::vec &queryPoint, const TreeType *referenceNode, const double pointToCenterDistance) |
Return the best possible distance between a point and a node, given that the distance between the point and the center of the node has already been calculated. | |
static bool | IsBetter (const double value, const double ref) |
Return whether or not value is "better" than ref. | |
static size_t | SortDistance (const arma::vec &list, double newDistance) |
Return the index in the vector where the new distance should be inserted, or (size_t() - 1) if it should not be inserted (i.e. | |
static double | WorstDistance () |
Return what should represent the worst possible distance with this particular sort policy. |
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSearch class.
The sorting policy here is that the minimum distance is the best (so, when used with NeighborSearch, the output is nearest neighbors).
This class is also meant to serve as a guide to implement a custom SortPolicy. All of the methods implemented here must be implemented by any other SortPolicy classes.
Definition at line 41 of file nearest_neighbor_sort.hpp.
static double mlpack::neighbor::NearestNeighborSort::BestDistance | ( | ) | [inline, static] |
Return what should represent the best possible distance with this particular sort policy.
In our case, this should be the minimum possible distance, 0.0.
Definition at line 147 of file nearest_neighbor_sort.hpp.
static double mlpack::neighbor::NearestNeighborSort::BestNodeToNodeDistance | ( | const TreeType * | queryNode, |
const TreeType * | referenceNode | ||
) | [static] |
Return the best possible distance between two nodes.
In our case, this is the minimum distance between the two tree nodes using the given distance function.
static double mlpack::neighbor::NearestNeighborSort::BestNodeToNodeDistance | ( | const TreeType * | queryNode, |
const TreeType * | referenceNode, | ||
const double | centerToCenterDistance | ||
) | [static] |
Return the best possible distance between two nodes, given that the distance between the centers of the two nodes has already been calculated.
This is used in conjunction with trees that have self-children (like cover trees).
static double mlpack::neighbor::NearestNeighborSort::BestNodeToNodeDistance | ( | const TreeType * | queryNode, |
const TreeType * | referenceNode, | ||
const TreeType * | referenceChildNode, | ||
const double | centerToCenterDistance | ||
) | [static] |
Return the best possible distance between the query node and the reference child node given the base case distance between the query node and the reference node.
TreeType::ParentDistance() must be implemented to use this.
queryNode | Query node. |
referenceNode | Reference node. |
referenceChildNode | Child of reference node which is being inspected. |
centerToCenterDistance | Distance between centers of query node and reference node. |
static double mlpack::neighbor::NearestNeighborSort::BestPointToNodeDistance | ( | const arma::vec & | queryPoint, |
const TreeType * | referenceNode | ||
) | [static] |
Return the best possible distance between a node and a point.
In our case, this is the minimum distance between the tree node and the point using the given distance function.
static double mlpack::neighbor::NearestNeighborSort::BestPointToNodeDistance | ( | const arma::vec & | queryPoint, |
const TreeType * | referenceNode, | ||
const double | pointToCenterDistance | ||
) | [static] |
Return the best possible distance between a point and a node, given that the distance between the point and the center of the node has already been calculated.
This is used in conjunction with trees that have self-children (like cover trees).
static bool mlpack::neighbor::NearestNeighborSort::IsBetter | ( | const double | value, |
const double | ref | ||
) | [inline, static] |
Return whether or not value is "better" than ref.
In this case, that means that the value is less than the reference.
value | Value to compare |
ref | Value to compare with |
Definition at line 69 of file nearest_neighbor_sort.hpp.
static size_t mlpack::neighbor::NearestNeighborSort::SortDistance | ( | const arma::vec & | list, |
double | newDistance | ||
) | [static] |
Return the index in the vector where the new distance should be inserted, or (size_t() - 1) if it should not be inserted (i.e.
if it is not any better than any of the existing points in the list). The list should be sorted such that the best point is the first in the list. The actual insertion is not performed.
list | Vector of existing distance points, sorted such that the best point is first in the list. |
new_distance | Distance to try to insert |
static double mlpack::neighbor::NearestNeighborSort::WorstDistance | ( | ) | [inline, static] |
Return what should represent the worst possible distance with this particular sort policy.
In our case, this should be the maximum possible distance, DBL_MAX.
Definition at line 138 of file nearest_neighbor_sort.hpp.