vecstasy

Crates.iovecstasy
lib.rsvecstasy
version0.1.10
created_at2025-07-18 13:15:26.779816+00
updated_at2025-07-27 10:00:43.838565+00
descriptionvecstasy is a library for SIMD-enabled floating-point operations on vectors.
homepage
repositoryhttps://gitlab.epfl.ch/randl/vecstasy
max_upload_size
id1758944
size26,912
MRandl (MRandl)

documentation

README

vecstasy

Minimal and fast Rust library for high-dimensional vector arithmetic.

crates.io docs.rs gitlab.epfl.ch gitlab.epfl.ch


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:

[dependencies]
vecstasy = "0.1"

or cargo add vecstasy

Usage

Core trait (VecLike)

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)

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.

License

MIT. See LICENSE for details.

Commit count: 0

cargo fmt