vecstasy 0.1.0

vecstasy is a library for SIMD-enabled floating-point operations on vectors. It provides fast implementations of euclidean distance/dot product/normalization. For now, it depends on the portable-simd unstable feature.
Documentation

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.
  • HashVec wrapper: Stable hashing and equality for &[f32] slices based on IEEE‑754 raw bits, distinguishing +0/−0 and NaNs for deterministic behavior.

Features

  • VecLike trait: Defines l2_dist_squared, dot, and normalized methods.
  • Optimized implementations: Portable SIMD when the simd feature is enabled; scalar fallback possible.
  • Bit-wise hashing: HashVec ensures identical bit-pattern vectors hash and compare consistently.

Usage

Add to your Cargo.toml:

[dependencies]
vecstasy = "0.1"

Then import and use:

use vecstasy::VecLike;
use vecstasy::HashVec;

let data: &[f32] = &[0.0; 8];  // length must be multiple of lane count
let hv = HashVec::from(data);
let normed = hv.normalized();

License

MIT, see license file