itpp::Punctured_Convolutional_Code Class Reference
Communications Module » Forward Error Correcting Codes

Binary Punctured Convolutional Code Class. More...

`#include <itpp/comm/punct_convcode.h>`

Inheritance diagram for itpp::Punctured_Convolutional_Code:

## 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 | encode_bit (const bin &input, bvec &output)
| Encode a binary bit starting from the internal encoder state.
bvec | encode_bit (const bin &input)
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.

## 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 Symbols

(Note that these are not member symbols.)
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.

## Detailed Description

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)

BPSK bpsk;
Punctured_Convolutional_Code code;
ivec generator(3);
generator(0)=0133;
generator(1)=0165;
generator(2)=0171;
code.set_generator_polynomials(generator, 7);
bmat puncture_matrix = "1 1;0 1";
code.set_puncture_matrix(puncture_matrix);
code.set_truncation_length(30);
bvec bits=randb(100), encoded_bits, decoded_bits;
vec tx_signal, rx_signal;
code.encode(bits, encoded_bits);
tx_signal = bpsk.modulate_bits(encoded_bits);
rx_signal = tx_signal + sqrt(0.5)*randn(tx_signal.size());
code.decode(rx_signal, decoded_bits);
itpp::BPSK
BPSK modulator with real symbols.
Definition modulator.h:877
itpp::BPSK::modulate_bits
void modulate_bits(const bvec &bits, vec &output) const
Modulate bits into BPSK symbols in complex domain.
Definition modulator.cpp:310
itpp::Convolutional_Code::set_truncation_length
void set_truncation_length(const int length)
Set memory truncation length. Must be at least K.
Definition convcode.h:300
itpp::Punctured_Convolutional_Code::set_generator_polynomials
void set_generator_polynomials(const ivec &gen, int constraint_length)
Set generator polynomials. Given in Proakis integer form.
Definition punct_convcode.h:97
itpp::Punctured_Convolutional_Code::encode
void encode(const bvec &input, bvec &output)
Encode a binary vector of inputs using specified method.
Definition punct_convcode.cpp:136
itpp::Punctured_Convolutional_Code::puncture_matrix
bmat puncture_matrix
The puncture matrix (n rows and Period columns).
Definition punct_convcode.h:264
itpp::Punctured_Convolutional_Code::Punctured_Convolutional_Code
Punctured_Convolutional_Code(void)
Constructor.
Definition punct_convcode.h:84
itpp::Punctured_Convolutional_Code::decode
virtual void decode(const vec &received_signal, bvec &output)
Viterbi decoding using specified method.
Definition punct_convcode.cpp:224
itpp::Punctured_Convolutional_Code::set_puncture_matrix
void set_puncture_matrix(const bmat &pmatrix)
Set puncture matrix (size n*Period).
Definition punct_convcode.cpp:120
itpp::sqrt
vec sqrt(const vec &x)
Square root of the elements.
Definition elem_math.h:123
itpp::randb
bin randb(void)
Generates a random bit (equally likely 0s and 1s).
Definition random.h:793
itpp::randn
double randn(void)
Generates a random Gaussian (0,1) variable.
Definition random.h:831
bmat
Mat< bin > bmat
bin matrix
Definition mat.h:508

Definition at line 80 of file punct_convcode.h.

## Constructor & Destructor Documentation

## Punctured_Convolutional_Code()

itpp::Punctured_Convolutional_Code::Punctured_Convolutional_Code | ( | void |  | ) |

inline

Constructor.

Definition at line 84 of file punct_convcode.h.

References itpp::Convolutional_Code::Convolutional_Code().

## ~Punctured_Convolutional_Code()

virtual itpp::Punctured_Convolutional_Code::~Punctured_Convolutional_Code | ( | void |  | ) |

inline virtual

Destructor.

Definition at line 86 of file punct_convcode.h.

## Member Function Documentation

## set_code()

void itpp::Punctured_Convolutional_Code::set_code | ( | const CONVOLUTIONAL_CODE_TYPE | type_of_code,
|  | int | inverse_rate,
|  | int | constraint_length )

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().

## set_generator_polynomials()

