#[repr(transparent)]pub struct f16(pub u16);Expand description
A half-precision (16-bit) floating point number.
This type represents IEEE 754 half-precision binary floating-point format. It provides conversion methods to and from f32, and the underlying u16 representation is publicly accessible for direct bit manipulation.
§Examples
use simsimd::f16;
// Create from f32
let half = f16::from_f32(3.14);
// Convert back to f32
let float = half.to_f32();
// Direct access to bits
let bits = half.0;Tuple Fields§
§0: u16Implementations§
Source§impl f16
impl f16
Sourcepub fn from_f32(value: f32) -> Self
pub fn from_f32(value: f32) -> Self
Converts an f32 to f16 representation.
§Examples
use simsimd::f16;
let half = f16::from_f32(3.14159);Sourcepub fn to_f32(self) -> f32
pub fn to_f32(self) -> f32
Converts the f16 to an f32.
§Examples
use simsimd::f16;
let half = f16::from_f32(3.14159);
let float = half.to_f32();Sourcepub fn is_infinite(self) -> bool
pub fn is_infinite(self) -> bool
Returns true if this value is positive or negative infinity.
Trait Implementations§
Source§impl ComplexProducts for f16
impl ComplexProducts for f16
Source§fn dot(a: &[Self], b: &[Self]) -> Option<ComplexProduct>
fn dot(a: &[Self], b: &[Self]) -> Option<ComplexProduct>
Computes the dot product between two complex number vectors.
Source§fn vdot(a: &[Self], b: &[Self]) -> Option<ComplexProduct>
fn vdot(a: &[Self], b: &[Self]) -> Option<ComplexProduct>
Computes the Hermitian dot product (conjugate dot product) between two complex number vectors.
Source§impl PartialOrd for f16
impl PartialOrd for f16
Source§impl ProbabilitySimilarity for f16
impl ProbabilitySimilarity for f16
Source§fn jensenshannon(a: &[Self], b: &[Self]) -> Option<Distance>
fn jensenshannon(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the Jensen-Shannon divergence between two probability distributions.
The Jensen-Shannon divergence is a method of measuring the similarity between
two probability distributions. It is based on the Kullback-Leibler divergence,
but is symmetric and always has a finite value.
Source§fn kullbackleibler(a: &[Self], b: &[Self]) -> Option<Distance>
fn kullbackleibler(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the Kullback-Leibler divergence between two probability distributions.
The Kullback-Leibler divergence is a measure of how one probability distribution
diverges from a second, expected probability distribution.
Source§impl SpatialSimilarity for f16
impl SpatialSimilarity for f16
Source§fn cos(a: &[Self], b: &[Self]) -> Option<Distance>
fn cos(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the cosine distance between two slices.
The cosine distance is 1 minus the cosine similarity between two non-zero vectors
of an dot product space that measures the cosine of the angle between them.
Source§fn dot(a: &[Self], b: &[Self]) -> Option<Distance>
fn dot(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the inner product (also known as dot product) between two slices.
The dot product is the sum of the products of the corresponding entries
of the two sequences of numbers.
Source§fn l2sq(a: &[Self], b: &[Self]) -> Option<Distance>
fn l2sq(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the squared Euclidean distance between two slices.
The squared Euclidean distance is the sum of the squared differences
between corresponding elements of the two slices.
Source§fn l2(a: &[Self], b: &[Self]) -> Option<Distance>
fn l2(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the Euclidean distance between two slices.
The Euclidean distance is the square root of
elements of the two slices.
Source§fn sqeuclidean(a: &[Self], b: &[Self]) -> Option<Distance>
fn sqeuclidean(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the squared Euclidean distance between two slices.
The squared Euclidean distance is the sum of the squared differences
between corresponding elements of the two slices.
Source§fn euclidean(a: &[Self], b: &[Self]) -> Option<Distance>
fn euclidean(a: &[Self], b: &[Self]) -> Option<Distance>
Computes the Euclidean distance between two slices.
The Euclidean distance is the square root of the
sum of the squared differences between corresponding
elements of the two slices.
impl Copy for f16
impl Eq for f16
impl StructuralPartialEq for f16
Auto Trait Implementations§
impl Freeze for f16
impl RefUnwindSafe for f16
impl Send for f16
impl Sync for f16
impl Unpin for f16
impl UnsafeUnpin for f16
impl UnwindSafe for f16
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