pub struct ReedSolomon { /* private fields */ }Expand description
A (shortened) Reed–Solomon code over $\mathrm{GF}(2^{m})$ (see the module).
Implementations§
Source§impl ReedSolomon
impl ReedSolomon
Sourcepub fn new(m: u32, t: usize) -> Result<ReedSolomon>
pub fn new(m: u32, t: usize) -> Result<ReedSolomon>
The $t$-error-correcting code of length $2^{m} - 1$ over the field of the
conventional primitive polynomial (primitive_polynomial), roots
$\alpha, \dots, \alpha^{2t}$ ($b = 1$).
§Errors
comnum_core::Error::Config for $m$ outside 2 to 16 or $2t \ge 2^{m} - 1$.
Sourcepub fn shortened(m: u32, t: usize, n: usize) -> Result<ReedSolomon>
pub fn shortened(m: u32, t: usize, n: usize) -> Result<ReedSolomon>
The code of ReedSolomon::new shortened to n symbols.
§Errors
comnum_core::Error::Config for $m$ outside 2 to 16 or a length that leaves no
information symbol or exceeds $2^{m} - 1$.
Sourcepub fn with_field(
m: u32,
poly: u32,
first_root: usize,
root_step: usize,
t: usize,
n: usize,
) -> Result<ReedSolomon>
pub fn with_field( m: u32, poly: u32, first_root: usize, root_step: usize, t: usize, n: usize, ) -> Result<ReedSolomon>
The code of n symbols correcting t errors over the field of the primitive
polynomial poly (bit $i$ the coefficient of $x^{i}$), with the generator roots
$\beta^{b}, \dots, \beta^{b+2t-1}$, $\beta = \alpha^{c}$: first_root is $b$
and root_step is $c$.
§Errors
comnum_core::Error::Config for $m$ outside 2 to 16, a polynomial that is not
primitive, a root step that is not coprime with $2^{m} - 1$, $t = 0$, or a length
that leaves no information symbol or exceeds $2^{m} - 1$.
Sourcepub fn n_symbols(&self) -> usize
pub fn n_symbols(&self) -> usize
Codeword length $n$ in symbols (BlockCode::n counts the $nm$ bits).
Sourcepub fn k_symbols(&self) -> usize
pub fn k_symbols(&self) -> usize
Message length $k = n - 2t$ in symbols (BlockCode::k counts the $km$ bits).
Sourcepub fn first_root(&self) -> usize
pub fn first_root(&self) -> usize
The first consecutive root $b$.
Sourcepub fn generator(&self) -> &[u16]
pub fn generator(&self) -> &[u16]
The generator polynomial $g(x)$, lowest degree first (monic, degree $2t$).
Sourcepub fn encode_symbols(&self, msg: &[u16]) -> Result<Vec<u16>>
pub fn encode_symbols(&self, msg: &[u16]) -> Result<Vec<u16>>
The codeword of $k$ message symbols: the message, then the $2t$ parity symbols (highest degree first).
§Errors
comnum_core::Error::Shape for another number of symbols,
comnum_core::Error::Config for a symbol that does not fit in $m$ bits.
Sourcepub fn decode_symbols(&self, r: &[u16]) -> Result<(Vec<u16>, Option<usize>)>
pub fn decode_symbols(&self, r: &[u16]) -> Result<(Vec<u16>, Option<usize>)>
Decode $n$ received symbols: the message and the number of corrected symbols
(None if the word has more errors than the code corrects and they were
detected; the message symbols are then returned as received).
§Errors
comnum_core::Error::Shape for another number of symbols,
comnum_core::Error::Config for a symbol that does not fit in $m$ bits.
Sourcepub fn decode_erasures(
&self,
r: &[u16],
erasures: &[usize],
) -> Result<(Vec<u16>, Option<usize>)>
pub fn decode_erasures( &self, r: &[u16], erasures: &[usize], ) -> Result<(Vec<u16>, Option<usize>)>
Decode $n$ received symbols with the positions erasures (0 to $n - 1$, in
transmission order) known to be unreliable: the message and the number of
corrected symbols (erasures included), None for a decoding failure (more than
$2t - s$ errors in the $n - s$ other positions, when detected; the message
symbols are then returned as received).
§Errors
comnum_core::Error::Shape for another number of symbols,
comnum_core::Error::Config for a symbol that does not fit in $m$ bits, an
erasure position outside the word, a repeated one, or more than $2t$ erasures.
Sourcepub fn encode(&self, bits: &[u8]) -> Result<Vec<u8>>
pub fn encode(&self, bits: &[u8]) -> Result<Vec<u8>>
The codeword of $km$ message bits as $nm$ bits ($m$ per symbol, most significant first): the message bits, then the parity.
§Errors
comnum_core::Error::Shape for another number of bits.
Sourcepub fn decode(&self, bits: &[u8]) -> Result<(Vec<u8>, Option<usize>)>
pub fn decode(&self, bits: &[u8]) -> Result<(Vec<u8>, Option<usize>)>
Decode $nm$ hard bits: the $km$ message bits and the number of corrected
symbols (None for a detected decoding failure, the message bits then returned
as received).
§Errors
comnum_core::Error::Shape for another number of bits.
Trait Implementations§
Source§impl BlockCode for ReedSolomon
impl BlockCode for ReedSolomon
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 ReedSolomon::decode; a decoding failure
returns the message bits as received.
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