#distance #numbers #vector #euclidean #generic #high-dimensional #data

distances

Fast and generic distance functions for high-dimensional data

20 stable releases

1.8.0 Oct 12, 2024
1.7.1 Jul 12, 2024
1.6.3 Mar 20, 2024
1.6.2 Nov 12, 2023
0.1.1 Apr 22, 2020

#61 in Hardware support

Download history 29/week @ 2024-09-18 63/week @ 2024-09-25 2/week @ 2024-10-02 155/week @ 2024-10-09 112/week @ 2024-10-16 72/week @ 2024-10-23 165/week @ 2024-10-30 28/week @ 2024-11-06 53/week @ 2024-11-13 48/week @ 2024-11-20 10/week @ 2024-11-27 58/week @ 2024-12-04 90/week @ 2024-12-11 77/week @ 2024-12-18 47/week @ 2024-12-25 27/week @ 2025-01-01

281 downloads per month
Used in 4 crates (3 directly)

MIT license

110KB
2K SLoC

Distances (v1.8.0)

Fast and generic distance functions for high-dimensional data.

Usage

Add this to your project:

> cargo add distances@1.8.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.

Dependencies

~1–1.6MB
~34K SLoC