vecstasy/lib.rs
1//! # vecstasy
2//!
3//! `vecstasy` is a minimal, high-performance Rust library for vector arithmetic.
4//! It provides a generic `VecLike` trait for common vector operations and
5//! two primary implementations:
6//!
7//! - **SIMD-backed linear algebra** (`[f32]` and `&[f32]`): Fast L2 distance, dot product, and normalization
8//! via SIMD. Should natively work on all platforms supported by LLVM, even the ones with no
9//! SIMD support (it falls back to sequential evaluation in that case).
10//! - **`HashVec` wrapper**: Stable hashing and equality for `&[f32]` slices based on
11//! IEEE‑754 raw bits, distinguishing +0/−0 and NaNs for deterministic behavior.
12//!
13//! ## Features
14//!
15//! - **`VecLike` trait**: Defines `l2_dist_squared`, `dot`, and `normalized` methods.
16//! - **Optimized implementations**: All implementations exploit CPU-based SIMD whenever available
17//! - **Bit-wise hashing**: `HashVec` ensures identical bit-pattern vectors hash and compare consistently.
18//!
19//! ## Usage
20//!
21//! Add to your `Cargo.toml`:
22//!
23//! ```toml
24//! [dependencies]
25//! vecstasy = "0.1"
26//! ```
27//!
28//! Then import and use:
29//!
30//! ```rust
31//! use vecstasy::VecLike;
32//! use vecstasy::HashVec;
33//!
34//! let data: &[f32] = &[0.0; 8]; // length should be multiple of the SIMD lane count, which is 8 by default
35//! let hv = HashVec::from(data);
36//! let normed = hv.normalized();
37//! ```
38//!
39//! ## License
40//!
41//! MIT, see license file
42
43#![feature(portable_simd)]
44
45mod hashvec;
46mod slice;
47mod veclike;
48
49pub use hashvec::*;
50pub use slice::*;
51pub use veclike::*;