Skip to main content

LabelHalves

Struct LabelHalves 

Source
pub struct LabelHalves { /* private fields */ }
Expand description

The metrics of one symbol over the two halves of its labels for one bit: the label $i$ of a point is in half $b$ when bit shift of $i$ is $b$, and every half keeps its largest metric $\mu_{b}$ and the sum $s_{b} = \sum_{i} e^{\ell_{i} - \mu_{b}}$, so that

$$ \ln \sum_{i \in b} e^{\ell_{i}} = \mu_{b} + \ln s_{b}, \qquad L = \mu_{0} + \ln s_{0} - \mu_{1} - \ln s_{1} $$

(with max-log, $\mu_{b}$ and $\mu_{0} - \mu_{1}$). The kernel of the bitwise demapper (Constellation::llr), of the bitwise closed forms (crate::theory) and of the bit-metric rates of comnum_metrics: the metric row $\ell_{i}$ (a log-likelihood plus a log-prior) is theirs, the sums are these.

§Examples

use comnum_mapping::demapper::LabelHalves;
use comnum_math::Jacobian;
// four labels, bit 1 (the most significant): halves {0, 1} and {2, 3}
let h = LabelHalves::new(&[0.0, -1.0, -3.0, -2.0], 1, Jacobian::Exact);
assert!((h.log_sum(0) - (1.0 + (-1f64).exp()).ln()).abs() < 1e-15);
assert_eq!(LabelHalves::new(&[0.0, -1.0, -3.0, -2.0], 1, Jacobian::MaxLog).llr(), 2.0);

Implementations§

Source§

impl LabelHalves

Source

pub fn new(metric: &[f64], shift: usize, jacobian: Jacobian) -> LabelHalves

The halves of the metric row metric (one value per label) for bit shift of the labels; with Jacobian::MaxLog, the maxima only.

Source

pub fn log_sum(&self, bit: usize) -> f64

$\ln \sum_{i \in b} e^{\ell_{i}}$ over the half bit (0 or 1): $\mu_{b} + \ln s_{b}$, or $\mu_{b}$ with max-log or when $\mu_{b}$ is not finite.

Source

pub fn llr(&self) -> f64

The LLR of the bit, $\mu_{0} + \ln s_{0} - \mu_{1} - \ln s_{1}$ (positive for a 0), or $\mu_{0} - \mu_{1}$ with max-log or when a maximum is not finite.

Trait Implementations§

Source§

impl Clone for LabelHalves

Source§

fn clone(&self) -> Self

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 Copy for LabelHalves

Source§

impl Debug for LabelHalves

Source§

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

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

impl PartialEq for LabelHalves

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LabelHalves

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.