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);