Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SPUC::Punctured_Convolutional_Code Class Reference
[Forward Error Correcting Codes]

Binary Punctured Convolutional Code Class. More...

#include <punct_convcode.h>

Inheritance diagram for SPUC::Punctured_Convolutional_Code:

Inheritance graph
[legend]
Collaboration diagram for SPUC::Punctured_Convolutional_Code:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Punctured_Convolutional_Code (void)
 Constructor.
virtual ~Punctured_Convolutional_Code (void)
 Destructor.
void set_code (string 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 (void)
 Get generator polynomials.
double get_rate (void)
 Return rate of code.
void set_puncture_matrix (const bmat &pmatrix)
 Set puncture matrix (size n*Period).
bmat get_puncture_matrix (void)
 Get puncture matrix.
int get_puncture_period (void)
 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 starting from state set by the set_state function.
bvec encode (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 decode (const vec &received_signal, bvec &output)
 Viterbi decoding using truncation of memory (default = 5*K).
bvec decode (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.
bool inverse_tail (const bvec coded_sequence, bvec &input)
 Calculate the inverse sequence.
bool catastrophic (void)
 Check if the code is catastrophic. Returns true if catastrophic.
void distance_profile (llvec &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< llvec > &spectrum, int dmax, int no_terms)
 Calculate spectrum.
void calculate_spectrum (Array< llvec > &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< llvec > &spectrum, int time, int dfree, int no_terms, int d_best_so_far=0, 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.

Protected Attributes

int Period
 The puncture period (i.e. the number of columns in the puncture matrix).
bmat puncture_matrix
 The puncture matrix (n rows and Period columns).

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. Also available is the encode_tail function 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 assumes that the memory truncation length either is the default (5*K) or set using the set_truncation_length 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);


Constructor & Destructor Documentation

SPUC::Punctured_Convolutional_Code::Punctured_Convolutional_Code void   )  [inline]
 

Constructor.

virtual SPUC::Punctured_Convolutional_Code::~Punctured_Convolutional_Code void   )  [inline, virtual]
 

Destructor.


Member Function Documentation

void Punctured_Convolutional_Code::calculate_spectrum Array< llvec > &  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.

void Punctured_Convolutional_Code::calculate_spectrum Array< llvec > &  spectrum,
int  dmax,
int  no_terms
 

Calculate spectrum.

Calculates both the weight spectrum (Ad) and the information weight spectrum (Cd) and returns it as llvec: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

Reimplemented from SPUC::Convolutional_Code.

bool Punctured_Convolutional_Code::catastrophic void   ) 
 

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

Reimplemented from SPUC::Convolutional_Code.

bvec SPUC::Punctured_Convolutional_Code::decode const vec &  received_signal  )  [inline]
 

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

Reimplemented from SPUC::Convolutional_Code.

Here is the call graph for this function:

void Punctured_Convolutional_Code::decode const vec &  received_signal,
bvec &  output
 

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

Reimplemented from SPUC::Convolutional_Code.

bvec SPUC::Punctured_Convolutional_Code::decode_tail const vec &  received_signal  )  [inline]
 

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 SPUC::Convolutional_Code.

Here is the call graph for this function:

void Punctured_Convolutional_Code::decode_tail const vec &  received_signal,
bvec &  output
 

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 SPUC::Convolutional_Code.

void Punctured_Convolutional_Code::distance_profile llvec &  dist_prof,
int  time,
int  dmax = 100000,
bool  reverse = false
 

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

bvec SPUC::Punctured_Convolutional_Code::encode const bvec &  input  )  [inline]
 

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

Reimplemented from SPUC::Convolutional_Code.

Here is the call graph for this function:

void Punctured_Convolutional_Code::encode const bvec &  input,
bvec &  output
 

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

Reimplemented from SPUC::Convolutional_Code.

bvec SPUC::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.

Reimplemented from SPUC::Convolutional_Code.

Here is the call graph for this function:

void 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.

Reimplemented from SPUC::Convolutional_Code.

int Punctured_Convolutional_Code::fast Array< llvec > &  spectrum,
int  time,
int  dfree,
int  no_terms,
int  d_best_so_far = 0,
bool  test_catastrophic = false
 

Cederwall's fast algorithm.

  • See IT 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 llvec: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.

ivec SPUC::Punctured_Convolutional_Code::get_generator_polynomials void   )  [inline]
 

Get generator polynomials.

Reimplemented from SPUC::Convolutional_Code.

bmat SPUC::Punctured_Convolutional_Code::get_puncture_matrix void   )  [inline]
 

Get puncture matrix.

int SPUC::Punctured_Convolutional_Code::get_puncture_period void   )  [inline]
 

Get puncturing period.

double SPUC::Punctured_Convolutional_Code::get_rate void   )  [inline]
 

Return rate of code.

Reimplemented from SPUC::Convolutional_Code.

void SPUC::Punctured_Convolutional_Code::init_encoder  )  [inline]
 

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

Reimplemented from SPUC::Convolutional_Code.

bool Punctured_Convolutional_Code::inverse_tail const bvec  coded_sequence,
bvec &  input
 

Calculate the inverse sequence.

Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence (not a valid codeword). Do not check that the tail forces the encoder into the zeroth state.

Reimplemented from SPUC::Convolutional_Code.

void SPUC::Punctured_Convolutional_Code::set_code string  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 accoring to Frenger, Orten and Ottosson.

Reimplemented from SPUC::Convolutional_Code.

Here is the call graph for this function:

void SPUC::Punctured_Convolutional_Code::set_generator_polynomials const ivec &  gen,
int  constraint_length
[inline]
 

Set generator polynomials. Given in Proakis integer form.

Reimplemented from SPUC::Convolutional_Code.

Here is the call graph for this function:

void Punctured_Convolutional_Code::set_puncture_matrix const bmat &  pmatrix  ) 
 

Set puncture matrix (size n*Period).

void 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.

int 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.

void 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.

int 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.


Member Data Documentation

int SPUC::Punctured_Convolutional_Code::Period [protected]
 

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

bmat SPUC::Punctured_Convolutional_Code::puncture_matrix [protected]
 

The puncture matrix (n rows and Period columns).


The documentation for this class was generated from the following files:
Generated on Fri Sep 16 11:07:59 2005 for spuc by  doxygen 1.4.4