void itpp::Punctured_Convolutional_Code::set_generator_polynomials | ( | const ivec & | gen,
|  | int | constraint_length )

inline

Set generator polynomials. Given in Proakis integer form.

Definition at line 97 of file punct_convcode.h.

References itpp::Convolutional_Code::set_generator_polynomials().

## get_generator_polynomials()

ivec itpp::Punctured_Convolutional_Code::get_generator_polynomials | ( | void |  | ) | const

inline

Get generator polynomials.

Definition at line 100 of file punct_convcode.h.

References itpp::Convolutional_Code::gen_pol.

## get_rate()

virtual double itpp::Punctured_Convolutional_Code::get_rate | ( | void |  | ) | const

inline virtual

Return rate of code.

Reimplemented from itpp::Convolutional_Code.

Definition at line 103 of file punct_convcode.h.

References itpp::Convolutional_Code::rate.

## set_method()

void itpp::Punctured_Convolutional_Code::set_method | ( | const CONVOLUTIONAL_CODE_METHOD | method | ) |

inline

Set encoding and decoding method (Trunc, Tail, or Tailbite).

Definition at line 106 of file punct_convcode.h.

References itpp::Convolutional_Code::set_method().

## set_puncture_matrix()

void itpp::Punctured_Convolutional_Code::set_puncture_matrix | ( | const bmat & | pmatrix | ) |

Set puncture matrix (size n*Period).

Definition at line 120 of file punct_convcode.cpp.

References it_error_if, itpp::Convolutional_Code::n, Period, puncture_matrix, itpp::Convolutional_Code::rate, and total.

## get_puncture_matrix()

bmat itpp::Punctured_Convolutional_Code::get_puncture_matrix | ( |  | ) | const

inline

Get puncture matrix.

Definition at line 111 of file punct_convcode.h.

References puncture_matrix.

## get_puncture_period()

int itpp::Punctured_Convolutional_Code::get_puncture_period | ( |  | ) | const

inline

Get puncturing period.

Definition at line 113 of file punct_convcode.h.

References Period.

## init_encoder()

void itpp::Punctured_Convolutional_Code::init_encoder | ( |  | ) |

inline

Set the encoder internal state in start_state (set by set_start_state()).

Definition at line 116 of file punct_convcode.h.

References itpp::Convolutional_Code::encoder_state, and itpp::Convolutional_Code::start_state.

## encode() [1/2]

void itpp::Punctured_Convolutional_Code::encode | ( | const bvec & | input,
|  | bvec & | output )

virtual

Encode a binary vector of inputs using specified method.

Reimplemented from itpp::Convolutional_Code.

Definition at line 136 of file punct_convcode.cpp.

References itpp::Convolutional_Code::cc_method, encode_tail(), encode_tailbite(), and encode_trunc().

## encode() [2/2]

bvec itpp::Punctured_Convolutional_Code::encode | ( | const bvec & | input | ) |

inline virtual

Encode a binary vector of inputs using specified method.

Reimplemented from itpp::Convolutional_Code.

Definition at line 121 of file punct_convcode.h.

References encode().

Referenced by encode().

## encode_trunc() [1/2]

void itpp::Punctured_Convolutional_Code::encode_trunc | ( | const bvec & | input,
|  | bvec & | output )

Encode a binary vector of inputs starting from state set by the set_state function.

Definition at line 154 of file punct_convcode.cpp.

References itpp::Convolutional_Code::encode_trunc(), itpp::Convolutional_Code::n, Period, and puncture_matrix.

Referenced by encode().

## encode_trunc() [2/2]

bvec itpp::Punctured_Convolutional_Code::encode_trunc | ( | const bvec & | input | ) |

inline

Encode a binary vector of inputs starting from state set by the set_state function.

Definition at line 126 of file punct_convcode.h.

References encode_trunc().

Referenced by encode_trunc().

## encode_tail() [1/2]

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().

## encode_tail() [2/2]

bvec itpp::Punctured_Convolutional_Code::encode_tail | ( | const bvec & | input | ) |

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().

## encode_tailbite() [1/2]

void itpp::Punctured_Convolutional_Code::encode_tailbite | ( | const bvec & | input,
|  | bvec & | output )

