IT++ Logo
punct_convcode.h
Go to the documentation of this file.
1 
29 #ifndef PUNCT_CONVCODE_H
30 #define PUNCT_CONVCODE_H
31 
32 #include <itpp/base/vec.h>
33 #include <itpp/base/mat.h>
34 #include <itpp/base/array.h>
35 #include <itpp/comm/convcode.h>
36 #include <itpp/itexports.h>
37 
38 namespace itpp
39 {
40 
81 {
82 public:
87 
94  void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
95  { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); }
97  void set_generator_polynomials(const ivec &gen, int constraint_length)
98  { Convolutional_Code::set_generator_polynomials(gen, constraint_length); }
100  ivec get_generator_polynomials() const { return gen_pol; }
101 
103  virtual double get_rate() const { return rate; }
104 
107 
109  void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size
111  bmat get_puncture_matrix() const { return puncture_matrix; }
113  int get_puncture_period() const { return Period; }
114 
116  void init_encoder() { encoder_state = start_state; }
117 
119  void encode(const bvec &input, bvec &output);
121  bvec encode(const bvec &input) { bvec output; encode(input, output); return output; }
122 
124  void encode_trunc(const bvec &input, bvec &output);
126  bvec encode_trunc(const bvec &input) { bvec output; encode_trunc(input, output); return output; }
127 
135  void encode_tail(const bvec &input, bvec &output);
143  bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; }
144 
146  void encode_tailbite(const bvec &input, bvec &output);
148  bvec encode_tailbite(const bvec &input)
149  { bvec output; encode_tailbite(input, output); return output; }
150 
151 
153  virtual void decode(const vec &received_signal, bvec &output);
155  virtual bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; }
156 
157  // ------------ Hard-decision decoding is not implemented -------------------
158  virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
159  virtual bvec decode(const bvec &coded_bits);
160 
162  void decode_trunc(const vec &received_signal, bvec &output);
164  bvec decode_trunc(const vec &received_signal) { bvec output; decode_trunc(received_signal, output); return output; }
165 
172  void decode_tail(const vec &received_signal, bvec &output);
179  bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; }
180 
182  void decode_tailbite(const vec &received_signal, bvec &output);
184  bvec decode_tailbite(const vec &received_signal)
185  { bvec output; decode_tailbite(received_signal, output); return output; }
186 
187  /*
188  \brief Calculate the inverse sequence
189 
190  Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence
191  (not a valid codeword).
192  */
193  bool inverse_tail(const bvec coded_sequence, bvec &input);
194 
196  bool catastrophic(void);
197 
199  void distance_profile(ivec &dist_prof, int time, int dmax = 100000, bool reverse = false);
200 
217  void calculate_spectrum(Array<ivec> &spectrum, int dmax, int no_terms);
218 
229  void calculate_spectrum(Array<ivec> &spectrum, int time, int dmax, int no_terms, int block_length = 0);
230 
247  int fast(Array<ivec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
248 
249 protected:
251  int weight(const int state, const int input, int time);
253  void weight(const int state, int &w0, int &w1, int time);
255  int weight_reverse(const int state, const int input, int time);
257  void weight_reverse(const int state, int &w0, int &w1, int time);
258 
260  int Period;
262  int total;
265 };
266 
267 } // namespace itpp
268 
269 #endif // #ifndef PUNCT_CONVCODE_H
Definition of a binary convolutional encoder class.
void set_method(const CONVOLUTIONAL_CODE_METHOD method)
Set encoding and decoding method (Trunc, Tail, or Tailbite)
Definition: convcode.h:117
void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
Set the code according to built-in tables.
virtual bvec decode(const vec &received_signal)
Viterbi decoding using specified method.
Binary Convolutional rate 1/n class.
Definition: convcode.h:104
Vec< T > reverse(const Vec< T > &in)
Reverse the input vector.
Definition: matfunc.h:777
ivec get_generator_polynomials() const
Get generator polynomials.
int total
The number of "1" in the puncture matrix.
bvec decode_trunc(const vec &received_signal)
Viterbi decoding using truncation of memory (default = 5*K)
bvec encode_tail(const bvec &input)
Encoding that begins and ends in the zero state.
void set_generator_polynomials(const ivec &gen, int constraint_length)
Set generator polynomials. Given in Proakis integer form.
Definition: convcode.cpp:555
bvec decode_tailbite(const vec &received_signal)
Decode a block of encoded data where encode_tailbite has been used. Tries all start states...
virtual ~Punctured_Convolutional_Code(void)
Destructor.
int weight(const bvec &a)
Calculate the Hamming weight of a.
Definition: commfunc.cpp:71
Definition of Array class (container)
CONVOLUTIONAL_CODE_TYPE
Type of Convolutional Code.
Definition: convcode.h:47
bmat puncture_matrix
The puncture matrix (n rows and Period columns)
Matrix Class Definitions.
int get_puncture_period() const
Get puncturing period.
bvec decode_tail(const vec &received_signal)
Decode a block of encoded data where encode_tail has been used.
virtual double get_rate() const
Return rate of code.
vec spectrum(const vec &v, int nfft, int noverlap)
Power spectrum calculation.
Definition: sigfun.cpp:267
itpp namespace
Definition: itmex.h:36
bvec encode_tailbite(const bvec &input)
Encode a binary vector of inputs using tailbiting.
int Period
The puncture period (i.e. the number of columns in the puncture matrix)
void init_encoder()
Set the encoder internal state in start_state (set by set_start_state()).
CONVOLUTIONAL_CODE_METHOD
Encoding and decoding methods for Convolutional codes.
Definition: convcode.h:53
void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
Set the code according to built-in tables.
Definition: convcode.cpp:537
Punctured_Convolutional_Code(void)
Constructor.
bvec encode(const bvec &input)
Encode a binary vector of inputs using specified method.
void set_generator_polynomials(const ivec &gen, int constraint_length)
Set generator polynomials. Given in Proakis integer form.
void set_method(const CONVOLUTIONAL_CODE_METHOD method)
Set encoding and decoding method (Trunc, Tail, or Tailbite)
bvec encode_trunc(const bvec &input)
Encode a binary vector of inputs starting from state set by the set_state function.
Binary Punctured Convolutional Code Class.
bmat get_puncture_matrix() const
Get puncture matrix.
Mat< bin > bmat
bin matrix
Definition: mat.h:508
Templated Vector Class Definitions.

Generated on Thu Jun 21 2018 16:06:18 for IT++ by Doxygen 1.8.13