#[repr(transparent)]pub struct bf16(pub u16);Expand description
A brain floating point (bfloat16) number.
This type represents Google’s bfloat16 format, which truncates IEEE 754 single-precision to 16 bits by keeping the exponent bits but reducing the mantissa. This provides a wider range than f16 but lower precision.
§Examples
use simsimd::bf16;
// Create from f32
let brain_half = bf16::from_f32(3.14);
// Convert back to f32
let float = brain_half.to_f32();
// Direct access to bits
let bits = brain_half.0;Tuple Fields§
§0: u16Implementations§
Source§impl bf16
impl bf16
Sourcepub fn from_f32(value: f32) -> Self
pub fn from_f32(value: f32) -> Self
Converts an f32 to bf16 representation.
§Examples
use simsimd::bf16;
let brain_half = bf16::from_f32(3.14159);Sourcepub fn to_f32(self) -> f32
pub fn to_f32(self) -> f32
Converts the bf16 to an f32.
§Examples
use simsimd::bf16;
let brain_half = bf16::from_f32(3.14159);
let float = brain_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 bf16
impl ComplexProducts for bf16
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 bf16
impl PartialOrd for bf16
Source§impl ProbabilitySimilarity for bf16
impl ProbabilitySimilarity for bf16
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 bf16
impl SpatialSimilarity for bf16
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 bf16
impl Eq for bf16
impl StructuralPartialEq for bf16
Auto Trait Implementations§
impl Freeze for bf16
impl RefUnwindSafe for bf16
impl Send for bf16
impl Sync for bf16
impl Unpin for bf16
impl UnsafeUnpin for bf16
impl UnwindSafe for bf16
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