#include <ldpc.h>
Public Member Functions | |
| LDPC_Code () | |
| Default constructor. | |
| LDPC_Code (const LDPC_Parity *const H, LDPC_Generator *const G=0) | |
| Constructor, from a parity check matrix and optionally a generator. | |
| LDPC_Code (const std::string &filename, LDPC_Generator *const G=0) | |
| Constructor, from a saved file. | |
| virtual | ~LDPC_Code () |
| Destructor. | |
| void | set_code (const LDPC_Parity *const H, LDPC_Generator *const G=0) |
| Set the codec, from a parity check matrix and optionally a generator. | |
| void | load_code (const std::string &filename, LDPC_Generator *const G=0) |
| Set the codec, by reading from a saved file. | |
| void | save_code (const std::string &filename) const |
| Save the codec to a file. | |
| void | set_decoding_method (const std::string &method) |
| Set the decoding method. | |
| void | set_exit_conditions (int max_iters, bool syndr_check_each_iter=true, bool syndr_check_at_start=false) |
| Set the decoding loop exit conditions. | |
| void | set_llrcalc (const LLR_calc_unit &llrcalc) |
| Set LLR calculation unit. | |
| virtual void | encode (const bvec &input, bvec &output) |
| Encode codeword. | |
| virtual bvec | encode (const bvec &input) |
| Encode codeword. | |
| virtual void | decode (const bvec &, bvec &) |
| Inherited from the base class - not implemented here. | |
| virtual bvec | decode (const bvec &) |
| Inherited from the base class - not implemented here. | |
| virtual void | decode (const vec &llr_in, bvec &syst_bits) |
| This function outputs systematic bits of the decoded codeword. | |
| virtual bvec | decode (const vec &llr_in) |
| This function outputs systematic bits of the decoded codeword. | |
| void | decode_soft_out (const vec &llr_in, vec &llr_out) |
This function is a wrapper for bp_decode(). | |
| vec | decode_soft_out (const vec &llr_in) |
This function is a wrapper for bp_decode(). | |
| int | bp_decode (const QLLRvec &LLRin, QLLRvec &LLRout) |
| Belief propagation decoding. | |
| bool | syndrome_check (const QLLRvec &LLR) const |
| Syndrome check, on QLLR vector. | |
| bool | syndrome_check (const bvec &b) const |
| Syndrome check, on bit vector. | |
| double | get_rate () const |
| Get the coderate. | |
| int | get_nvar () const |
| Get the number of variable nodes. | |
| int | get_ncheck () const |
| Get the number of check nodes. | |
| int | get_ninfo () const |
| Get the number of information bits per codeword. | |
| std::string | get_decoding_method () const |
| Return the decoding method. | |
| int | get_nrof_iterations () const |
| Get the maximum number of iterations of the decoder. | |
| LLR_calc_unit | get_llrcalc () const |
| Get LLR calculation unit used in decoder. | |
Protected Member Functions | |
| void | decoder_parameterization (const LDPC_Parity *const H) |
| Function to compute decoder parameterization. | |
| void | integrity_check () |
| Function to check the integrity of the parity check matrix and generator. | |
| void | setup_decoder () |
| Initialize decoder. | |
Protected Attributes | |
| bool | H_defined |
| true if parity check matrix is defined | |
| bool | G_defined |
| true if generator is defined | |
| int | nvar |
| Number of variable nodes. | |
| int | ncheck |
| Number of check nodes. | |
| LDPC_Generator * | G |
| Generator object pointer. | |
| std::string | dec_method |
| Decoding method. | |
| int | max_iters |
| Maximum number of iterations. | |
| bool | psc |
| check syndrom after each iteration | |
| bool | pisc |
| check syndrom before first iteration | |
| LLR_calc_unit | llrcalc |
| LLR calculation unit. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const LDPC_Code &C) |
| Print some properties of the codec in plain text. | |
This class provides the functionality for encoding and decoding of LDPC codes defined via LDPC_Parity and LDPC_Generator classes.
LDPC codecs are constructed from parity check and generator matrices. Since the procedure of constructing the codec can be time-consuming (for example, due to optimization of the parity matrix and computation of the generator matrix), codecs can be saved to a file for later use. This class provides functionality and a special file format (the file format is designed to optimize the operation of the decoder) to do this. Some examples of load and save operations follow:
Saving a codec without generator matrix:
// assume the parity matrix is already defined and stored in H LDPC_Code C(&H); C.save_code("filename.it");
Saving a codec with generator matrix (for the example of systematic generator):
// assume the parity matrix is already defined and stored in H LDPC_Generator_Systematic G(&H); // create generator LDPC_Code C(&H, &G); C.save_code("filename.it");
Loading a codec without a generator:
LDPC_Code("filename.it");
Loading a codec with a generator (systematic in this example):
LDPC_Generator_Systematic G; // the generator object must be created first LDPC_Code("filename.it", &G);
| itpp::LDPC_Code::LDPC_Code | ( | const LDPC_Parity *const | H, | |
| LDPC_Generator *const | G = 0 | |||
| ) |
Constructor, from a parity check matrix and optionally a generator.
This constructor simply calls set_code().
References set_code().
| itpp::LDPC_Code::LDPC_Code | ( | const std::string & | filename, | |
| LDPC_Generator *const | G = 0 | |||
| ) |
| int itpp::LDPC_Code::bp_decode | ( | const QLLRvec & | LLRin, | |
| QLLRvec & | LLRout | |||
| ) |
Belief propagation decoding.
This function implements the sum-product message passing decoder (Pearl's belief propagation) using LLR values as messages. A fast update mechanism is used for nodes with large degrees.
| LLRin | vector of nvar input LLR values | |
| LLRout | vector of nvar output LLR values |
One can use set_exit_conditions() method to change the number of decoding iterations and related parameters parameters. The decoding function uses LLR_calc_unit to implement table-lookup for the Boxplus operator. By setting the parameters of the LLR_calc_unit provided in set_llrcalc(), one can change the resolution, for example to use a logmax approximation. See the documentation of LLR_calc_unit for details on how to do this.
References itpp::LLR_calc_unit::Boxplus(), H_defined, it_assert, it_error, it_info_debug, it_info_no_endl_debug, llrcalc, max_iters, ncheck, nvar, pisc, psc, and syndrome_check().
Referenced by decode(), and decode_soft_out().
| void itpp::LDPC_Code::encode | ( | const bvec & | input, | |
| bvec & | output | |||
| ) | [virtual] |
Encode codeword.
This is a wrapper functions which calls a proper implementation from the LDPC_Generator object.
| input | Vector of ncheck input bits | |
| output | Vector of nvar output bits |
Implements itpp::Channel_Code.
References itpp::LDPC_Generator::encode(), G, G_defined, it_assert, it_assert_debug, and syndrome_check().
Referenced by encode().
| void itpp::LDPC_Code::load_code | ( | const std::string & | filename, | |
| LDPC_Generator *const | G = 0 | |||
| ) |
Set the codec, by reading from a saved file.
The file format is defined in the source code. LDPC codecs can be saved with the function save_code().
| filename | Name of the file where the codec is stored | |
| G | A pointer to the optional generator object |
G points at 0 (default), the generator data is not read from the saved file. This means that the encoding can not be performed. References itpp::it_ifile::close(), G, G_defined, H_defined, it_assert, it_info_debug, itpp::LDPC_Generator::load(), ncheck, nvar, and setup_decoder().
Referenced by LDPC_Code().
| void itpp::LDPC_Code::save_code | ( | const std::string & | filename | ) | const |
Save the codec to a file.
| filename | Name of the file where to store the codec |
max_iters, syndr_check_each_iter, syndr_check_at_start and llrcalc) are not saved to a file. References itpp::it_file::close(), G, G_defined, H_defined, it_assert, it_info_debug, ncheck, nvar, itpp::it_file::open(), and itpp::LDPC_Generator::save().
| void itpp::LDPC_Code::set_code | ( | const LDPC_Parity *const | H, | |
| LDPC_Generator *const | G = 0 | |||
| ) |
Set the codec, from a parity check matrix and optionally a generator.
| H | The parity check matrix | |
| G | A pointer to the optional generator object |
References decoder_parameterization(), G, G_defined, integrity_check(), and setup_decoder().
Referenced by LDPC_Code().
| void itpp::LDPC_Code::set_decoding_method | ( | const std::string & | method | ) |
Set the decoding method.
Currently only a belief propagation method ("BP" or "bp") is supported.
References dec_method, and it_assert.
| void itpp::LDPC_Code::set_exit_conditions | ( | int | max_iters, | |
| bool | syndr_check_each_iter = true, |
|||
| bool | syndr_check_at_start = false | |||
| ) |
Set the decoding loop exit conditions.
| max_iters | Maximum number of the decoding iterations | |
| syndr_check_each_iter | If true, break the decoding loop as soon as valid codeword is found. Recommended value: true. | |
| syndr_check_at_start | If true, perform a syndrome check before entering the decoding loop. If LLRin corresponds to a valid codeword, set LLRout = LLRin. Recommended value: false. |
| bool itpp::LDPC_Code::syndrome_check | ( | const QLLRvec & | LLR | ) | const |
Syndrome check, on QLLR vector.
This function performs a syndrome check on a softbit (LLR vector). The function returns true for a valid codeword, false else.
| LLR | LLR-vector to check |
References ncheck.
Referenced by bp_decode(), encode(), integrity_check(), and syndrome_check().
| std::ostream & operator<< | ( | std::ostream & | os, | |
| const LDPC_Code & | C | |||
| ) | [friend] |
Print some properties of the codec in plain text.
Print some properties of the LDPC codec in plain text.
1.5.8