Encode a binary vector of inputs using tailbiting.

Definition at line 190 of file punct_convcode.cpp.

References itpp::Convolutional_Code::encode_tailbite(), itpp::Convolutional_Code::n, Period, and puncture_matrix.

Referenced by encode(), and encode_tailbite().

## encode_tailbite() [2/2]

bvec itpp::Punctured_Convolutional_Code::encode_tailbite | ( | const bvec & | input | ) |

inline

Encode a binary vector of inputs using tailbiting.

Definition at line 148 of file punct_convcode.h.

References encode_tailbite().

## decode() [1/4]

void itpp::Punctured_Convolutional_Code::decode | ( | const vec & | received_signal,
|  | bvec & | output )

virtual

Viterbi decoding using specified method.

Reimplemented from itpp::Convolutional_Code.

Definition at line 224 of file punct_convcode.cpp.

References itpp::Convolutional_Code::cc_method, decode_tail(), decode_tailbite(), and decode_trunc().

## decode() [2/4]

virtual bvec itpp::Punctured_Convolutional_Code::decode | ( | const vec & | received_signal | ) |

inline virtual

Viterbi decoding using specified method.

Reimplemented from itpp::Convolutional_Code.

Definition at line 155 of file punct_convcode.h.

References decode().

Referenced by decode().

## decode() [3/4]

void itpp::Punctured_Convolutional_Code::decode | ( | const bvec & | codedbits,
|  | bvec & | decoded_bits )

virtual

Decode a bvec of coded data.

Reimplemented from itpp::Convolutional_Code.

Definition at line 210 of file punct_convcode.cpp.

References it_error.

## decode() [4/4]

bvec itpp::Punctured_Convolutional_Code::decode | ( | const bvec & | coded_bits | ) |

virtual

Decode a bvec of coded data.

Reimplemented from itpp::Convolutional_Code.

Definition at line 215 of file punct_convcode.cpp.

References it_error.

## decode_trunc() [1/2]

void itpp::Punctured_Convolutional_Code::decode_trunc | ( | const vec & | received_signal,
|  | bvec & | output )

virtual

Viterbi decoding using truncation of memory (default = 5*K).

Reimplemented from itpp::Convolutional_Code.

Definition at line 244 of file punct_convcode.cpp.

References itpp::Convolutional_Code::decode_trunc(), it_warning, itpp::Convolutional_Code::n, Period, puncture_matrix, and total.

Referenced by decode().

## decode_trunc() [2/2]

bvec itpp::Punctured_Convolutional_Code::decode_trunc | ( | const vec & | received_signal | ) |

inline virtual

Viterbi decoding using truncation of memory (default = 5*K).

Reimplemented from itpp::Convolutional_Code.

Definition at line 164 of file punct_convcode.h.

References decode_trunc().

Referenced by decode_trunc().

## decode_tail() [1/2]

void itpp::Punctured_Convolutional_Code::decode_tail | ( | const vec & | received_signal,
|  | bvec & | output )

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().

## decode_tail() [2/2]

bvec itpp::Punctured_Convolutional_Code::decode_tail | ( | const vec & | received_signal | ) |

inline 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 179 of file punct_convcode.h.

References decode_tail().

Referenced by decode_tail().

## decode_tailbite() [1/2]

void itpp::Punctured_Convolutional_Code::decode_tailbite | ( | const vec & | received_signal,
|  | bvec & | output )

virtual

Decode a block of encoded data where encode_tailbite has been used. Tries all start states.

Reimplemented from itpp::Convolutional_Code.

Definition at line 345 of file punct_convcode.cpp.

References itpp::Convolutional_Code::decode_tailbite(), it_warning, itpp::Convolutional_Code::n, Period, puncture_matrix, and total.

Referenced by decode(), and decode_tailbite().

## decode_tailbite() [2/2]

bvec itpp::Punctured_Convolutional_Code::decode_tailbite | ( | const vec & | received_signal | ) |

inline virtual

Decode a block of encoded data where encode_tailbite has been used. Tries all start states.

Reimplemented from itpp::Convolutional_Code.

Definition at line 184 of file punct_convcode.h.

