38 #include <itpp/itexports.h> 92 LDPC_Parity(
const std::string& filename,
const std::string& format);
101 void initialize(
int ncheck,
int nvar);
117 "LDPC_Parity::get_nvar(): Internal error");
119 "LDPC_Parity::get_nvar(): Internal error");
126 "LDPC_Parity::get_ncheck(): Internal error");
128 "LDPC_Parity::get_ncheck(): Internal error");
133 void set(
int i,
int j,
bin value);
136 bin get(
int i,
int j)
const {
137 it_assert_debug(H(i, j) == Ht(j, i),
"LDPC_Parity::get(): Internal error");
144 "LDPC_Parity::operator(): Internal error");
149 virtual void display_stats()
const;
153 return (1.0 - static_cast<double>(ncheck) / nvar);
163 void load_alist(
const std::string& alist_file);
166 void save_alist(
const std::string& alist_file)
const;
172 static const int Nmax = 200;
201 int check_for_cycles(
int L)
const;
246 int check_connectivity(
int from_m,
int from_n,
int to_m,
int to_n,
279 virtual void display_stats()
const = 0;
299 int cycle_removal_MGW(
int L);
303 void generate_random_H(
const ivec& C,
const ivec& R,
const ivec& cycopt);
318 void compute_CR(
const vec& var_deg,
const vec& chk_deg,
const int Nvar,
339 const std::string& method =
"rand",
340 const ivec& options =
"200 6");
380 void generate(
int Nvar,
const vec& var_deg,
const vec& chk_deg,
381 const std::string& method =
"rand",
382 const ivec& options =
"200 6");
404 const std::string& method =
"rand",
405 const ivec& options =
"200 6");
425 void generate(
int Nvar,
int k,
int l,
426 const std::string& method =
"rand",
427 const ivec& options =
"200 6");
471 BLDPC_Parity(
const std::string &filename,
int exp_factor);
474 void expand_base(
const imat &base_matrix,
int exp_factor);
477 int get_exp_factor()
const;
480 imat get_base_matrix()
const;
483 bool is_valid()
const {
return H_b_valid && init_flag; }
486 void set_exp_factor(
int exp_factor);
489 void load_base_matrix(
const std::string &filename);
492 void save_base_matrix(
const std::string &filename)
const;
500 void calculate_base_matrix();
529 type(new
std::string(type_in)) {}
534 virtual void encode(
const bvec &input, bvec &output) = 0;
549 virtual void save(
const std::string& filename)
const = 0;
551 virtual void load(
const std::string& filename) = 0;
577 bool natural_ordering =
false,
578 const ivec& ind =
"");
584 virtual void encode(
const bvec &input, bvec &output);
619 ivec construct(
LDPC_Parity*
const H,
bool natural_ordering =
false,
620 const ivec& ind =
"");
624 virtual void save(
const std::string& filename)
const;
626 virtual void load(
const std::string& filename);
652 const std::string type =
"BLDPC");
658 void encode(
const bvec &input, bvec &output);
665 void save(
const std::string &filename)
const;
667 void load(
const std::string &filename);
748 bool perform_integrity_check =
true);
770 bool perform_integrity_check =
true);
785 void load_code(
const std::string& filename,
LDPC_Generator*
const G = 0);
795 void save_code(
const std::string& filename)
const;
806 void set_decoding_method(
const std::string& method);
821 void set_exit_conditions(
int max_iters,
822 bool syndr_check_each_iter =
true,
823 bool syndr_check_at_start =
false);
840 virtual void encode(
const bvec &input, bvec &output);
842 virtual bvec encode(
const bvec &input);
848 virtual void decode(
const bvec &, bvec &) {
849 it_error(
"LDPC_Code::decode(): Hard input decoding not implemented");
853 it_error(
"LDPC_Code::decode(): Hard input decoding not implemented");
858 virtual void decode(
const vec &llr_in, bvec &syst_bits);
860 virtual bvec decode(
const vec &llr_in);
863 void decode_soft_out(
const vec &llr_in, vec &llr_out);
865 vec decode_soft_out(
const vec &llr_in);
889 int bp_decode(
const QLLRvec &LLRin, QLLRvec &LLRout);
899 bool syndrome_check(
const QLLRvec &LLR)
const;
902 bool syndrome_check(
const bvec &b)
const;
912 QLLRvec soft_syndrome_check(
const QLLRvec &LLR)
const;
918 return (1.0 - static_cast<double>(ncheck) / nvar);
944 void decoder_parameterization(
const LDPC_Parity*
const H);
947 void integrity_check();
950 void setup_decoder();
960 std::string* dec_method;
966 ivec C, V, sumX1, sumX2, iind, jind;
972 static const int max_cnd = 200;
980 ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const LDPC_Code &C);
GF2mat_sparse Ht
The transposed parity check matrix.
int get_exp_factor() const
Get expansion factor.
ivec sumX2
Actual number of ones in each row.
int nvar
Number of variable nodes.
GF2mat H_enc
Preprocessed parity check matrix.
bool init_flag
Flag that indicates proper initialization.
Block LDPC code parity-check matrix.
LDPC_Parity_Regular()
Default constructor.
LDPC_Generator(const std::string &type_in="")
Default constructor.
BLDPC_Parity()
Default constructor.
Class for dense GF(2) matrices.
virtual bvec decode(const bvec &)
Inherited from the base class - not implemented here.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
int ncheck
Number of check nodes.
int K
Number of information bits = N-M.
int get_nvar() const
Get the number of variable nodes.
double get_rate() const
Get the coderate.
void display_stats() const
Display some information about the matrix.
void display_stats() const
Display some information about the matrix.
std::string get_type() const
Return generator type.
GF2mat_sparse H
The parity check matrix.
Generic Channel Code class.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
bin operator()(int i, int j) const
Get element (i,j) of the parity check matrix.
BLDPC_Generator(const std::string type="BLDPC")
Default constructor.
Pure abstract class for unstructured LDPC matrices.
LDPC Generator pure virtual base class.
Sparse_Vec< bin > get_col(int c) const
Get a specific column from the matrix.
GF2mat_sparse get_H(bool transpose=false) const
Get the parity check matrix, optionally its transposed form.
int get_ncheck() const
Get the number of check nodes.
Irregular LDPC code generator class.
int get_ncheck() const
Get the number of check nodes (number of rows)
virtual ~LDPC_Parity()
Virtual destructor.
bool is_initialized() const
Check if generator is initialized.
int get_nrof_iterations() const
Get the maximum number of iterations of the decoder.
Channel Code class virtual interface.
LLR_calc_unit get_llrcalc() const
Get LLR calculation unit used in decoder.
virtual void decode(const bvec &, bvec &)
Inherited from the base class - not implemented here.
Low-density parity check (LDPC) codec.
Block LDPC Generator class.
Class for numerically efficient log-likelihood algebra.
int M
Number of parity check bits = H_enc.rows()
int get_ninfo() const
Get the number of information bits per codeword.
int get_nvar() const
Get the number of variable nodes (number of columns)
int N
Codeword length = H_enc.cols()
Log-likelihood algebra calculation unit.
LDPC parity check matrix generic class.
std::string get_decoding_method() const
Return the decoding method.
Binary arithmetic (boolean) class.
#define it_error(s)
Abort unconditionally.
void transpose(const Mat< T > &m, Mat< T > &out)
Transposition of the matrix m returning the transposed matrix in out.
virtual void display_stats() const
Display some information about the matrix.
Sparse_Vec< bin > get_row(int r) const
Get a specific row from the matrix.
Definition of a class for algebra on GF(2) (binary) matrices.
bool is_valid() const
Verify initialisation.
LDPC_Generator_Systematic()
Default constructor.
Definition of classes for random number generators.
virtual ~LDPC_Generator_Systematic()
Virtual destructor.
void mark_initialized()
Mark generator as initialized.
Parameterized "alist" representation of sparse GF(2) matrix.
Systematic LDPC Generator class.
LDPC_Parity_Irregular()
Default constructor.
double get_rate() const
Get the code rate.
LDPC_Parity()
Default constructor.
virtual ~LDPC_Code()
Destructor.
Regular LDPC code generator class.
virtual ~LDPC_Generator()
Virtual destructor.
ivec sumX1
Actual number of ones in each column.