blob: 5e487ad0adf242cae6c0292d27880da8e679effe [file] [log] [blame]
dburgess82c46ff2011-10-07 02:40:51 +00001/*
2* Copyright 2008 Free Software Foundation, Inc.
3*
4*
5* This software is distributed under the terms of the GNU Affero Public License.
6* See the COPYING file in the main directory for details.
7*
8* This use of this software may be subject to additional restrictions.
9* See the LEGAL file in the main directory for details.
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU Affero General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU Affero General Public License for more details.
20
21 You should have received a copy of the GNU Affero General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24*/
25
26
27
28
29#include "BitVector.h"
30#include <iostream>
31#include <cstdlib>
32
33using namespace std;
34
35
36int main(int argc, char *argv[])
37{
38 BitVector v1("0000111100111100101011110000");
39 cout << v1 << endl;
40 v1.LSB8MSB();
41 cout << v1 << endl;
42 ViterbiR2O4 vCoder;
43 BitVector v2(v1.size()*2);
44 v1.encode(vCoder,v2);
45 cout << v2 << endl;
46 SoftVector sv2(v2);
47 cout << sv2 << endl;
48 for (unsigned i=0; i<sv2.size()/4; i++) sv2[random()%sv2.size()]=0.5;
49 cout << sv2 << endl;
50 BitVector v3(v1.size());
51 sv2.decode(vCoder,v3);
52 cout << v3 << endl;
53
54 cout << v3.segment(3,4) << endl;
55
56 BitVector v4(v3.segment(0,4),v3.segment(8,4));
57 cout << v4 << endl;
58
59 BitVector v5("000011110000");
60 int r1 = v5.peekField(0,8);
61 int r2 = v5.peekField(4,4);
62 int r3 = v5.peekField(4,8);
63 cout << r1 << ' ' << r2 << ' ' << r3 << endl;
64 cout << v5 << endl;
65 v5.fillField(0,0xa,4);
66 int r4 = v5.peekField(0,8);
67 cout << v5 << endl;
68 cout << r4 << endl;
69
70 v5.reverse8();
71 cout << v5 << endl;
72
73 BitVector mC = "000000000000111100000000000001110000011100001101000011000000000000000111000011110000100100001010000010100000101000001010000010100000010000000000000000000000000000000000000000000000001100001111000000000000000000000000000000000000000000000000000010010000101000001010000010100000101000001010000001000000000000000000000000110000111100000000000001110000101000001100000001000000000000";
74 SoftVector mCS(mC);
75 BitVector mU(mC.size()/2);
76 mCS.decode(vCoder,mU);
77 cout << "c=" << mCS << endl;
78 cout << "u=" << mU << endl;
79
80
81 unsigned char ts[9] = "abcdefgh";
82 BitVector tp(70);
83 cout << "ts=" << ts << endl;
84 tp.unpack(ts);
85 cout << "tp=" << tp << endl;
86 tp.pack(ts);
87 cout << "ts=" << ts << endl;
88}