References decode_tailbite().

## inverse_tail()

bool itpp::Punctured_Convolutional_Code::inverse_tail | ( | const bvec | coded_sequence,
|  | bvec & | input )

Definition at line 404 of file punct_convcode.cpp.

## catastrophic()

bool itpp::Punctured_Convolutional_Code::catastrophic | ( | void |  | ) |

Check if the code is catastrophic. Returns true if catastrophic.

Definition at line 455 of file punct_convcode.cpp.

References itpp::Convolutional_Code::m, itpp::Convolutional_Code::next_state(), Period, and weight().

## distance_profile() [1/2]

void itpp::Punctured_Convolutional_Code::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.

Definition at line 516 of file punct_convcode.cpp.

References itpp::Convolutional_Code::m, itpp::Convolutional_Code::next_state(), Period, itpp::reverse(), weight(), and weight_reverse().

Referenced by fast().

## calculate_spectrum() [1/2]

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.

- dmax = an upper bound on the free distance
- no_terms = number of terms including the dmax term that should be calculated

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 calculate_spectrum(), Period, and itpp::spectrum().

Referenced by calculate_spectrum().

## calculate_spectrum() [2/2]

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:

- Use time = 0 if the puncturing is restarted at each block.
- Use block_length = 0 (default value) for infinite blocks.

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::spectrum(), and weight().

## fast() [1/2]

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.

