kira-spatial-core is a deterministic, SoA-first Rust library for spatial primitives shared across Kira tools.
- Core types and invariants (
SpatialDomain,Field, geometry types) - Deterministic numeric helpers and quantization
- Deterministic tile planning (row-major)
- SIMD capability scaffold with scalar fallback stubs
- Grid field operators:
gradient,laplacian,hessian,window - Advanced spatial operators:
structure-tensor,divergence,curl,distance-transform,curvature,fractal-dimension,skeletonization,diffusion,multiscale-log,cross-gradient - Spatial statistics: global/local Moran's I and Geary's C on regular lattices
- Spatial indexing and graph algorithms
- Neighborhood operators and solvers
- Production SIMD kernels
kira-spatial-core owns in-memory contracts, numeric policy, and deterministic traversal rules.
kira-spatial-io should handle file formats and ingestion, then hand validated data to this crate.
cargo testOptional features:
parallel: enable Rayon work-stealing in stencil operators and diffusionforce_scalar: force the SIMD-availability detector to returnfalsef64_fields: store field payloads asf64instead off32ndarray: enableinterop::ndarray_ioadaptersmmap: enableinterop::mmap_io::MmapFieldfor zero-copy OOC inputs (transitively pullsmemmap2+bytemuck)simd-reduce: route widening sums (field::reducer::sum_f64) through an 8-widewide::f32x8path. Numerically equivalent to scalar.
- MSRV: Rust 1.95 (Edition 2024). The crate uses let-chains in
if/while, so a stable toolchain at or above 1.95 is required. - The crate uses
#![deny(unsafe_code)]. The only module that opts back in (via#[allow(unsafe_code)]) isinterop::mmap_io, gated behind themmapfeature; it wrapsmemmap2for OOC inputs. Every other module is unsafe-free. - All public numeric entry points reject
NaN/Inf; seedocs/NUMERIC.md. - Public enums are marked
#[non_exhaustive]: externalmatcharms must include a_ => …fallback so future variants do not break downstream. - SIMD capability is detected at runtime on
x86_64(AVX2) andaarch64(NEON). Theforce_scalarfeature pins the detector tofalse.
See examples/ for a runnable end-to-end gradient/diffusion
pipeline against a synthetic grid:
cargo run --example gradient_diffusionUse SpatialOperator names as canonical --op values:
gradientlaplacianstructure-tensordivergencecurldistance-transformcurvaturefractal-dimensionskeletonizationdiffusionmultiscale-logcross-gradient