-
Notifications
You must be signed in to change notification settings - Fork 0
/
Decoder.h
53 lines (41 loc) · 1.39 KB
/
Decoder.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
#pragma once
#include <vector>
#include <algorithm>
#include <map>
#include "Value.h"
#include "Polynomial.h"
using namespace std;
class Decoder
{
int m_t;
int m_n;
map<int, int> m_logarithmsTable; // fixme
public:
Decoder(int t);
vector<Value> decode(vector<Value> codedMessage);
Value log(const Value& value);
void debug(bool flag);
public:
class FixedSyndromeError : public Error
{
public:
FixedSyndromeError() : Error() {};
FixedSyndromeError(const string& message) : Error(message) {};
};
class LocatorPolynomialError : public Error
{
public:
LocatorPolynomialError() : Error() {};
LocatorPolynomialError(const string& message) : Error(message) {};
};
protected:
Polynomial calculateSyndromePolynomial(const Polynomial &C);
Polynomial calculateLocatorPolynomial(Polynomial &S); // fixme: const
vector<Value> calculateErrorsPosition(Polynomial& LAMBDA);
Polynomial calculateSigmaPolynomial(Polynomial& S, Polynomial& LAMBDA, vector<Value> errorPositions);
Polynomial calculateLocatorDerivativePolynomial(Polynomial &LAMBDA, vector<Value> &errorsPosition);
Polynomial calculateCorrectionPolynomial(vector<Value> &codedMessage, Polynomial &SIGMA, Polynomial &LAMBDAD,
vector<Value> &errorPositions);
private:
void initLogarithmTable();
};