Binary Punctured Convolutional Code Class. More...
#include <itpp/comm/punct_convcode.h>
Public Member Functions | |
Punctured_Convolutional_Code (void) | |
Constructor. | |
virtual | ~Punctured_Convolutional_Code (void) |
Destructor. | |
void | set_code (const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length) |
Set the code according to built-in tables. | |
void | set_generator_polynomials (const ivec &gen, int constraint_length) |
Set generator polynomials. Given in Proakis integer form. | |
ivec | get_generator_polynomials () const |
Get generator polynomials. | |
virtual double | get_rate () const |
Return rate of code. | |
void | set_method (const CONVOLUTIONAL_CODE_METHOD method) |
Set encoding and decoding method (Trunc, Tail, or Tailbite) | |
void | set_puncture_matrix (const bmat &pmatrix) |
Set puncture matrix (size n*Period) | |
bmat | get_puncture_matrix () const |
Get puncture matrix. | |
int | get_puncture_period () const |
Get puncturing period. | |
void | init_encoder () |
Set the encoder internal state in start_state (set by set_start_state()). | |
void | encode (const bvec &input, bvec &output) |
Encode a binary vector of inputs using specified method. | |
bvec | encode (const bvec &input) |
Encode a binary vector of inputs using specified method. | |
void | encode_trunc (const bvec &input, bvec &output) |
Encode a binary vector of inputs starting from state set by the set_state function. | |
bvec | encode_trunc (const bvec &input) |
Encode a binary vector of inputs starting from state set by the set_state function. | |
void | encode_tail (const bvec &input, bvec &output) |
Encoding that begins and ends in the zero state. | |
bvec | encode_tail (const bvec &input) |
Encoding that begins and ends in the zero state. | |
void | encode_tailbite (const bvec &input, bvec &output) |
Encode a binary vector of inputs using tailbiting. | |
bvec | encode_tailbite (const bvec &input) |
Encode a binary vector of inputs using tailbiting. | |
virtual void | decode (const vec &received_signal, bvec &output) |
Viterbi decoding using specified method. | |
virtual bvec | decode (const vec &received_signal) |
Viterbi decoding using specified method. | |
virtual void | decode (const bvec &coded_bits, bvec &decoded_bits) |
Decode a bvec of coded data. | |
virtual bvec | decode (const bvec &coded_bits) |
Decode a bvec of coded data. | |
void | decode_trunc (const vec &received_signal, bvec &output) |
Viterbi decoding using truncation of memory (default = 5*K) | |
bvec | decode_trunc (const vec &received_signal) |
Viterbi decoding using truncation of memory (default = 5*K) | |
void | decode_tail (const vec &received_signal, bvec &output) |
Decode a block of encoded data where encode_tail has been used. | |
bvec | decode_tail (const vec &received_signal) |
Decode a block of encoded data where encode_tail has been used. | |
void | decode_tailbite (const vec &received_signal, bvec &output) |
Decode a block of encoded data where encode_tailbite has been used. Tries all start states. | |
bvec | decode_tailbite (const vec &received_signal) |
Decode a block of encoded data where encode_tailbite has been used. Tries all start states. | |
bool | inverse_tail (const bvec coded_sequence, bvec &input) |
bool | catastrophic (void) |
Check if the code is catastrophic. Returns true if catastrophic. | |
void | distance_profile (ivec &dist_prof, int time, int dmax=100000, bool reverse=false) |
Calculate distance profile. If reverse = true calculate for the reverse code instead. | |
void | calculate_spectrum (Array< ivec > &spectrum, int dmax, int no_terms) |
Calculate spectrum. | |
void | calculate_spectrum (Array< ivec > &spectrum, int time, int dmax, int no_terms, int block_length=0) |
Calculate spectrum. Suitable when calculating many terms in the spectra. Breadth first search. | |
int | fast (Array< ivec > &spectrum, int time, int dfree, int no_terms, int d_best_so_far=0, bool test_catastrophic=false) |
Cederwall's fast algorithm. | |
void | reset () |
Reset encoder and decoder states. | |
void | set_start_state (int state) |
Set encoder default start state. | |
int | get_encoder_state (void) const |
Get the current encoder state. | |
void | set_truncation_length (const int length) |
Set memory truncation length. Must be at least K. | |
int | get_truncation_length (void) const |
Get memory truncation length. | |
void | distance_profile (ivec &dist_prof, int dmax=100000, bool reverse=false) |
Calculate distance profile. If reverse = true calculate for the reverse code instead. | |
int | fast (Array< ivec > &spectrum, const int dfree, const int no_terms, const int Cdfree=1000000, const bool test_catastrophic=false) |
Cederwall's fast algorithm. | |
void | encode_bit (const bin &input, bvec &output) |
Encode a binary bit starting from the internal encoder state. | |
bvec | encode_bit (const bin &input) |
Encode a binary bit starting from the internal encoder state. | |
Protected Member Functions | |
int | weight (const int state, const int input, int time) |
The weight of path from state with input (0 or 1) at transition time . | |
void | weight (const int state, int &w0, int &w1, int time) |
The weight of the two paths (input 0 or 1) from given state. | |
int | weight_reverse (const int state, const int input, int time) |
Weight of the reverse code from state with input (0 or 1) at transition time . | |
void | weight_reverse (const int state, int &w0, int &w1, int time) |
The weight of the reverse code of two paths (input 0 or 1) from given state. | |
int | next_state (const int instate, const int input) |
Next state from instate given the input. | |
int | previous_state (const int state, const int input) |
The previous state from state given the input. | |
void | previous_state (const int state, int &S0, int &S1) |
The previous state from state given the input. | |
int | weight (const int state, const int input) |
The weight of the transition from given state with the input given. | |
void | weight (const int state, int &w0, int &w1) |
The weight of the two paths (input 0 or 1) from given state. | |
int | weight_reverse (const int state, const int input) |
The weight (of the reverse code) of the transition from given state with the input given. | |
void | weight_reverse (const int state, int &w0, int &w1) |
The weight (of the reverse code) of the two paths (input 0 or 1) from given state. | |
bvec | output_reverse (const int state, const int input) |
Output on transition (backwards) with input from state. | |
void | output_reverse (const int state, bvec &zero_output, bvec &one_output) |
Output on transition (backwards) with input from state. | |
void | output_reverse (const int state, int &zero_output, int &one_output) |
Output on transition (backwards) with input from state. | |
void | calc_metric_reverse (const int state, const vec &rx_codeword, double &zero_metric, double &one_metric) |
Calculate delta metrics for 0 and 1 input branches reaching state. | |
void | calc_metric (const vec &rx_codeword, vec &delta_metrics) |
Calculate delta metrics for all possible codewords. | |
int | get_input (const int state) |
Returns the input that results in state, that is the MSB of state. | |
Protected Attributes | |
int | Period |
The puncture period (i.e. the number of columns in the puncture matrix) | |
int | total |
The number of "1" in the puncture matrix. | |
bmat | puncture_matrix |
The puncture matrix (n rows and Period columns) | |
int | n |
Number of generators. | |
int | K |
Constraint length. | |
int | m |
Memory of the encoder. | |
int | no_states |
Number of states. | |
ivec | gen_pol |
Generator polynomials. | |
ivec | gen_pol_rev |
Generator polynomials for the reverse code. | |
int | encoder_state |
The current encoder state. | |
int | start_state |
The encoder start state. | |
int | trunc_length |
The decoder truncation length. | |
double | rate |
The rate of the code. | |
bvec | xor_int_table |
Auxilary table used by the codec. | |
imat | output_reverse_int |
output in int format for a given state and input | |
CONVOLUTIONAL_CODE_METHOD | cc_method |
encoding and decoding method | |
imat | path_memory |
Path memory (trellis) | |
Array< bool > | visited_state |
Visited states. | |
vec | sum_metric |
Metrics accumulator. | |
int | trunc_ptr |
Truncated path memory pointer. | |
int | trunc_state |
Truncated memory fill state. | |
Related Functions | |
(Note that these are not member functions.) | |
ITPP_EXPORT int | reverse_int (int length, int in) |
Reverses the bitrepresentation of in (of size length) and converts to an integer. | |
ITPP_EXPORT int | weight_int (int length, int in) |
Calculate the Hamming weight of the binary representation of in of size length. | |
ITPP_EXPORT int | compare_spectra (ivec v1, ivec v2) |
Compare two distance spectra. Return 1 if v1 is less, 0 if v2 less, and -1 if equal. | |
ITPP_EXPORT int | compare_spectra (ivec v1, ivec v2, vec weight_profile) |
Compare two distance spectra using a weight profile. | |
Binary Punctured Convolutional Code Class.
The codes are given as feedforward encoders an given in the Proakis form. That is the binary generators (K-tuples) are converted to octal integers. Observe that the constraint length (K) is defined as the number of meomory cells plus one (as in Proakis). The puncture matrix should be of size n * Period, where Period is the puncturing period.
Encoding is performed with the encode
function. By default the encode_tail
function is called which automatically add a tail of K-1 zeros and also assume that the encoder starts in the zero state. Observe that decode_tail
is used for data encoded with encode_tail
, and decode_trunc assumes that the memory truncation length either is the default (5*K) or set using the set_truncation_length
function. Encoding and decoding method can be changed by calling the set_method() function.
Example of use: (rate 1/3 constraint length K=7 ODS code using BPSK over AWGN)
Definition at line 80 of file punct_convcode.h.
|
inline |
Set the code according to built-in tables.
The type_of_code can be either MFD or ODS for maximum free distance codes (according to Proakis) or Optimum Distance Spectrum Codes according to Frenger, Orten and Ottosson.
Definition at line 94 of file punct_convcode.h.
References itpp::Convolutional_Code::set_code().
void itpp::Punctured_Convolutional_Code::encode_tail | ( | const bvec & | input, |
bvec & | output | ||
) |
Encoding that begins and ends in the zero state.
Encode a binary vector of inputs starting from zero state and also adds a tail of K-1 zeros to force the encoder into the zero state. Well suited for packet transmission.
Definition at line 172 of file punct_convcode.cpp.
References itpp::Convolutional_Code::encode_tail(), itpp::Convolutional_Code::n, Period, and puncture_matrix.
Referenced by encode().
|
inline |
Encoding that begins and ends in the zero state.
Encode a binary vector of inputs starting from zero state and also adds a tail of K-1 zeros to force the encoder into the zero state. Well suited for packet transmission.
Definition at line 143 of file punct_convcode.h.
References encode_tail().
Referenced by encode_tail().
|
virtual |
Decode a block of encoded data where encode_tail has been used.
Thus is assumes a decoder start state of zero and that a tail of K-1 zeros has been added. No memory truncation.
Reimplemented from itpp::Convolutional_Code.
Definition at line 294 of file punct_convcode.cpp.
References itpp::Convolutional_Code::decode_tail(), it_warning, itpp::Convolutional_Code::n, Period, puncture_matrix, and total.
Referenced by decode().
|
inlinevirtual |
Decode a block of encoded data where encode_tail has been used.
Thus is assumes a decoder start state of zero and that a tail of K-1 zeros has been added. No memory truncation.
Reimplemented from itpp::Convolutional_Code.
Definition at line 179 of file punct_convcode.h.
References decode_tail().
Referenced by decode_tail().
void itpp::Punctured_Convolutional_Code::calculate_spectrum | ( | Array< ivec > & | spectrum, |
int | dmax, | ||
int | no_terms | ||
) |
Calculate spectrum.
Calculates both the weight spectrum (Ad) and the information weight spectrum (Cd) and returns it as ivec:s in the 0:th and 1:st component of spectrum, respectively. For a punctrued code the spectrum is a sum of the spectras of all starting positions. Suitable for calculating many terms in the spectra (uses an breadth first algorithm). It is assumed that the code is non-catastrophic or else it is a possibility for an eternal loop.
Observe that there is a risk that some of the integers are overflow if many terms are calculated in the spectrum.
Definition at line 734 of file punct_convcode.cpp.
References Period, itpp::Array< T >::set_size(), and itpp::spectrum().
void itpp::Punctured_Convolutional_Code::calculate_spectrum | ( | Array< ivec > & | spectrum, |
int | time, | ||
int | dmax, | ||
int | no_terms, | ||
int | block_length = 0 |
||
) |
Calculate spectrum. Suitable when calculating many terms in the spectra. Breadth first search.
Use this function to evaluate the spectum whith a speccific puncturing period, or to calculate the spectrum for block transmission. To calculate spectra for block transmission:
Definition at line 750 of file punct_convcode.cpp.
References itpp::elem_mult(), itpp::Convolutional_Code::K, itpp::Convolutional_Code::m, itpp::Convolutional_Code::next_state(), Period, itpp::Array< T >::set_size(), itpp::spectrum(), and weight().
int itpp::Punctured_Convolutional_Code::fast | ( | Array< ivec > & | spectrum, |
int | time, | ||
int | dfree, | ||
int | no_terms, | ||
int | d_best_so_far = 0 , |
||
bool | test_catastrophic = false |
||
) |
Cederwall's fast algorithm.
true
), and returns 1 if everything went right. calc_spectrum
instead. Observe that there is a risk that some of the integers are overflow if many terms are calculated in the spectrum.
Definition at line 589 of file punct_convcode.cpp.
References distance_profile(), itpp::Convolutional_Code::K, itpp::Convolutional_Code::m, itpp::Convolutional_Code::next_state(), Period, itpp::reverse(), itpp::Array< T >::set_size(), itpp::spectrum(), weight(), and weight_reverse().
|
inherited |
Encode a binary bit starting from the internal encoder state.
To initialize the encoder state use set_start_state() and init_encoder()
Definition at line 719 of file convcode.cpp.
References itpp::Convolutional_Code::encoder_state, itpp::Convolutional_Code::gen_pol, itpp::Convolutional_Code::m, itpp::Convolutional_Code::n, and itpp::Convolutional_Code::xor_int_table.
|
inlineinherited |
Encode a binary bit starting from the internal encoder state.
To initialize the encoder state use set_start_state() and init_encoder()
Definition at line 214 of file convcode.h.
|
inherited |
Cederwall's fast algorithm.
Calculates both the weight spectrum (Ad) and the information weight spectrum (Cd) and returns it as ivec:s in the 0:th and 1:st component of spectrum, respectively. The FAST algorithm is good for calculating only a few terms in the spectrum. If many terms are desired, use calc_spectrum instead. The algorithm returns -1 if the code tested is worse that the input dfree and Cdfree. It returns 0 if the code MAY be catastrophic (assuming that test_catastrophic is true), and returns 1 if everything went right.
dfree
the free distance of the code (or an upper bound) no_terms
including the dfree term that should be calculated Cdfree
is the best value of information weight spectrum found so farObserve that there is a risk that some of the integers are overflow if many terms are calculated in the spectrum.
See IT No. 6, pp. 1146-1159, Nov. 1989 for details.
Definition at line 1299 of file convcode.cpp.
References itpp::Convolutional_Code::distance_profile(), itpp::Convolutional_Code::K, itpp::Convolutional_Code::m, itpp::Convolutional_Code::next_state(), itpp::reverse(), itpp::Array< T >::set_size(), itpp::spectrum(), itpp::Convolutional_Code::weight(), and itpp::Convolutional_Code::weight_reverse().
|
related |
Compare two distance spectra using a weight profile.
Return 1 if v1 is less, 0 if v2 less, and -1 if equal.
Definition at line 1492 of file convcode.cpp.
Generated on Sat Jul 6 2013 10:54:33 for IT++ by Doxygen 1.8.2