Skip to main content

Ccdm

Struct Ccdm 

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

A constant-composition distribution matcher (see the module).

Implementations§

Source§

impl Ccdm

Source

pub fn new(composition: Vec<usize>) -> Result<Ccdm>

The matcher of a composition: composition[a] occurrences of symbol a.

§Errors

comnum_core::Error::Config for an empty composition or one that carries no bit.

Source

pub fn from_distribution(p: &[f64], n: usize) -> Result<Ccdm>

The matcher of blocks of n symbols whose composition is the nearest to the distribution p (largest remainders: ⌊n p_a⌋, then one more for the largest remainders until the sum is n).

§Errors

comnum_core::Error::Config for probabilities that are not non-negative with a positive sum, and as Ccdm::new.

Source

pub fn composition(&self) -> &[usize]

The composition.

Source

pub fn n(&self) -> usize

Symbols per block $n$.

Source

pub fn k(&self) -> usize

Bits per block $k$.

Source

pub fn rate(&self) -> f64

The rate $k/n$ (bits per symbol).

Source

pub fn distribution(&self) -> Vec<f64>

The distribution of the symbols, $n_{a}/n$.

Source

pub fn match_bits(&self, bits: &[u8]) -> Result<Vec<usize>>

The sequence of $n$ symbols of bits ($k$ bits, the rank, most significant first).

§Errors

comnum_core::Error::Shape if bits does not have $k$ bits.

Source

pub fn dematch(&self, symbols: &[usize]) -> Result<Vec<u8>>

The $k$ bits of a sequence of $n$ symbols (its rank, most significant first); a symbol the composition has used up is replaced by the nearest available one.

§Errors

comnum_core::Error::Shape if symbols does not have $n$ symbols.

Trait Implementations§

Source§

impl Clone for Ccdm

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 Debug for Ccdm

Source§

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

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

impl Eq for Ccdm

Source§

impl PartialEq for Ccdm

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 Ccdm

Auto Trait Implementations§

§

impl Freeze for Ccdm

§

impl RefUnwindSafe for Ccdm

§

impl Send for Ccdm

§

impl Sync for Ccdm

§

impl Unpin for Ccdm

§

impl UnsafeUnpin for Ccdm

§

impl UnwindSafe for Ccdm

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.