[][src]Trait believer::decoders::Decoder

pub trait Decoder: Send + Sync {
    type Error;
    type Result: DecodingResult;
    fn decode(&self, error: &Self::Error) -> Self::Result;
fn random_error(&self) -> Self::Error; }

Associated Types

Loading content...

Required methods

fn decode(&self, error: &Self::Error) -> Self::Result

fn random_error(&self) -> Self::Error

Loading content...

Implementors

impl<'a> Decoder for ErasureDecoder<'a>[src]

type Error = Vec<usize>

type Result = ErasureResult

impl<'a, C> Decoder for BPDecoder<'a, C> where
    C: BinaryChannel
[src]

type Error = Vec<GF2>

type Result = BPResult

fn decode(&self, message: &Self::Error) -> Self::Result[src]

Decodes a given message doing at most max_iters iterations. Returns Some(codeword) if the decoder converge to a solution of None if it didn't find a solution in the given the number of iterations.

Panic

Panics if message lenght doesn't correspond to self.n_bits().

Example

let channel = channel::BinarySymmetricChannel::new(0.2);
let parity_check = ParityCheckMatrix::new(
    vec![
        vec![0, 1],
        vec![1, 2],
        vec![2, 3],
    ],
    4
);
let decoder = BPDecoder::new(&channel, &parity_check, 10);

// Should be able to decode this message to the 1 codeword.
let easy_message = vec![GF2::B0, GF2::B1, GF2::B1, GF2::B1];
let easy_decoded = decoder.decode(&easy_message);
assert_eq!(easy_decoded, BPResult::Codeword(vec![GF2::B1; 4]));

// Should get stuck while decoding this message.
let impossible_message = vec![GF2::B0, GF2::B0, GF2::B1, GF2::B1];
let impossible_decoded = decoder.decode(&impossible_message);
assert_eq!(impossible_decoded, BPResult::GotStuck);
Loading content...