Go to the documentation of this file.00001 #include <itpp/itcomm.h>
00002
00003 using namespace itpp;
00004
00005
00006 using std::cout;
00007 using std::endl;
00008
00009 int main()
00010 {
00011
00012
00013 int m, t, n, k, q, NumBits, NumCodeWords;
00014 double p;
00015 bvec uncoded_bits, coded_bits, received_bits, decoded_bits;
00016
00017
00018 NumCodeWords = 1000;
00019 p = 0.01;
00020 m = 3;
00021 t = 2;
00022
00023 cout << "Number of Reed-Solomon code-words to simulate: " << NumCodeWords << endl;
00024 cout << "BSC Error probability : " << p << endl;
00025 cout << "RS m: " << m << endl;
00026 cout << "RS t: " << t << endl;
00027
00028
00029 Reed_Solomon reed_solomon(m,t);
00030 BSC bsc(p);
00031 BERC berc;
00032
00033 RNG_randomize();
00034
00035
00036 n = round_i(pow(2.0,m)-1);
00037 k = round_i(pow(2.0,m))-1-2*t;
00038 q = round_i(pow(2.0,m));
00039
00040 cout << "Simulating an Reed-Solomon code with the following parameters:" << endl;
00041 cout << "n = " << n << endl;
00042 cout << "k = " << k << endl;
00043 cout << "q = " << q << endl;
00044
00045 NumBits = m * k * NumCodeWords;
00046 uncoded_bits = randb(NumBits);
00047 coded_bits = reed_solomon.encode(uncoded_bits);
00048 received_bits = bsc(coded_bits);
00049 decoded_bits = reed_solomon.decode(received_bits);
00050
00051 berc.count(uncoded_bits,decoded_bits);
00052 cout << "The bit error probability after decoding is " << berc.get_errorrate() << endl;
00053
00054
00055 return 0;
00056
00057 }