Skip to main content

Interleaver

Struct Interleaver 

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

A permutation of the positions of a block.

Implementations§

Source§

impl Interleaver

Source

pub fn from_permutation(perm: Vec<usize>) -> Result<Interleaver>

The interleaver of the permutation perm: output position $i$ takes input position perm[i].

§Errors

comnum_core::Error::Config if perm is not a permutation of $0, \dots, n - 1$.

§Examples
use comnum_fec::interleaving::Interleaver;
let p = Interleaver::from_permutation(vec![2, 0, 1])?;
assert_eq!(p.interleave(&['a', 'b', 'c']), ['c', 'a', 'b']);
assert!(Interleaver::from_permutation(vec![0, 0, 1]).is_err());
Source

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

$\pi$: output position $i$ takes input position perm()[i].

Source

pub fn block(rows: usize, cols: usize) -> Interleaver

Write row by row into rows × cols, read column by column.

Source

pub fn random(n: usize, seed: u64) -> Interleaver

A uniform random permutation of n positions (seeded).

Source

pub fn qpp(k: usize, f1: usize, f2: usize) -> Result<Interleaver>

The quadratic permutation polynomial $\pi(i) = (f_{1} i + f_{2} i^{2}) \bmod K$.

§Errors

comnum_core::Error::Config if the polynomial is not a permutation.

Source

pub fn from_name(name: &str, k: usize) -> Result<Interleaver>

The interleaver of a standard by name, for blocks of k bits: lte, the QPP interleaver of the LTE turbo code (crate::turbo::lte_qpp, TS 36.212, Table 5.1.3-3), case-insensitive.

§Errors

comnum_core::Error::Config for another name, or a size k outside the table.

Source

pub fn len(&self) -> usize

Length of the block.

Source

pub fn is_empty(&self) -> bool

Whether the block is empty.

Source

pub fn interleave<T: Copy>(&self, x: &[T]) -> Vec<T>

$y_{i} = x_{\pi(i)}$.

§Panics

If x is shorter than the permutation.

Source

pub fn deinterleave<T: Copy + Default>(&self, y: &[T]) -> Vec<T>

The inverse permutation.

§Panics

If y is shorter than the permutation.

Trait Implementations§

Source§

impl Clone for Interleaver

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 Interleaver

Source§

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

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

impl Eq for Interleaver

Source§

impl PartialEq for Interleaver

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 Interleaver

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.