Struct SRTree

Source
pub struct SRTree<T, M> {
    pub root_index: usize,
    pub points: Vec<Point<T>>,
    pub nodes: Vec<Node<T>>,
    pub params: Params,
    pub metric: M,
}

Fields§

§root_index: usize§points: Vec<Point<T>>§nodes: Vec<Node<T>>§params: Params§metric: M

Implementations§

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn bulk_load(&mut self, point_indices: Vec<usize>) -> usize

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn query(&self, point_coords: &[T], k: usize) -> (Vec<usize>, Vec<T>)

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn query_radius(&self, point_coords: &[T], radius: T) -> Vec<usize>

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn distance(&self, a: &Point<T>, b: &Point<T>) -> T

Source

pub fn distance_squared(&self, a: &Point<T>, b: &Point<T>) -> T

Source

pub fn point_to_rect_min_distance(&self, point: &Point<T>, rect: &Rect<T>) -> T

Source

pub fn point_to_rect_max_distance(&self, point: &Point<T>, rect: &Rect<T>) -> T

Source

pub fn point_to_sphere_min_distance( &self, point: &Point<T>, sphere: &Sphere<T>, ) -> T

Source

pub fn point_to_sphere_max_distance( &self, point: &Point<T>, sphere: &Sphere<T>, ) -> T

Source

pub fn point_to_node_min_distance(&self, point: &Point<T>, node: &Node<T>) -> T

Source

pub fn point_to_node_max_distance(&self, point: &Point<T>, node: &Node<T>) -> T

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn calculate_mean(&self, node_index: usize) -> Vec<T>

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn calculate_points_variance(&self, point_indices: &[usize]) -> Vec<T>

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn reshape(&mut self, node_index: usize)

Source§

impl<T, M> SRTree<T, M>
where T: Float + Send + Sync, M: Metric<T>,

Source

pub fn new( pts: &[Vec<T>], params: Params, metric: M, ) -> Result<Self, ArrayError>

Builds SRTree with the given points, params and metric.

§Errors
  • ArrayError::Empty if the input array is empty.
  • ArrayError::DimensionMismatch if the input array contains points of different dimensions.
Source

pub fn default(pts: &[Vec<T>], metric: M) -> Result<Self, ArrayError>

Builds SRTree with the given points (using default params) and metric.

§Errors
  • ArrayError::Empty if the input array is empty.
  • ArrayError::DimensionMismatch if the input array contains points of different dimensions.
Source

pub fn add_node(&mut self, node: Node<T>) -> usize

Source

pub fn num_nodes(&self) -> usize

Source

pub fn num_points(&self) -> usize

Source

pub fn num_leaves(&self) -> usize

Source

pub fn height(&self) -> usize

Source

pub fn children_of(&self, node_index: usize) -> Option<&[usize]>

Source

pub fn points_of(&self, node_index: usize) -> &[usize]

Source

pub fn node_distance_lower_bound( &self, node_index: usize, other_node_index: usize, ) -> T

Source

pub fn radius_of(&self, node_index: usize) -> T

Source

pub fn compare_nodes( &self, node_index: usize, other_node_index: usize, ) -> Option<Ordering>

Source§

impl<T> SRTree<T, Euclidean>
where T: Float + Send + Sync,

Source

pub fn euclidean_with_params( pts: &[Vec<T>], params: Params, ) -> Result<Self, ArrayError>

Builds SRTree with the given points, params and Euclidean metric.

§Errors
  • ArrayError::Empty if the input array is empty.
  • ArrayError::DimensionMismatch if the input array contains points of different dimensions.
Source

pub fn euclidean(pts: &[Vec<T>]) -> Result<Self, ArrayError>

Builds SRTree with the given points (using default params) and Euclidean metric.

§Errors
  • ArrayError::Empty if the input array is empty.
  • ArrayError::DimensionMismatch if the input array contains points of different dimensions.

Auto Trait Implementations§

§

impl<T, M> Freeze for SRTree<T, M>
where M: Freeze,

§

impl<T, M> RefUnwindSafe for SRTree<T, M>

§

impl<T, M> Send for SRTree<T, M>
where M: Send, T: Send,

§

impl<T, M> Sync for SRTree<T, M>
where M: Sync, T: Sync,

§

impl<T, M> Unpin for SRTree<T, M>
where M: Unpin, T: Unpin,

§

impl<T, M> UnwindSafe for SRTree<T, M>
where M: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.