pub struct Bch { /* private fields */ }Expand description
A shortened binary BCH code (see the module).
Implementations§
Source§impl Bch
impl Bch
Sourcepub fn new(m: u32, poly: u32, t: usize, n: usize) -> Result<Bch>
pub fn new(m: u32, poly: u32, t: usize, n: usize) -> Result<Bch>
The code of $\mathrm{GF}(2^{m})$ with the primitive polynomial poly (bit $i$ the
coefficient of $x^{i}$), correcting t errors, shortened to n bits.
§Errors
comnum_core::Error::Config for a polynomial that is not primitive, or a length
that leaves no message bit or exceeds $2^{m} - 1$.
Sourcepub fn encode(&self, msg: &[u8]) -> Result<Vec<u8>>
pub fn encode(&self, msg: &[u8]) -> Result<Vec<u8>>
The codeword of $k$ message bits: the message, then the parity bits (highest degree first).
§Errors
comnum_core::Error::Shape for another number of bits.
Sourcepub fn decode(&self, r: &[u8]) -> Result<(Vec<u8>, Option<usize>)>
pub fn decode(&self, r: &[u8]) -> Result<(Vec<u8>, Option<usize>)>
Decode $n$ hard bits: the message and the number of corrected errors (None if
the word has more errors than the code corrects and they were detected; the
message bits are then returned as received).
§Errors
comnum_core::Error::Shape for another number of bits.
Trait Implementations§
Source§impl BlockCode for Bch
impl BlockCode for Bch
Source§fn decode_block(&self, llr: &[f64]) -> Result<Vec<u8>>
fn decode_block(&self, llr: &[f64]) -> Result<Vec<u8>>
Hard decisions of the LLRs, then Bch::decode; a decoding failure returns the
message bits as received (as crate::rs::ReedSolomon).
Source§fn encode_block(&self, info: &[u8]) -> Result<Vec<u8>>
fn encode_block(&self, info: &[u8]) -> Result<Vec<u8>>
Source§fn encode_block_into(&self, info: &[u8], out: &mut [u8]) -> Result<()>
fn encode_block_into(&self, info: &[u8], out: &mut [u8]) -> Result<()>
out (ADR 0011: the default
copies BlockCode::encode_block; a code overrides it when a profile shows the
copy). Read moreSource§fn decode_block_into(&self, llr: &[f64], out: &mut [u8]) -> Result<()>
fn decode_block_into(&self, llr: &[f64], out: &mut [u8]) -> Result<()>
out (as
BlockCode::encode_block_into). Read more