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
38namespace itpp
39{
40
81{
82public:
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
106 void set_method(const CONVOLUTIONAL_CODE_METHOD method) { Convolutional_Code::set_method(method); }
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
249protected:
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
262 int total;
265};
266
267} // namespace itpp
268
269#endif // #ifndef PUNCT_CONVCODE_H
Definition of Array class (container)
General array class.
Definition factory.h:40
Binary Convolutional rate 1/n class.
Definition convcode.h:105
Binary Punctured Convolutional Code Class.
void set_method(const CONVOLUTIONAL_CODE_METHOD method)
Set encoding and decoding method (Trunc, Tail, or Tailbite)
void set_generator_polynomials(const ivec &gen, int constraint_length)
Set generator polynomials. Given in Proakis integer form.
int get_puncture_period() const
Get puncturing period.
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 ~Punctured_Convolutional_Code(void)
Destructor.
bmat puncture_matrix
The puncture matrix (n rows and Period columns)
bvec encode_tail(const bvec &input)
Encoding that begins and ends in the zero state.
ivec get_generator_polynomials() const
Get generator polynomials.
bvec encode_tailbite(const bvec &input)
Encode a binary vector of inputs using tailbiting.
int total
The number of "1" in the puncture matrix.
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.
bmat get_puncture_matrix() const
Get puncture matrix.
Punctured_Convolutional_Code(void)
Constructor.
bvec encode_trunc(const bvec &input)
Encode a binary vector of inputs starting from state set by the set_state function.
bvec decode_tailbite(const vec &received_signal)
Decode a block of encoded data where encode_tailbite has been used. Tries all start states.
bvec encode(const bvec &input)
Encode a binary vector of inputs using specified method.
virtual bvec decode(const vec &received_signal)
Viterbi decoding using specified method.
bvec decode_trunc(const vec &received_signal)
Viterbi decoding using truncation of memory (default = 5*K)
void init_encoder()
Set the encoder internal state in start_state (set by set_start_state()).
int Period
The puncture period (i.e. the number of columns in the puncture matrix)
Definition of a binary convolutional encoder class.
CONVOLUTIONAL_CODE_METHOD
Encoding and decoding methods for Convolutional codes.
Definition convcode.h:53
CONVOLUTIONAL_CODE_TYPE
Type of Convolutional Code.
Definition convcode.h:47
int weight(const bvec &a)
Calculate the Hamming weight of a.
Definition commfunc.cpp:71
Matrix Class Definitions.
Mat< bin > bmat
bin matrix
Definition mat.h:508
itpp namespace
Definition itmex.h:37
Templated Vector Class Definitions.
SourceForge Logo

Generated on Tue Dec 10 2024 04:49:37 for IT++ by Doxygen 1.12.0