pub struct Turbo4Codec { /* private fields */ }Expand description
The Turbo4 codec for a fixed (dimension, rotation-seed) pair.
Implementations§
Source§impl Turbo4Codec
impl Turbo4Codec
Sourcepub fn new(dim: usize, rotation_seed: u64) -> Result<Self, TurboQuantError>
pub fn new(dim: usize, rotation_seed: u64) -> Result<Self, TurboQuantError>
Build a codec. dim must be even and ≥ 2 (all practical embedding
widths are; evenness keeps the two-run nibble layout exact).
pub fn dim(&self) -> usize
Sourcepub fn encode(&self, v: &[f32]) -> Result<Vec<u8>, TurboQuantError>
pub fn encode(&self, v: &[f32]) -> Result<Vec<u8>, TurboQuantError>
Encode a vector into its Turbo4 code blob.
Sourcepub fn encode_dual(
&self,
v: &[f32],
) -> Result<(Vec<u8>, Vec<u8>), TurboQuantError>
pub fn encode_dual( &self, v: &[f32], ) -> Result<(Vec<u8>, Vec<u8>), TurboQuantError>
Encode both planes from one rotation pass: the Turbo4 code and the 1-bit candidate-generation code (ADR-297 phase C). The bits blob shares this codec’s rotation, so a single query prep serves both.
Sourcepub fn encode_query(&self, q: &[f32]) -> Result<Turbo4Query, TurboQuantError>
pub fn encode_query(&self, q: &[f32]) -> Result<Turbo4Query, TurboQuantError>
Prepare a query for traversal + rescoring.
Sourcepub fn decode_rotated(&self, blob: &[u8]) -> Vec<f32>
pub fn decode_rotated(&self, blob: &[u8]) -> Vec<f32>
Reconstruct the rotated-space approximation from a code blob (tests/debugging only — the search path never reconstructs).
Auto Trait Implementations§
impl Freeze for Turbo4Codec
impl RefUnwindSafe for Turbo4Codec
impl Send for Turbo4Codec
impl Sync for Turbo4Codec
impl Unpin for Turbo4Codec
impl UnsafeUnpin for Turbo4Codec
impl UnwindSafe for Turbo4Codec
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