GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
Public Member Functions | List of all members
ReedSolomon Class Reference

Class implementing a Reed-Solomon encoder and decoder RS(255,K,d) where k=255-nroots is the information vector length and d=nroots+1 is the minimum Hamming distance, with symbols of 8 bits. It allows shortened RS codes. More...

#include <reed_solomon.h>

Public Member Functions

 ReedSolomon (const std::string &gnss_signal=std::string())
 Default constructor. Constructs a Reed Solomon object. The encode_with_generator_poly and encode_with_generator_matrix methods are available for testing purposes. More...
 
 ReedSolomon (int nroots, int minpoly, int prim, int fcr, int pad=0, int shortening=0, const std::vector< uint8_t > &genpoly_coeff=std::vector< uint8_t >{}, const std::vector< std::vector< uint8_t >> &gen_matrix=std::vector< std::vector< uint8_t >>{})
 Custom constructor for RS(255, 255-nroots, nroots+1). Parameters: More...
 
int decode (std::vector< uint8_t > &data_to_decode, const std::vector< int > &erasure_positions=std::vector< int >{}) const
 Decode an encoded block. More...
 
std::vector< uint8_t > encode_with_generator_matrix (const std::vector< uint8_t > &data_to_encode) const
 Encode data with the generator matrix (for testing purposes) More...
 
std::vector< uint8_t > encode_with_generator_poly (const std::vector< uint8_t > &data_to_encode) const
 Encode data with the generator polynomial (for testing purposes) More...
 

Detailed Description

Class implementing a Reed-Solomon encoder and decoder RS(255,K,d) where k=255-nroots is the information vector length and d=nroots+1 is the minimum Hamming distance, with symbols of 8 bits. It allows shortened RS codes.

Definition at line 40 of file reed_solomon.h.

Constructor & Destructor Documentation

◆ ReedSolomon() [1/2]

ReedSolomon::ReedSolomon ( const std::string &  gnss_signal = std::string())
explicit

Default constructor. Constructs a Reed Solomon object. The encode_with_generator_poly and encode_with_generator_matrix methods are available for testing purposes.

gnss_signal: empty or "E6B" sets the Galileo E6B RS parameters. "E1B" sets the Galileo E1B (INAV) RS parameters.

◆ ReedSolomon() [2/2]

ReedSolomon::ReedSolomon ( int  nroots,
int  minpoly,
int  prim,
int  fcr,
int  pad = 0,
int  shortening = 0,
const std::vector< uint8_t > &  genpoly_coeff = std::vector< uint8_t >{},
const std::vector< std::vector< uint8_t >> &  gen_matrix = std::vector< std::vector< uint8_t >>{} 
)

Custom constructor for RS(255, 255-nroots, nroots+1). Parameters:

nroots - the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block.

minpoly - primitive polynomial.

prim - the primitive root of the generator polynomial.

fcr - first consecutive root of the Reed-Solomon generator polynomial.

pad - the number of pad symbols in a block. If not defined, it defaults to 0.

shortening - value of the shortening parameter. Defaults to 0. If different to 0, it defines a shortened RS encoder/decoder.

genpoly_coeff - a vector of (nroots+1) elements containing the generator polynomial coefficients. Only used for encoding. Defaults to empty. If defined, the encode_with_generator_poly method can be used.

gen_matrix - a (255-shortening)x(255-nroots-shortening) matrix containing the elements of the generator matrix. Only used for encoding. Defaults to empty. If defined, the encode_with_generator_matrix method can be used.

Member Function Documentation

◆ decode()

int ReedSolomon::decode ( std::vector< uint8_t > &  data_to_decode,
const std::vector< int > &  erasure_positions = std::vector< int >{} 
) const

Decode an encoded block.

The decoded symbols are at the first 255-nroots-shortening elements of the data_to_decode vector.

The second parameter is optional, and contains a vector of erasure positions to be passed to the decoding algorithm. Defaults to empty.

Returns the number of corrected errors, or -1 if decoding failed.

◆ encode_with_generator_matrix()

std::vector<uint8_t> ReedSolomon::encode_with_generator_matrix ( const std::vector< uint8_t > &  data_to_encode) const

Encode data with the generator matrix (for testing purposes)

Returns the encoded vector. It is set to all zeros if the generator matrix is not defined.

◆ encode_with_generator_poly()

std::vector<uint8_t> ReedSolomon::encode_with_generator_poly ( const std::vector< uint8_t > &  data_to_encode) const

Encode data with the generator polynomial (for testing purposes)

Returns the encoded vector. It is set to all zeros if the generator polynomial is not defined.


The documentation for this class was generated from the following file: