-
Notifications
You must be signed in to change notification settings - Fork 0
/
libEDM_turbo.h
68 lines (53 loc) · 2.65 KB
/
libEDM_turbo.h
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
#pragma once
#define _USE_MATH_DEFINES
#include <cmath>
#include <libEDM_convolutional.h>
#include <libEDM_interleaver.h>
#include <libEDM_library.h>
class TurboCodec : public Codec {
public:
double rate() const {return divide(numUncoded, numCoded);}
TurboCodec(const size_t feedbackGenerator,
const uVector &parityGenerators,
const size_t constraintLength,
const uMatrix &interleaverSequences,
const size_t numIterations = 8,
const Metric metric = LOGMAX,
const bool adaptiveStop = false)
: rscCodec (constraintLength, parityGenerators, feedbackGenerator, true, true),
numIterations (numIterations),
metric (metric),
adaptiveStop (adaptiveStop),
Lc (1.0),
n (parityGenerators.size()),
m (constraintLength - 1),
numUncoded (interleaverSequences[0].size()),
numCoded (numUncoded*(1+numCoders*n) + numCoders*m*(1+n)),
numCoders (interleaverSequences.size()+1)
{
for (size_t i=0; i<interleaverSequences.size(); i++)
{
bInterleavers.push_back(bSequenceInterleaver(interleaverSequences[i]));
dInterleavers.push_back(dSequenceInterleaver(interleaverSequences[i]));
}
}
void set_awgn_channel_parameters(const double channelSNR) {set_scaling_factor(4.0 * channelSNR);}
void set_iterations (const size_t numIterations) {this->numIterations = numIterations;}
void set_scaling_factor (const double Lc) {this->Lc = Lc;}
void encode (const bVector &input, bVector &output) const {output = encode(input);}
bVector encode (const bVector &input) const;
void decode (const dVector &input, bVector &output, const bVector &trueBits = bVector()) {output = decode(input, trueBits);}
bVector decode (const dVector &input, const bVector &trueBits = bVector());
private:
const size_t n, m, numCoders;
const size_t numUncoded, numCoded;
const bool adaptiveStop;
const Metric metric;
size_t numIterations;
double Lc;
vector<bSequenceInterleaver> bInterleavers;
vector<dSequenceInterleaver> dInterleavers;
ConvolutionalCodec rscCodec;
dVector unsplice (dVector::const_iterator rxSignal, dMatrix &received) const;
};
uVector wcdma_turbo_interleaver_sequence(size_t interleaverSize);