Skip to main content

Offset

Struct Offset 

Source
pub struct Offset<E: IntegerElement, BdIn: Bound, BdOut: Bound, C: Codec<E, BdIn>> { /* private fields */ }
Expand description

d(c) - z: asymmetric quantization as a codec composition, not a feature.

A zero point is a codec, which is why the library needs no separate “asymmetric” mode and no branch for one (§1.3).

Decoding widens the alphabet: an inner value bounded by BdIn and a zero point of magnitude |z| produce a value bounded by BdIn + |z|. That is why the output bound is a separate parameter, and why Offset::new checks, once and in O(1), that the declared output bound covers the image and that no value overflows the element type. A None means no such codec exists — the same category as a non-conformant shape, decided before any arithmetic (C6).

Implementations§

Source§

impl<E: IntegerElement, BdIn: Bound, BdOut: Bound, C: Codec<E, BdIn>> Offset<E, BdIn, BdOut, C>

Source

pub fn new(inner: C, zero: E) -> Option<Self>

Compose inner with the zero point zero.

None when BdIn + |zero| exceeds the declared output bound or the element type’s own range, in which case the decode this describes does not land in the alphabet it claims to.

Source

pub const fn zero(&self) -> E

The zero point.

Trait Implementations§

Source§

impl<E: Clone + IntegerElement, BdIn: Clone + Bound, BdOut: Clone + Bound, C: Clone + Codec<E, BdIn>> Clone for Offset<E, BdIn, BdOut, C>

Source§

fn clone(&self) -> Offset<E, BdIn, BdOut, C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E, BdIn, BdOut, C> Codec<E, BdOut> for Offset<E, BdIn, BdOut, C>
where E: IntegerElement, BdIn: Bound, BdOut: Bound, C: Codec<E, BdIn>,

Source§

const MAX_BLOCK: usize = C::MAX_BLOCK

The most alphabet elements one code can produce. Read more
Source§

const TIER: TierId = TierId::Offset

Which tier this is, for reports and for the kappa manifest.
Source§

const IS_FIXED_WIDTH: bool = C::IS_FIXED_WIDTH

Is decode_len always MAX_BLOCK? Read more
Source§

type Code = <C as Codec<E, BdIn>>::Code

The stored code type. Read more
Source§

fn decode_element(&self, code: Self::Code, i: usize) -> Alphabet<E, BdOut>

Decode element i of the block code names. Total for every i. Read more
Source§

fn decode_len(&self, _code: Self::Code) -> usize

How many elements code actually produces. Read more
Source§

fn decode_into(&self, code: Self::Code, out: &mut [Alphabet<E, Bd>]) -> usize

Decode one code, returning how many elements were written. Read more
Source§

fn decode_seq(&self, codes: &[Self::Code], out: &mut [Alphabet<E, Bd>]) -> usize

Bulk path, returning how many elements were written in total.
Source§

impl<E: Copy + IntegerElement, BdIn: Copy + Bound, BdOut: Copy + Bound, C: Copy + Codec<E, BdIn>> Copy for Offset<E, BdIn, BdOut, C>

Source§

impl<E: Debug + IntegerElement, BdIn: Debug + Bound, BdOut: Debug + Bound, C: Debug + Codec<E, BdIn>> Debug for Offset<E, BdIn, BdOut, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E, BdIn, BdOut, C> Enumerable<E, BdOut> for Offset<E, BdIn, BdOut, C>
where E: IntegerElement, BdIn: Bound, BdOut: Bound, C: Enumerable<E, BdIn>,

Source§

const CODE_SPACE: usize = C::CODE_SPACE

The number of distinct codes. Read more
Source§

fn code_at(index: usize) -> Self::Code

The index-th code. Total for index < CODE_SPACE.
Source§

fn index_of(code: Self::Code) -> usize

Where code sits in the enumeration. Read more
Source§

fn as_index_stream(codes: &[Self::Code]) -> Option<IndexStream<'_>>

The stored code stream, read as the index stream it already is. Read more
Source§

const SIGN_BIT_BOOK: bool = false

Whether the decoded book is the sign bit-decomposition: CODE_SPACE is a power of two and book[c][t] == 2 * bit(c, t) - 1 for every code c and every t below its log. Read more

Auto Trait Implementations§

§

impl<E, BdIn, BdOut, C> Freeze for Offset<E, BdIn, BdOut, C>
where C: Freeze, E: Freeze,

§

impl<E, BdIn, BdOut, C> RefUnwindSafe for Offset<E, BdIn, BdOut, C>

§

impl<E, BdIn, BdOut, C> Send for Offset<E, BdIn, BdOut, C>

§

impl<E, BdIn, BdOut, C> Sync for Offset<E, BdIn, BdOut, C>

§

impl<E, BdIn, BdOut, C> Unpin for Offset<E, BdIn, BdOut, C>
where C: Unpin, E: Unpin,

§

impl<E, BdIn, BdOut, C> UnsafeUnpin for Offset<E, BdIn, BdOut, C>
where C: UnsafeUnpin, E: UnsafeUnpin,

§

impl<E, BdIn, BdOut, C> UnwindSafe for Offset<E, BdIn, BdOut, C>
where C: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.