pub struct Encoder { /* private fields */ }Expand description
The prepared recipe: sign vectors and scales are FIXED per (seed, width), so they are computed once here, never per vector. Before this hoist the encode path allocated fresh sign vectors and re-ran the PRNG for EVERY vector – measured 3.3x on the 250K ingest ladder; the hoist plus ROUNDS 3 -> 1 (recall unchanged at 1.000 on both the gaussian and the hostile sparse dataset; the identity-rotation mutation fails the sparse case at 0.555) brought bulk 15.9s -> 8.6s.
Implementations§
Source§impl Encoder
impl Encoder
pub fn new(dim: usize, seed: u64, bits: usize) -> Encoder
pub fn bits(&self) -> usize
pub fn padded(&self) -> usize
Sourcepub fn encode(&self, v: &[f32]) -> (f32, Vec<u8>)
pub fn encode(&self, v: &[f32]) -> (f32, Vec<u8>)
Encode: returns (norm, packed code) for a raw vector (dim <= padded).
Sourcepub fn rotate_query(&self, q: &[f32]) -> Vec<f32>
pub fn rotate_query(&self, q: &[f32]) -> Vec<f32>
Pad + rotate a query once per search.
Source§impl Encoder
impl Encoder
pub fn affine_query(&self, q: &[f32]) -> AffineQuery
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more