pub struct KdTree<'a> { /* private fields */ }Expand description
A balanced static k-dimensional tree over selected atoms.
Construction uses linear-time median partitioning at each level, for
O(n log n) total work with n / LEAF_MAX split nodes and four flat
per-point arrays.
Implementations§
Source§impl KdTree<'_>
impl KdTree<'_>
Sourcepub fn knn(
&self,
query: &[u32],
k: usize,
options: KnnOptions,
context: &ExecutionContext,
) -> Result<KnnResult, SpatialError>
pub fn knn( &self, query: &[u32], k: usize, options: KnnOptions, context: &ExecutionContext, ) -> Result<KnnResult, SpatialError>
Finds the k nearest targets of every query atom in parallel.
Results are identical at any worker count. Equal distances order by atom index. Periodic trees report exact minimum-image distances.
§Errors
Returns an error for an invalid max_distance, a query atom outside
the coordinate array, memory admission failure or cancellation.
Source§impl<'a> KdTree<'a>
impl<'a> KdTree<'a>
Sourcepub fn build(
positions: &'a [[f32; 3]],
targets: &[u32],
periodic: Option<PeriodicBox>,
) -> Result<Self, SpatialError>
pub fn build( positions: &'a [[f32; 3]], targets: &[u32], periodic: Option<PeriodicBox>, ) -> Result<Self, SpatialError>
Builds a balanced tree over finite target positions.
§Errors
Returns an error when a target index is outside positions.
Sourcepub fn build_with_options(
positions: &'a [[f32; 3]],
targets: &[u32],
periodic: Option<PeriodicBox>,
periodic_options: KdPeriodicOptions,
) -> Result<Self, SpatialError>
pub fn build_with_options( positions: &'a [[f32; 3]], targets: &[u32], periodic: Option<PeriodicBox>, periodic_options: KdPeriodicOptions, ) -> Result<Self, SpatialError>
Builds a balanced tree with an explicit periodic image budget.
§Errors
Returns an error for invalid options or target indices.
Sourcepub fn pairs(
&self,
query: &[u32],
cutoff: f32,
) -> Result<Vec<NeighborPair>, SpatialError>
pub fn pairs( &self, query: &[u32], cutoff: f32, ) -> Result<Vec<NeighborPair>, SpatialError>
Finds all indexed pairs within cutoff.
§Errors
Returns an error for an invalid cutoff or query index.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for KdTree<'a>
impl<'a> RefUnwindSafe for KdTree<'a>
impl<'a> Send for KdTree<'a>
impl<'a> Sync for KdTree<'a>
impl<'a> Unpin for KdTree<'a>
impl<'a> UnsafeUnpin for KdTree<'a>
impl<'a> UnwindSafe for KdTree<'a>
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
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> ⓘ
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> ⓘ
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