kn0sys_nn

Trait NearestNeighbour

source
pub trait NearestNeighbour:
    Debug
    + Send
    + Sync
    + Unpin {
    // Required method
    fn batch_with_leaf_size<'a, F: Float + ScalarOperand, DT: Data<Elem = F>, D: 'a + Distance<F>>(
        &self,
        batch: &'a ArrayBase<DT, Ix2>,
        leaf_size: usize,
        dist_fn: D,
    ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>;

    // Provided method
    fn batch<'a, F: Float + ScalarOperand, DT: Data<Elem = F>, D: 'a + Distance<F>>(
        &self,
        batch: &'a ArrayBase<DT, Ix2>,
        dist_fn: D,
    ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError> { ... }
}
Expand description

Nearest neighbour algorithm builds a spatial index structure out of a batch of points. The distance between points is calculated using a provided distance function. The index implements the NearestNeighbourIndex trait and allows for efficient computing of nearest neighbour and range queries.

Required Methods§

source

fn batch_with_leaf_size<'a, F: Float + ScalarOperand, DT: Data<Elem = F>, D: 'a + Distance<F>>( &self, batch: &'a ArrayBase<DT, Ix2>, leaf_size: usize, dist_fn: D, ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>

Builds a spatial index using a MxN two-dimensional array representing M points with N dimensions. Also takes leaf_size, which specifies the number of elements in the leaf nodes of tree-like index structures.

Returns an error if the points have dimensionality of 0 or if the leaf size is 0. If any value in the batch is NaN or infinite, the behaviour is unspecified.

Provided Methods§

source

fn batch<'a, F: Float + ScalarOperand, DT: Data<Elem = F>, D: 'a + Distance<F>>( &self, batch: &'a ArrayBase<DT, Ix2>, dist_fn: D, ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>

Builds a spatial index using a default leaf size. See from_batch_with_leaf_size for more information.

Object Safety§

This trait is not object safe.

Implementors§