space 0.14.1

A library providing abstractions for spatial datastructures and search
Documentation

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::MetricPoint;

struct Hamming(u8);

impl MetricPoint for Hamming {
    type Metric = u8;

    fn distance(&self, other: &Self) -> Self::Metric {
        (self.0 ^ other.0).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.