Interleaving and de-interleaving of data

This example shows how to use one of the interleaving classes.

#include <itpp/itcomm.h>
using namespace itpp;
//These lines are needed for use of cout and endl
using std::cout;
using std::endl;
int main()
{
//Declare scalars and vectors:
int rows, cols;
ivec input, output, deinterleaved;
//Declare the interleaver. The interleaver classes are templated, and therefore we must specify
//the type of the data elements. In this example we are using integers:
Block_Interleaver<int> my_interleaver;
//Initialize the interleaver class. Note that this can be done already in the declaration by writing
//Block_Interleaver<int> my_interleaver(rows,cols);
rows = 4;
cols = 5;
my_interleaver.set_rows(rows);
my_interleaver.set_cols(cols);
//Define the input to the interleaver:
input = "1:20";
//Do the interleaving:
output = my_interleaver.interleave(input);
//Do the de-interleaving:
deinterleaved = my_interleaver.deinterleave(output);
//Print the results:
cout << "input = " << input << endl;
cout << "output = " << output << endl;
cout << "deinterleaved = " << deinterleaved << endl;
//Exit program:
return 0;
}

When you run this program, the output will look like this:

input = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
output = [1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20]
deinterleaved = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
itpp
itpp namespace
Definition: itmex.h:36
itpp::Block_Interleaver::interleave
Vec< T > interleave(const Vec< T > &input)
Function for block interleaving. May add some zeros.
Definition: interleave.h:246
itpp::Block_Interleaver::set_rows
void set_rows(int in_rows)
Set the number of rows for block interleaving.
Definition: interleave.h:77
itpp::Block_Interleaver::deinterleave
Vec< T > deinterleave(const Vec< T > &input, short keepzeros=0)
Function for block deinterleaving. Removes additional zeros if keepzeros = 0.
Definition: interleave.h:296
itpp::Block_Interleaver::set_cols
void set_cols(int in_cols)
Set the number of columns for block interleaving.
Definition: interleave.h:79
itcomm.h
Include file for the IT++ communications module.
itpp::Block_Interleaver
Block Interleaver Class.
Definition: interleave.h:61

Generated on Mon Mar 23 2020 06:18:03 for IT++ by Doxygen 1.8.17