vecstasy
vecstasy is a minimal, high-performance Rust library for vector operations.
It provides a generic VecLike trait for common vector operations and
two primary implementations:
- SIMD-backed slices (
&[f32]): Fast L2 distance, dot product, and normalization via SIMD. Should natively work on all platforms supported by LLVM, even the ones with no SIMD support. It falls back to sequential evaluation in that case. HashVecwrapper: Stable hashing and equality for&[f32]slices based on IEEE‑754 raw bits, distinguishing +0/−0 and NaNs for deterministic behavior.
Features
VecLiketrait: Definesl2_dist_squared,dot, andnormalizedmethods.- Optimized implementations: Portable SIMD when the
simdfeature is enabled; scalar fallback possible. - Bit-wise hashing:
HashVecensures identical bit-pattern vectors hash and compare consistently.
Usage
Add to your Cargo.toml:
[]
= "0.1"
Then import and use:
use VecLike;
use HashVec;
let data: & = &; // length must be multiple of lane count
let hv = from;
let normed = hv.normalized;
License
MIT, see license file