Math::Vector::Real::Neighbors - find nearest neighbor for a set of points
use Math::Vector::Real use Math::Vector::Real::Neighbors; use Math::Vector::Real::Random; my @v = map Math::Vector::Real->random_normal(2), 0..1000; my @nearest_ixs = Math::Vector::Real::Neighbors->neighbors(@v);
This module is able to find for every point in a given set its nearest neighbour from the same set.
Note: currently the
neighbors method is just a thin wrapper for the neighbor look-up algorithm provided in Math::Vector::Real::kdTree which is a couple of orders of magnitude faster than the old one formerly used here.
Two methods are currently available:
Given a set of points returns the indexes on the set for the nearest neighbor for every point.
Does the same using a brute force algorithm. This method is mostly for testing purposes.
The wikipedia entry for Nearest Neighbor Search http://en.wikipedia.org/wiki/Nearest_neighbor_search.
Copyright (C) 2011, 2014 by Salvador Fandiño <email@example.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.3 or, at your option, any later version of Perl 5 you may have available.