#distance #numbers #data #vector #generic #euclidean #function

distances

Fast and generic distance functions for high-dimensional data

19 stable releases

1.7.1 Jul 12, 2024
1.6.3 Mar 20, 2024
1.6.2 Nov 12, 2023
1.1.2 Jul 18, 2023
0.1.1 Apr 22, 2020

#143 in Algorithms

Download history 86/week @ 2024-04-01 39/week @ 2024-04-08 28/week @ 2024-04-15 23/week @ 2024-04-22 33/week @ 2024-04-29 26/week @ 2024-05-06 8/week @ 2024-05-13 6/week @ 2024-05-20 6/week @ 2024-06-03 16/week @ 2024-06-10 4/week @ 2024-06-24 183/week @ 2024-07-01 133/week @ 2024-07-08 19/week @ 2024-07-15

339 downloads per month
Used in 2 crates

MIT license

105KB
2K SLoC

Distances (v1.7.1)

Fast and generic distance functions for high-dimensional data.

Usage

Add this to your project:

> cargo add distances@1.7.1

Use it in your project:

use distances::Number;
use distances::vectors::euclidean;

let a = [1.0_f32, 2.0, 3.0];
let b = [4.0_f32, 5.0, 6.0];

let distance: f32 = euclidean(&a, &b);

assert!((distance - (27.0_f32).sqrt()).abs() < 1e-6);

Features

  • A Number trait to abstract over different numeric types.
    • Distance functions are generic over the return type implementing Number.
    • Distance functions may also be generic over the input type being a collection of Numbers.
  • SIMD accelerated implementations for float types.
  • Python bindings with maturin and pyo3.
  • no_std support.

Available Distance Functions

Contributing

Contributions are welcome, encouraged, and appreciated! See CONTRIBUTING.md.

License

Licensed under the MIT license.

Dependencies

~0.6–1.2MB
~27K SLoC