#integer #distance #levenshtein #set #recursion #length #byte #trace #wiki #euclidean

distances

Fast and generic distance functions for high-dimensional data

10 stable releases

new 1.4.0 Sep 15, 2023
1.3.0 Aug 24, 2023
1.1.2 Jul 18, 2023
0.1.1 Apr 22, 2020

#178 in Algorithms

Download history 3/week @ 2023-06-15 2/week @ 2023-06-22 3/week @ 2023-06-29 161/week @ 2023-07-06 89/week @ 2023-07-13 27/week @ 2023-07-20 50/week @ 2023-07-27 49/week @ 2023-08-03 52/week @ 2023-08-10 106/week @ 2023-08-17 46/week @ 2023-08-24 22/week @ 2023-08-31 11/week @ 2023-09-07 59/week @ 2023-09-14

140 downloads per month
Used in abd-clam

MIT license

86KB
1.5K SLoC

Distances (v1.4.0)

Fast and generic distance functions for high-dimensional data.

Usage

Add this to your project:

> cargo add distances@1.4.0

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.

No runtime deps