Class Bruteforce

Inheritance Relationships

Base Type

Class Documentation

class Bruteforce : public dim_red::NearestNeighbors

A bruteforce implementation of nearest neighbor search.

Public Functions

Bruteforce(const Eigen::Ref<const Matrix> &x, const std::string &metric = "euclidean")

Constructor.

Parameters
  • x – the dataset to search in.

  • metric – the distance metric.

virtual std::pair<Vector, IntVector> query(const Eigen::Ref<const Vector> &point, int k, bool sort_results = true) const override

Retrieves the k-nearest neighbors for the query point.

Parameters
  • point – the query point.

  • k – the number of nearest neighbors to search for.

  • sort_results – if true, the neighbors will be sorted by distances in ascending order.

Returns

the k-nearest neighbors: {distances, indices}.

virtual std::pair<Vector, IntVector> queryRadius(const Eigen::Ref<const Vector> &point, double radius, bool sort_results = false) const override

Retrieves all the neighbors of the query point in the specified radius.

Parameters
  • point – the query point.

  • radius – the search radius.

  • sort_results – if true, the neighbors will be sorted by distances in ascending order.

Returns

the nearest neighbors in the specified radius: {distances, indices}.