#space #knn #ann #search

no-std space

A library providing abstractions for spatial datastructures and search

34 releases (16 breaking)

0.17.0 Jul 18, 2021
0.15.0 Jul 18, 2021
0.10.3 Mar 5, 2020
0.7.3 Aug 1, 2019
0.6.0 Nov 20, 2018

#80 in Data structures

Download history 428/week @ 2021-04-08 291/week @ 2021-04-15 1199/week @ 2021-04-22 191/week @ 2021-04-29 90/week @ 2021-05-06 134/week @ 2021-05-13 53/week @ 2021-05-20 52/week @ 2021-05-27 34/week @ 2021-06-03 156/week @ 2021-06-10 247/week @ 2021-06-17 358/week @ 2021-06-24 163/week @ 2021-07-01 831/week @ 2021-07-08 465/week @ 2021-07-15 944/week @ 2021-07-22

1,283 downloads per month
Used in 12 crates (8 directly)

MIT license

16KB
166 lines

space

Discord Crates.io MIT/Apache docs.rs LoC Tests Lints no_std

A library providing abstractions for spatial datastructures and search

If you use a kNN datastructure library and would like to have the Knn trait implemented on its types natively, please raise an issue on that library. Similarly, crates which define datapoints with specific distance metrics, and not general linear algebra crates, can implement the MetricPoint trait.

See the bitarray crate for an implementation of MetricPoint using hamming distance (with optional, though unstable, 512-bit SIMD support, and always-on 64-bit popcnt instruction support).

Usage

use space::Metric;

struct Hamming;

impl Metric<u8> for Hamming {
    type Unit = u8;

    fn distance(&self, &a: &u8, &b: &u8) -> Self::Unit {
        (a ^ b).count_ones() as u8
    }
}

Benchmarks

To run the benchmarks, use the following command:

cargo bench --all-features

If you do not pass --all-features, the benchmark wont run. Due to this issue, the SIMD feature must be enabled. Cargo offers no way to automatically bring the SIMD feature in for the benchmark, and thus it must be passed at the command line.

Dependencies

~100–355KB