pub struct BallTree<T: Float + Send + Sync, D: Distance<T>> { /* private fields */ }
Expand description
Ball tree for efficient nearest neighbor searches
The ball tree partitions data into a set of nested hyperspheres (balls), which allows for efficient nearest neighbor searches, especially in high-dimensional spaces. Each node in the tree represents a ball containing a subset of the points.
§Type Parameters
T
: Floating point type (f32 or f64)D
: Distance metric that implements theDistance
trait
Implementations§
Source§impl<T: Float + Send + Sync + 'static, D: Distance<T> + Send + Sync + 'static> BallTree<T, D>
impl<T: Float + Send + Sync + 'static, D: Distance<T> + Send + Sync + 'static> BallTree<T, D>
Sourcepub fn new(
data: &ArrayView2<'_, T>,
leaf_size: usize,
distance: D,
) -> SpatialResult<BallTree<T, D>>
pub fn new( data: &ArrayView2<'_, T>, leaf_size: usize, distance: D, ) -> SpatialResult<BallTree<T, D>>
Sourcepub fn query(
&self,
point: &[T],
k: usize,
return_distance: bool,
) -> SpatialResult<(Vec<usize>, Option<Vec<T>>)>
pub fn query( &self, point: &[T], k: usize, return_distance: bool, ) -> SpatialResult<(Vec<usize>, Option<Vec<T>>)>
Sourcepub fn query_radius(
&self,
point: &[T],
radius: T,
return_distance: bool,
) -> SpatialResult<(Vec<usize>, Option<Vec<T>>)>
pub fn query_radius( &self, point: &[T], radius: T, return_distance: bool, ) -> SpatialResult<(Vec<usize>, Option<Vec<T>>)>
Sourcepub fn query_radius_tree(
&self,
other: &BallTree<T, D>,
radius: T,
) -> SpatialResult<Vec<(usize, usize)>>
pub fn query_radius_tree( &self, other: &BallTree<T, D>, radius: T, ) -> SpatialResult<Vec<(usize, usize)>>
Sourcepub fn get_n_samples(&self) -> usize
pub fn get_n_samples(&self) -> usize
Get the number of data points
Sourcepub fn get_n_features(&self) -> usize
pub fn get_n_features(&self) -> usize
Get the dimension of data points
Sourcepub fn get_leaf_size(&self) -> usize
pub fn get_leaf_size(&self) -> usize
Get the leaf size
Source§impl<T: Float + Send + Sync + 'static> BallTree<T, EuclideanDistance<T>>
impl<T: Float + Send + Sync + 'static> BallTree<T, EuclideanDistance<T>>
Sourcepub fn with_euclidean_distance(
data: &ArrayView2<'_, T>,
leaf_size: usize,
) -> SpatialResult<BallTree<T, EuclideanDistance<T>>>
pub fn with_euclidean_distance( data: &ArrayView2<'_, T>, leaf_size: usize, ) -> SpatialResult<BallTree<T, EuclideanDistance<T>>>
Trait Implementations§
Auto Trait Implementations§
impl<T, D> Freeze for BallTree<T, D>where
D: Freeze,
impl<T, D> RefUnwindSafe for BallTree<T, D>where
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, D> Send for BallTree<T, D>
impl<T, D> Sync for BallTree<T, D>
impl<T, D> Unpin for BallTree<T, D>
impl<T, D> UnwindSafe for BallTree<T, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more