Skip to main content

Crate sprk

Crate sprk 

Source
Expand description

A high-performance spatial index for radius queries in D-dimensional Euclidean space.

The core data structure is Sprk, which combines KD-tree-like axis-aligned partitioning with SIMD-vectorized leaf scans and lookup-table-based pruning. For cases where the dimensionality is not known at compile time, DynSprk provides the same functionality with a runtime dimension parameter.

§Quick Start

use sprk::Sprk;

let positions = vec![[0.0f32, 0.0], [1.0, 0.0], [0.0, 1.0], [5.0, 5.0]];
let tree: Sprk<2> = Sprk::new(&positions);

let mut results: Vec<u32> = Vec::new();
tree.query_radius(&[0.5, 0.5], 1.5, &mut results);
assert_eq!(results.len(), 3); // indices 0, 1, 2

§Output Types

The output type is controlled by the QueryOutput trait. Use integer types (u32, usize) for index-only results, or IdDist for (index, squared distance) pairs:

use sprk::{Sprk, IdDist};

let tree: Sprk<2> = Sprk::new(&[[0.0f32, 0.0], [1.0, 0.0]]);
let mut pairs: Vec<IdDist<u32, f32>> = Vec::new();
tree.query_radius(&[0.0, 0.0], 2.0, &mut pairs);
for p in &pairs {
    println!("index {}, squared distance {}", p.id, p.dist);
}

Re-exports§

pub use output::IdDist;
pub use output::QueryOutput;

Modules§

output
Result types and the QueryOutput trait that controls what query_radius produces.

Structs§

DynSprk
Sprk with runtime-specified dimensionality.
Sprk
A spatial index for exact radius queries in D-dimensional Euclidean space.

Traits§

IdStorage
Integer type used to store point IDs internally.
Scalar
Numeric type used for coordinates and distances.