/usr/share/doc/libitpp-dev/html/convcode.html is in libitpp-doc 4.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Welcome to IT++!</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div style="width: 100%; height: 40px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<a href="http://itpp.sourceforge.net"><img src="itpp_logo.png" alt="IT++ Logo" style="float: left; border: 0;"></a>
</div>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="dirs.html"><span>Directories</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">Simulation of a convolutional encoder and decoder </div> </div>
</div>
<div class="contents">
<div class="textblock"><p>In this example we will show how to use the convolutional encoder/decoder class in it++. The Viterbi decoder uses the soft received values.</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include <<a class="code" href="itcomm_8h.html" title="Include file for the IT++ communications module.">itpp/itcomm.h</a>></span>
<span class="keyword">using namespace </span>itpp;
<span class="comment">//These lines are needed for use of cout and endl</span>
<span class="keyword">using</span> std::cout;
<span class="keyword">using</span> std::endl;
<span class="keywordtype">int</span> main()
{
<span class="comment">//Scalars</span>
<span class="keywordtype">int</span> constraint_length, MaxNrofErrors, Nobits, MaxIterations, p, i;
<span class="keywordtype">double</span> Ec, Eb;
<span class="comment">//Vectors</span>
ivec generators;
vec EbN0dB, EbN0, N0, ber, trans_symbols, rec_symbols;
bvec uncoded_bits, coded_bits, decoded_bits;
<span class="comment">//Classes</span>
<a class="code" href="classitpp_1_1BPSK.html" title="BPSK modulator with real symbols.">BPSK</a> bpsk;
<a class="code" href="classitpp_1_1BERC.html" title="Bit Error Rate Counter (BERC) Class.">BERC</a> berc;
<a class="code" href="classitpp_1_1Convolutional__Code.html" title="Binary Convolutional rate 1/n class.">Convolutional_Code</a> conv_code;
<a class="code" href="classitpp_1_1AWGN__Channel.html" title="Ordinary AWGN Channel for cvec or vec inputs and outputs.">AWGN_Channel</a> channel;
<span class="comment">/*</span>
<span class="comment"> Set up the convolutional encoder/decoder class:</span>
<span class="comment"> The generators are given in octal form by adding a zero in front of the numbers.</span>
<span class="comment"> In this example we will simulate a rate 1/3 code that is listed in J. G. Proakis,</span>
<span class="comment"> "Digital communications". The encoder has constraint length 7.</span>
<span class="comment"> */</span>
generators.set_size(3, <span class="keyword">false</span>);
generators(0) = 0133;
generators(1) = 0145;
generators(2) = 0175;
constraint_length = 7;
conv_code.<a class="code" href="classitpp_1_1Convolutional__Code.html#ab8ca18ab14b3b6a1e1a1132f0386c84f" title="Set generator polynomials. Given in Proakis integer form.">set_generator_polynomials</a>(generators, constraint_length);
<span class="comment">//Init: Calculate some simulation specific parameters:</span>
Ec = 1.0;
EbN0dB = <a class="code" href="group__specmat.html#gae5632baa525e231b015f3d45f3503cac" title="Linspace (works in the same way as the matlab version)">linspace</a>(-2, 6, 5);
EbN0 = <a class="code" href="group__logexpfunc.html#ga9a4a3d1188d2ec6a6815c237bd3ab2cc" title="Inverse of decibel of x.">inv_dB</a>(EbN0dB);
Eb = Ec / conv_code.<a class="code" href="classitpp_1_1Convolutional__Code.html#ae7e892230d677d7b64917cd6f8e7b823" title="Return rate of code (not including the rate-loss)">get_rate</a>();
N0 = Eb * <a class="code" href="group__logexpfunc.html#ga0c42d158b1f623f9b72c1ccde7e2fd09" title="Calculates x to the power of y (x^y)">pow</a>(EbN0, -1);
MaxNrofErrors = 100;
Nobits = 10000;
MaxIterations = 10;
ber.set_size(EbN0dB.length(), <span class="keyword">false</span>);
ber.clear();
<span class="comment">//Randomize the random number generators.</span>
<a class="code" href="group__randgen.html#gadf5dd6e879881b651896c213e6efd3ba" title="Set a random seed for the Global Random Number Generator.">RNG_randomize</a>();
<span class="keywordflow">for</span> (p = 0; p < EbN0dB.length(); p++) {
cout << <span class="stringliteral">"Now simulating point "</span> << p + 1 << <span class="stringliteral">" out of "</span> << EbN0dB.length() << endl;
berc.<a class="code" href="classitpp_1_1BERC.html#a3b575cfbe8dd194c2cd51a6aa52651e5" title="Clears the bit error counter.">clear</a>(); <span class="comment">//Clear the bit error rate counter.</span>
channel.<a class="code" href="classitpp_1_1AWGN__Channel.html#aedf43a1a192a6c474ef915c297e9fcbb" title="Set noise variance (for complex-valued channels the sum of real and imaginary parts)">set_noise</a>(N0(p) / 2.0); <span class="comment">//Set the noise value of the AWGN channel.</span>
<span class="keywordflow">for</span> (i = 0; i < MaxIterations; i++) {
uncoded_bits = <a class="code" href="group__randgen.html#ga5aa06887cf1fd3301b040987924068f0" title="Generates a random bit (equally likely 0s and 1s)">randb</a>(Nobits); <span class="comment">//The uncoded bits.</span>
coded_bits = conv_code.<a class="code" href="classitpp_1_1Convolutional__Code.html#af9d5354b5ea7f2a090a488b383e995ef" title="Encode an input binary vector using specified method (Tail by default)">encode</a>(uncoded_bits); <span class="comment">//The convolutional encoder function.</span>
bpsk.<a class="code" href="classitpp_1_1BPSK.html#aff002bcb92f62a0f01e76ce1b0ab543e" title="Modulate bits into BPSK symbols in complex domain.">modulate_bits</a>(coded_bits, trans_symbols); <span class="comment">//The BPSK modulator.</span>
rec_symbols = channel(trans_symbols); <span class="comment">//The AWGN channel.</span>
decoded_bits = conv_code.<a class="code" href="classitpp_1_1Convolutional__Code.html#af3bf2206a471342563a4080e42d6b435" title="Decode a bvec of coded data.">decode</a>(rec_symbols); <span class="comment">//The Viterbi decoder function.</span>
berc.<a class="code" href="classitpp_1_1BERC.html#a539b0c989badff3027d97e4693fc9cd7" title="Cumulative error counter.">count</a>(uncoded_bits, decoded_bits); <span class="comment">//Count the errors.</span>
ber(p) = berc.<a class="code" href="classitpp_1_1BERC.html#af17d5f534ba34558d3632a98f29f0519" title="Returns the estimated bit error rate.">get_errorrate</a>();
<span class="comment">//Break the simulation on this point if sufficient number of bit errors were observed:</span>
<span class="keywordflow">if</span> (berc.<a class="code" href="classitpp_1_1BERC.html#a02e757f28e87003404ad0d4aec1e44a6" title="Returns the counted number of bit errors.">get_errors</a>() > MaxNrofErrors) {
cout << <span class="stringliteral">"Breaking on point "</span> << p + 1 << <span class="stringliteral">" with "</span> << berc.<a class="code" href="classitpp_1_1BERC.html#a02e757f28e87003404ad0d4aec1e44a6" title="Returns the counted number of bit errors.">get_errors</a>() << <span class="stringliteral">" errors."</span> << endl;
<span class="keywordflow">break</span>;
}
}
}
<span class="comment">//Print the results:</span>
cout << <span class="stringliteral">"BER = "</span> << ber << endl;
cout << <span class="stringliteral">"EbN0dB = "</span> << EbN0dB << endl;
<span class="comment">//Exit program:</span>
<span class="keywordflow">return</span> 0;
}
</pre></div><p>When you run this program, the output will look something like this:</p>
<div class="fragment"><pre class="fragment">Now simulating point 1 out of 5
Breaking on point 1 with 3297 errors.
Now simulating point 2 out of 5
Breaking on point 2 with 781 errors.
Now simulating point 3 out of 5
Breaking on point 3 with 112 errors.
Now simulating point 4 out of 5
Now simulating point 5 out of 5
BER = [0.330858 0.0783743 0.00280983 0 0]
EbN0dB = [-2 0 2 4 6]
</pre></div> </div></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div style="clear: both; width: 100%; height: 31px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=37044&type=1" alt="SourceForge Logo" style="float: right; border: 0;"></a>
<p style="padding-left: 10px; font-size: 85%;">Generated on Wed Jul 27 2011 16:27:06 for IT++ by <a href="http://www.doxygen.org/index.html">Doxygen</a> 1.7.4</p>
</div>
</body>
</html>
|