- See IEEE Trans. Information Theory No. 6, pp. 1146-1159, Nov. 1989 for details.
- 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 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 = Number of terms including the dfree term that should be calculated.
- d_best_so_far = the best value of the free distance found so far.
- The FAST algorithm is good for calculating only a few terms in the spectrum. If many terms are desired, use `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::spectrum(), weight(), and weight_reverse().

## weight() [1/4]

int itpp::Punctured_Convolutional_Code::weight | ( | const int | state,
|  | const int | input,
|  | int | time )

protected

The weight of path from `state` with `input` (0 or 1) at transition `time`.

Definition at line 38 of file punct_convcode.cpp.

References itpp::Convolutional_Code::gen_pol, itpp::Convolutional_Code::K, itpp::Convolutional_Code::m, itpp::Convolutional_Code::n, and puncture_matrix.

Referenced by calculate_spectrum(), catastrophic(), distance_profile(), and fast().

## weight() [2/4]

void itpp::Punctured_Convolutional_Code::weight | ( | const int | state,
|  | int & | w0,
|  | int & | w1,
|  | int | time )

protected

The weight of the two paths (input 0 or 1) from given state.

Definition at line 76 of file punct_convcode.cpp.

References itpp::Convolutional_Code::gen_pol, itpp::Convolutional_Code::m, itpp::Convolutional_Code::n, and puncture_matrix.

## weight_reverse() [1/4]

int itpp::Punctured_Convolutional_Code::weight_reverse | ( | const int | state,
|  | const int | input,
|  | int | time )

protected

Weight of the reverse code from `state` with `input` (0 or 1) at transition `time`.

Definition at line 57 of file punct_convcode.cpp.

References itpp::Convolutional_Code::gen_pol_rev, itpp::Convolutional_Code::K, itpp::Convolutional_Code::m, itpp::Convolutional_Code::n, Period, and puncture_matrix.

Referenced by distance_profile(), and fast().

## weight_reverse() [2/4]

void itpp::Punctured_Convolutional_Code::weight_reverse | ( | const int | state,
|  | int & | w0,
|  | int & | w1,
|  | int | time )

protected

The weight of the reverse code of two paths (input 0 or 1) from given state.

Definition at line 97 of file punct_convcode.cpp.

References itpp::Convolutional_Code::gen_pol_rev, itpp::Convolutional_Code::m, itpp::Convolutional_Code::n, Period, and puncture_matrix.

## reset()

void itpp::Convolutional_Code::reset | ( |  | ) |

inherited

Reset encoder and decoder states.

Definition at line 605 of file convcode.cpp.

References init_encoder(), start_state, sum_metric, trunc_ptr, trunc_state, and visited_state.

## encode_bit() [1/2]

void itpp::Convolutional_Code::encode_bit | ( | const bin & | input,
|  | bvec & | output )

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 encoder_state, gen_pol, m, n, and xor_int_table.

## encode_bit() [2/2]

bvec itpp::Convolutional_Code::encode_bit | ( | const bin & | input | ) |

inline inherited

Definition at line 214 of file convcode.h.

## set_start_state()

void itpp::Convolutional_Code::set_start_state | ( | int | state | ) |

inline inherited

Set encoder default start state.

Definition at line 283 of file convcode.h.

References it_error_if, m, and start_state.

## get_encoder_state()

int itpp::Convolutional_Code::get_encoder_state | ( | void |  | ) | const

inline inherited

Get the current encoder state.

Definition at line 296 of file convcode.h.

References encoder_state.

## set_truncation_length()

void itpp::Convolutional_Code::set_truncation_length | ( | const int | length | ) |

inline inherited

Set memory truncation length. Must be at least K.

Definition at line 300 of file convcode.h.

References it_error_if, K, itpp::length(), and trunc_length.

## get_truncation_length()

int itpp::Convolutional_Code::get_truncation_length | ( | void |  | ) | const

inline inherited

Get memory truncation length.

Definition at line 307 of file convcode.h.

References trunc_length.

## distance_profile() [2/2]

void itpp::Convolutional_Code::distance_profile | ( | ivec & | dist_prof,
|  | int | dmax = 100000,
|  | bool | reverse = false )

inherited

Calculate distance profile. If reverse = true calculate for the reverse code instead.

Definition at line 1133 of file convcode.cpp.

References K, m, next_state(), itpp::reverse(), weight(), and weight_reverse().

Referenced by fast().

## fast() [2/2]

int itpp::Convolutional_Code::fast | ( | Array< ivec > & | spectrum,
|  | const int | dfree,
|  | const int | no_terms,
|  | const int | Cdfree = 1000000,
|  | const bool | test_catastrophic = false )

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 far

Observe 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 distance_profile(), K, m, next_state(), itpp::reverse(), itpp::spectrum(), weight(), and weight_reverse().

## next_state()

int itpp::Convolutional_Code::next_state | ( | const int | instate,
|  | const int | input )

inline protected inherited

Next state from instate given the input.

Definition at line 374 of file convcode.h.

References m.

Referenced by calculate_spectrum(), itpp::Punctured_Convolutional_Code::calculate_spectrum(), catastrophic(), itpp::Punctured_Convolutional_Code::catastrophic(), distance_profile(), itpp::Punctured_Convolutional_Code::distance_profile(), fast(), and itpp::Punctured_Convolutional_Code::fast().

## previous_state() [1/2]

int itpp::Convolutional_Code::previous_state | ( | const int | state,
|  | const int | input )

inline protected inherited

The previous state from state given the input.

Definition at line 378 of file convcode.h.

References m.

Referenced by decode_tail(), decode_tailbite(), and decode_trunc().

## previous_state() [2/2]

void itpp::Convolutional_Code::previous_state | ( | const int | state,
|  | int & | S0,
|  | int & | S1 )

inline protected inherited

The previous state from state given the input.

Definition at line 382 of file convcode.h.

References no_states.

## weight() [3/4]

int itpp::Convolutional_Code::weight | ( | const int | state,
|  | const int | input )

protected inherited

The weight of the transition from given state with the input given.

Definition at line 42 of file convcode.cpp.

References gen_pol, K, m, and n.

Referenced by calculate_spectrum(), catastrophic(), distance_profile(), and fast().

## weight() [4/4]

void itpp::Convolutional_Code::weight | ( | const int | state,
|  | int & | w0,
|  | int & | w1 )

protected inherited

The weight of the two paths (input 0 or 1) from given state.

Definition at line 85 of file convcode.cpp.

References gen_pol, m, and n.

## weight_reverse() [3/4]

int itpp::Convolutional_Code::weight_reverse | ( | const int | state,
|  | const int | input )

protected inherited

The weight (of the reverse code) of the transition from given state with the input given.

Definition at line 64 of file convcode.cpp.

References gen_pol_rev, K, m, and n.

Referenced by distance_profile(), and fast().

## weight_reverse() [4/4]

void itpp::Convolutional_Code::weight_reverse | ( | const int | state,
|  | int & | w0,
|  | int & | w1 )

protected inherited

The weight (of the reverse code) of the two paths (input 0 or 1) from given state.

Definition at line 109 of file convcode.cpp.

References gen_pol_rev, m, and n.

## output_reverse() [1/3]

bvec itpp::Convolutional_Code::output_reverse | ( | const int | state,
|  | const int | input )

protected inherited

Output on transition (backwards) with input from state.

Definition at line 132 of file convcode.cpp.

References gen_pol, n, and xor_int_table.

Referenced by set_generator_polynomials().

## output_reverse() [2/3]

void itpp::Convolutional_Code::output_reverse | ( | const int | state,
|  | bvec & | zero_output,
|  | bvec & | one_output )

protected inherited

Output on transition (backwards) with input from state.

Definition at line 150 of file convcode.cpp.

References gen_pol, n, and xor_int_table.

## output_reverse() [3/3]

void itpp::Convolutional_Code::output_reverse | ( | const int | state,
|  | int & | zero_output,
|  | int & | one_output )

protected inherited

Output on transition (backwards) with input from state.

Definition at line 169 of file convcode.cpp.

References gen_pol, n, and xor_int_table.

## calc_metric_reverse()

void itpp::Convolutional_Code::calc_metric_reverse | ( | const int | state,
|  | const vec & | rx_codeword,
|  | double & | zero_metric,
|  | double & | one_metric )

protected inherited

Calculate delta metrics for 0 and 1 input branches reaching state.

Definition at line 190 of file convcode.cpp.

References gen_pol, n, and xor_int_table.

## calc_metric()

void itpp::Convolutional_Code::calc_metric | ( | const vec & | rx_codeword,
|  | vec & | delta_metrics )

protected inherited

Calculate delta metrics for all possible codewords.

Definition at line 213 of file convcode.cpp.

References gen_pol, n, no_states, itpp::pow2i(), and xor_int_table.

Referenced by decode_tail(), decode_tailbite(), and decode_trunc().

## get_input()

int itpp::Convolutional_Code::get_input | ( | const int | state | ) |

inline protected inherited

Returns the input that results in state, that is the MSB of state.

Definition at line 408 of file convcode.h.

References m.

Referenced by decode_tail(), decode_tailbite(), and decode_trunc().

## Friends And Related Symbol Documentation

## reverse_int()

ITPP_EXPORT int reverse_int | ( | int | length,
|  | int | in )

related

Reverses the bitrepresentation of in (of size length) and converts to an integer.

Definition at line 1442 of file convcode.cpp.

References itpp::length().

Referenced by set_generator_polynomials().

## weight_int()

ITPP_EXPORT int weight_int | ( | int | length,
|  | int | in )

related

Calculate the Hamming weight of the binary representation of in of size length.

Definition at line 1460 of file convcode.cpp.

References itpp::length().

Referenced by set_generator_polynomials().

## compare_spectra() [1/2]

ITPP_EXPORT int compare_spectra | ( | ivec | v1,
|  | ivec | v2 )

related

Compare two distance spectra. Return 1 if v1 is less, 0 if v2 less, and -1 if equal.

Definition at line 1472 of file convcode.cpp.

References it_assert_debug.

## compare_spectra() [2/2]

ITPP_EXPORT int compare_spectra | ( | ivec | v1,
|  | ivec | v2,
|  | vec | weight_profile )

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.

## Member Data Documentation

## Period

int itpp::Punctured_Convolutional_Code::Period

protected

The puncture period (i.e. the number of columns in the puncture matrix).

Definition at line 260 of file punct_convcode.h.

Referenced by calculate_spectrum(), calculate_spectrum(), catastrophic(), decode_tail(), decode_tailbite(), decode_trunc(), distance_profile(), encode_tail(), encode_tailbite(), encode_trunc(), fast(), get_puncture_period(), set_puncture_matrix(), weight_reverse(), and weight_reverse().

## total

int itpp::Punctured_Convolutional_Code::total

protected

The number of "1" in the puncture matrix.

Definition at line 262 of file punct_convcode.h.

Referenced by decode_tail(), decode_tailbite(), decode_trunc(), and set_puncture_matrix().

## puncture_matrix

bmat itpp::Punctured_Convolutional_Code::puncture_matrix

protected

The puncture matrix (n rows and Period columns).

Definition at line 264 of file punct_convcode.h.

Referenced by decode_tail(), decode_tailbite(), decode_trunc(), encode_tail(), encode_tailbite(), encode_trunc(), get_puncture_matrix(), set_puncture_matrix(), weight(), weight(), weight_reverse(), and weight_reverse().

## n

int itpp::Convolutional_Code::n

protected inherited

Number of generators.

Definition at line 411 of file convcode.h.

Referenced by calc_metric(), calc_metric_reverse(), decode_tail(), itpp::Punctured_Convolutional_Code::decode_tail(), decode_tailbite(), itpp::Punctured_Convolutional_Code::decode_tailbite(), decode_trunc(), itpp::Punctured_Convolutional_Code::decode_trunc(), encode_bit(), encode_tail(), itpp::Punctured_Convolutional_Code::encode_tail(), encode_tailbite(), itpp::Punctured_Convolutional_Code::encode_tailbite(), encode_trunc(), itpp::Punctured_Convolutional_Code::encode_trunc(), inverse_tail(), output_reverse(), output_reverse(), output_reverse(), set_generator_polynomials(), itpp::Punctured_Convolutional_Code::set_puncture_matrix(), weight(), weight(), itpp::Punctured_Convolutional_Code::weight(), itpp::Punctured_Convolutional_Code::weight(), weight_reverse(), weight_reverse(), itpp::Punctured_Convolutional_Code::weight_reverse(), and itpp::Punctured_Convolutional_Code::weight_reverse().

## K

int itpp::Convolutional_Code::K

protected inherited

Constraint length.

Definition at line 413 of file convcode.h.

Referenced by itpp::Punctured_Convolutional_Code::calculate_spectrum(), Convolutional_Code(), distance_profile(), fast(), itpp::Punctured_Convolutional_Code::fast(), set_generator_polynomials(), set_truncation_length(), weight(), itpp::Punctured_Convolutional_Code::weight(), weight_reverse(), and itpp::Punctured_Convolutional_Code::weight_reverse().

## m

int itpp::Convolutional_Code::m

protected inherited

Memory of the encoder.

Definition at line 415 of file convcode.h.

Referenced by calculate_spectrum(), itpp::Punctured_Convolutional_Code::calculate_spectrum(), catastrophic(), itpp::Punctured_Convolutional_Code::catastrophic(), decode_tail(), distance_profile(), itpp::Punctured_Convolutional_Code::distance_profile(), encode_bit(), encode_tail(), encode_tailbite(), encode_trunc(), fast(), itpp::Punctured_Convolutional_Code::fast(), get_input(), inverse_tail(), next_state(), previous_state(), set_generator_polynomials(), set_start_state(), weight(), weight(), itpp::Punctured_Convolutional_Code::weight(), itpp::Punctured_Convolutional_Code::weight(), weight_reverse(), weight_reverse(), itpp::Punctured_Convolutional_Code::weight_reverse(), and itpp::Punctured_Convolutional_Code::weight_reverse().

## no_states

int itpp::Convolutional_Code::no_states

protected inherited

Number of states.

Definition at line 417 of file convcode.h.

Referenced by calc_metric(), calculate_spectrum(), catastrophic(), decode_tail(), decode_tailbite(), decode_trunc(), previous_state(), and set_generator_polynomials().

## gen_pol

ivec itpp::Convolutional_Code::gen_pol

protected inherited

Generator polynomials.

Definition at line 419 of file convcode.h.

Referenced by calc_metric(), calc_metric_reverse(), encode_bit(), encode_tail(), encode_tailbite(), encode_trunc(), get_generator_polynomials(), itpp::Punctured_Convolutional_Code::get_generator_polynomials(), inverse_tail(), output_reverse(), output_reverse(), output_reverse(), set_generator_polynomials(), weight(), weight(), itpp::Punctured_Convolutional_Code::weight(), and itpp::Punctured_Convolutional_Code::weight().

## gen_pol_rev

ivec itpp::Convolutional_Code::gen_pol_rev

protected inherited

Generator polynomials for the reverse code.

Definition at line 421 of file convcode.h.

Referenced by set_generator_polynomials(), weight_reverse(), weight_reverse(), itpp::Punctured_Convolutional_Code::weight_reverse(), and itpp::Punctured_Convolutional_Code::weight_reverse().

## encoder_state

int itpp::Convolutional_Code::encoder_state

protected inherited

The current encoder state.

Definition at line 423 of file convcode.h.

Referenced by encode_bit(), encode_tail(), encode_tailbite(), encode_trunc(), get_encoder_state(), init_encoder(), and itpp::Punctured_Convolutional_Code::init_encoder().

## start_state

int itpp::Convolutional_Code::start_state

protected inherited

The encoder start state.

Definition at line 425 of file convcode.h.

Referenced by Convolutional_Code(), init_encoder(), itpp::Punctured_Convolutional_Code::init_encoder(), reset(), set_generator_polynomials(), and set_start_state().

## trunc_length

int itpp::Convolutional_Code::trunc_length

protected inherited

The decoder truncation length.

Definition at line 427 of file convcode.h.

Referenced by decode_trunc(), get_truncation_length(), set_generator_polynomials(), and set_truncation_length().

## rate

double itpp::Convolutional_Code::rate

protected inherited

The rate of the code.

Definition at line 429 of file convcode.h.

Referenced by get_rate(), itpp::Punctured_Convolutional_Code::get_rate(), set_generator_polynomials(), and itpp::Punctured_Convolutional_Code::set_puncture_matrix().

## xor_int_table

bvec itpp::Convolutional_Code::xor_int_table

protected inherited

Auxilary table used by the codec.

Definition at line 431 of file convcode.h.

Referenced by calc_metric(), calc_metric_reverse(), encode_bit(), encode_tail(), encode_tailbite(), encode_trunc(), inverse_tail(), output_reverse(), output_reverse(), output_reverse(), and set_generator_polynomials().

## output_reverse_int

imat itpp::Convolutional_Code::output_reverse_int

protected inherited

output in int format for a given state and input

Definition at line 433 of file convcode.h.

Referenced by decode_tail(), decode_tailbite(), decode_trunc(), and set_generator_polynomials().

## cc_method

CONVOLUTIONAL_CODE_METHOD itpp::Convolutional_Code::cc_method

protected inherited

encoding and decoding method

Definition at line 435 of file convcode.h.

Referenced by Convolutional_Code(), decode(), itpp::Punctured_Convolutional_Code::decode(), encode(), itpp::Punctured_Convolutional_Code::encode(), and set_method().

## path_memory

imat itpp::Convolutional_Code::path_memory

protected inherited

Path memory (trellis).

Definition at line 437 of file convcode.h.

Referenced by decode_tail(), decode_tailbite(), and decode_trunc().

## visited_state

Array<bool> itpp::Convolutional_Code::visited_state

protected inherited

Visited states.

Definition at line 439 of file convcode.h.

Referenced by decode_tail(), decode_tailbite(), decode_trunc(), reset(), and set_generator_polynomials().

## sum_metric

vec itpp::Convolutional_Code::sum_metric

protected inherited

Metrics accumulator.

Definition at line 441 of file convcode.h.

Referenced by decode_tail(), decode_tailbite(), decode_trunc(), reset(), and set_generator_polynomials().

## trunc_ptr

int itpp::Convolutional_Code::trunc_ptr

protected inherited

Truncated path memory pointer.

Definition at line 443 of file convcode.h.

Referenced by decode_trunc(), reset(), and set_generator_polynomials().

## trunc_state

int itpp::Convolutional_Code::trunc_state

protected inherited

Truncated memory fill state.

Definition at line 445 of file convcode.h.

Referenced by decode_trunc(), reset(), and set_generator_polynomials().

The documentation for this class was generated from the following files:

- itpp/comm/punct_convcode.h
- itpp/comm/punct_convcode.cpp

Generated on for IT++ by Doxygen 1.15.0