1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! # vecstasy
//!
//! `vecstasy` is a minimal, high-performance Rust library for vector arithmetic.
//! It provides a generic `VecLike` trait for common vector operations and
//! two primary implementations:
//!
//! - **SIMD-backed linear algebra** (`[f32]` and `&[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**: All implementations exploit CPU-based SIMD whenever available
//! - **Bit-wise hashing**: `HashVec` ensures identical bit-pattern vectors hash and compare consistently.
//!
//! ## Usage
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! vecstasy = "0.1"
//! ```
//!
//! Then import and use:
//!
//! ```rust
//! use vecstasy::VecLike;
//! use vecstasy::HashVec;
//!
//! let data: &[f32] = &[0.0; 8]; // length should be multiple of the SIMD lane count, which is 8 by default
//! let hv = HashVec::from(data);
//! let normed = hv.normalized();
//! ```
//!
//! ## License
//!
//! MIT, see license file
pub use *;
pub use *;
pub use *;