1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Contains a selection of distance metrics that can be chosen from to measure the distance
//! between two points stored inside the tree.
// #[cfg(any(target_arch = "x86_64"))]
// use std::arch::x86_64::*;
use crateAxis;
/// Returns the squared euclidean distance between two points.
///
/// Faster than Euclidean distance due to not needing a square root, but still
/// preserves the same distance ordering as with Euclidean distance.
///
/// # Examples
///
/// ```rust
/// use kiddo::float::distance::squared_euclidean;
///
/// assert_eq!(0f32, squared_euclidean(&[0f32, 0f32], &[0f32, 0f32]));
/// assert_eq!(1f32, squared_euclidean(&[0f32, 0f32], &[1f32, 0f32]));
/// assert_eq!(2f32, squared_euclidean(&[0f32, 0f32], &[1f32, 1f32]));
/// ```
/// Returns the Manhattan / "taxi cab" distance between two points.
///
/// Faster than squared Euclidean, and just as effective if not more so in higher-dimensional spaces
///
/// # Examples
///
/// ```rust
/// use kiddo::float::distance::manhattan;
///
/// assert_eq!(0f32, manhattan(&[0f32, 0f32], &[0f32, 0f32]));
/// assert_eq!(1f32, manhattan(&[0f32, 0f32], &[1f32, 0f32]));
/// assert_eq!(2f32, manhattan(&[0f32, 0f32], &[1f32, 1f32]));
/// ```