pub struct TurboQuantCodebook { /* private fields */ }Expand description
Deterministic scalar codebook for one TurboQuant vector dimension.
Implementations§
Source§impl TurboQuantCodebook
impl TurboQuantCodebook
Sourcepub fn new(
kind: TurboQuantCodebookKind,
bit_width: TurboQuantBitWidth,
dimension: usize,
) -> TurboQuantCodecResult<Self>
pub fn new( kind: TurboQuantCodebookKind, bit_width: TurboQuantBitWidth, dimension: usize, ) -> TurboQuantCodecResult<Self>
Build a deterministic codebook for kind, bit_width, and
dimension.
§Errors
Returns an error when dimension is zero or exceeds
MAX_VECTOR_DIMENSION.
Sourcepub fn clipped_uniform(
bit_width: TurboQuantBitWidth,
dimension: usize,
) -> TurboQuantCodecResult<Self>
pub fn clipped_uniform( bit_width: TurboQuantBitWidth, dimension: usize, ) -> TurboQuantCodecResult<Self>
Build a clipped-uniform codebook.
§Errors
Returns an error when dimension is zero or exceeds
MAX_VECTOR_DIMENSION.
Sourcepub fn normal_lloyd_max(
bit_width: TurboQuantBitWidth,
dimension: usize,
) -> TurboQuantCodecResult<Self>
pub fn normal_lloyd_max( bit_width: TurboQuantBitWidth, dimension: usize, ) -> TurboQuantCodecResult<Self>
Build a normal Lloyd-Max codebook.
§Errors
Returns an error when dimension is zero or exceeds
MAX_VECTOR_DIMENSION.
Sourcepub const fn kind(&self) -> TurboQuantCodebookKind
pub const fn kind(&self) -> TurboQuantCodebookKind
Return the codebook family.
Sourcepub const fn bit_width(&self) -> TurboQuantBitWidth
pub const fn bit_width(&self) -> TurboQuantBitWidth
Return the bit width used by this codebook.
Sourcepub const fn dimension(&self) -> usize
pub const fn dimension(&self) -> usize
Return the vector dimension this codebook was calibrated for.
Sourcepub fn boundaries(&self) -> &[f32]
pub fn boundaries(&self) -> &[f32]
Return midpoint boundaries between adjacent centroids.
Sourcepub fn centroid(&self, code: u8) -> TurboQuantCodecResult<f32>
pub fn centroid(&self, code: u8) -> TurboQuantCodecResult<f32>
Return the centroid for code.
§Errors
Returns TurboQuantCodecError::InvalidCode when code exceeds this
codebook’s bit width.
Sourcepub fn encode_scalar(&self, value: f32) -> TurboQuantCodecResult<u8>
pub fn encode_scalar(&self, value: f32) -> TurboQuantCodecResult<u8>
Quantize a finite scalar into a code by scanning codebook boundaries.
Values equal to a boundary choose the lower code, matching the lower-code tie break used by exact nearest-centroid scans.
§Errors
Returns TurboQuantCodecError::NonFiniteValue for NaN or infinity.
Sourcepub fn estimated_bytes(&self) -> usize
pub fn estimated_bytes(&self) -> usize
Return an approximate heap allocation footprint for this codebook.
Trait Implementations§
Source§impl Clone for TurboQuantCodebook
impl Clone for TurboQuantCodebook
Source§fn clone(&self) -> TurboQuantCodebook
fn clone(&self) -> TurboQuantCodebook
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TurboQuantCodebook
impl Debug for TurboQuantCodebook
Source§impl PartialEq for TurboQuantCodebook
impl PartialEq for TurboQuantCodebook
Source§fn eq(&self, other: &TurboQuantCodebook) -> bool
fn eq(&self, other: &TurboQuantCodebook) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TurboQuantCodebook
Auto Trait Implementations§
impl Freeze for TurboQuantCodebook
impl RefUnwindSafe for TurboQuantCodebook
impl Send for TurboQuantCodebook
impl Sync for TurboQuantCodebook
impl Unpin for TurboQuantCodebook
impl UnsafeUnpin for TurboQuantCodebook
impl UnwindSafe for TurboQuantCodebook
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.