Skip to main content

rcflib/
lib.rs

1pub mod common;
2pub mod errors;
3pub mod glad;
4mod pointstore;
5pub mod rcf;
6mod samplerplustree;
7pub mod trcf;
8mod types;
9mod util;
10pub mod visitor;
11
12extern crate rand;
13extern crate rand_chacha;
14
15use num::abs;
16
17pub fn l1distance(a: &[f32], b: &[f32]) -> f64 {
18    a.iter()
19        .zip(b)
20        .map(|(&x, &y)| abs(x as f64 - y as f64))
21        .sum()
22}
23
24pub fn linfinitydistance(a: &[f32], b: &[f32]) -> f64 {
25    let mut dist = 0.0;
26    for i in 0..a.len() {
27        let t = abs(a[i] as f64 - b[i] as f64);
28        if dist < t {
29            dist = t;
30        };
31    }
32    dist
33}
34
35pub fn l2distance(a: &[f32], b: &[f32]) -> f64 {
36    f64::sqrt(
37        a.iter()
38            .zip(b)
39            .map(|(&x, &y)| abs(x as f64 - y as f64) * abs(x as f64 - y as f64) )
40            .sum(),
41    )
42}