pub struct HalfVector {
pub bytes: Vec<u8>,
}Expand description
SQ8 / SQ4 / SQ16 share an Sq*Vector-shaped struct; halfvec
follows the same pattern. bytes always has even length; the
invariant is enforced by every constructor in this module.
Fields§
§bytes: Vec<u8>Implementations§
Source§impl HalfVector
impl HalfVector
Sourcepub fn from_f32_slice(v: &[f32]) -> Self
pub fn from_f32_slice(v: &[f32]) -> Self
Encode v into raw u16 LE bits via per-element
f32 → f16 round-to-nearest-even.
Sourcepub fn to_f32_vec(&self) -> Vec<f32>
pub fn to_f32_vec(&self) -> Vec<f32>
Decode every u16 LE in bytes to f32. Inverse of
from_f32_slice modulo half-precision round-trip error
(≤ 2^-10 × |x| for finite normals).
Trait Implementations§
Source§impl Clone for HalfVector
impl Clone for HalfVector
Source§fn clone(&self) -> HalfVector
fn clone(&self) -> HalfVector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HalfVector
impl Debug for HalfVector
impl Eq for HalfVector
Source§impl PartialEq for HalfVector
impl PartialEq for HalfVector
Source§fn eq(&self, other: &HalfVector) -> bool
fn eq(&self, other: &HalfVector) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HalfVector
Auto Trait Implementations§
impl Freeze for HalfVector
impl RefUnwindSafe for HalfVector
impl Send for HalfVector
impl Sync for HalfVector
impl Unpin for HalfVector
impl UnsafeUnpin for HalfVector
impl UnwindSafe for HalfVector
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