# vecstasy
Minimal and fast Rust library for high-dimensional vector arithmetic.
[](https://crates.io/crates/vecstasy) [](https://docs.rs/vecstasy) 

---
## Features
* **`VecLike` trait** defining:
* `l2_dist_squared` (squared Euclidean distance)
* `dot` (inner product)
* `normalized` (unit‑length copy)
* **Always-on SIMD‑backed implementation** for `&[f32]` slices via Rust’s unstable portable SIMD APIs
* **`HashVec` wrapper**: stable hashing & equality by IEEE‑754 bit patterns
## Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
vecstasy = "0.1"
```
or `cargo add vecstasy`
## Usage
### Core trait (`VecLike`)
```rust
use vecstasy::VecLike;
let a: &[f32] = &[1.0; 8]; // length should be multiple of SIMD_LANECOUNT, which is 8 by default
let b: &[f32] = &[2.0; 8];
let dist2 = a.l2_dist_squared(&b);
let dot = a.dot(&b);
let normed: Vec<f32> = a.normalized();
```
### Stable hashing (`HashVec`)
```rust
use vecstasy::HashVec;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let data: &[f32] = &[0.0; 8];
let hv = HashVec::from(data);
let mut hasher = DefaultHasher::new();
hv.hash(&mut hasher);
let hash_value = hasher.finish();
```
## Requirements
* **Nightly Rust** with the `portable_simd` feature enabled
## Documentation
API docs are available on [docs.rs](https://docs.rs/vecstasy).
## License
MIT. See [LICENSE](LICENSE) for details.