kd-tree-0.1.0: A simple k-d tree implementation

Safe HaskellNone
LanguageHaskell2010

Data.KdTree

Contents

Synopsis

Documentation

data KdTree f a Source

The k-d tree is a data structure capable of efficiently answering nearest neighbor search queries in low-dimensional spaces. As a rule of thumb, for efficient lookups the number of points in k dimensions should greatly exceed 2^k

Construction

fromVector :: (Ord a, Vector v (f a)) => [E f] -> v (f a) -> KdTree f a Source

Construct a KdTree from a vector of points

Queries

nearest :: forall f a. (Ord a, Num a, Metric f) => f a -> KdTree f a -> Maybe (f a) Source

Find the point nearest to the given point

toList :: KdTree f a -> [f a] Source

List all points in a tree

Diagnostics

isValid :: Ord a => KdTree f a -> Bool Source

Verify that the tree is well-formed (recursively)

showKdTree :: Show (f a) => f String -> KdTree f a -> String Source

Given names for the axes show the tree