vq/lib.rs
1//! # Vq
2//!
3//! `vq` is a vector quantization library for Rust.
4//!
5//! It provides efficient implementations of various vector quantization algorithms,
6//! including binary quantization (BQ), scalar quantization (SQ), product quantization (PQ),
7//! and tree-structured vector quantization (TSVQ).
8//!
9//! ## Features
10//!
11//! - Unified API: All algorithms implement the [`Quantizer`] trait.
12//! - Distance metrics: Supports Euclidean, squared Euclidean, Manhattan, and cosine distances.
13//! - Performance:
14//! - SIMD acceleration (AVX/AVX2/AVX512/NEON/SVE) via `simd` feature.
15//! - Parallel training via `parallel` feature.
16//!
17//! ## Example
18//!
19//! ```rust
20//! use vq::{Quantizer, VqResult};
21//! use vq::sq::ScalarQuantizer;
22//!
23//! fn main() -> VqResult<()> {
24//! let sq = ScalarQuantizer::new(-1.0, 1.0, 256)?;
25//! let vector = vec![0.5, -0.2, 0.9];
26//! let quantized = sq.quantize(&vector)?;
27//! let reconstructed = sq.dequantize(&quantized)?;
28//! Ok(())
29//! }
30//! ```
31
32pub mod bq;
33pub mod core;
34pub mod pq;
35pub mod sq;
36pub mod tsvq;
37
38pub use bq::BinaryQuantizer;
39pub use pq::ProductQuantizer;
40pub use sq::ScalarQuantizer;
41pub use tsvq::TSVQ;
42
43pub use core::distance::Distance;
44pub use core::error::{VqError, VqResult};
45pub use core::quantizer::Quantizer;
46pub use core::vector::Vector;
47
48#[cfg(feature = "simd")]
49pub use core::hsdlib_ffi::get_simd_backend;