-
Notifications
You must be signed in to change notification settings - Fork 24
/
modulation.hh
74 lines (60 loc) · 1.6 KB
/
modulation.hh
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
/*
Modulation interface
Copyright 2018 Ahmet Inan <[email protected]>
*/
#ifndef MODULATION_HH
#define MODULATION_HH
template <typename TYPE, typename CODE>
struct ModulationInterface
{
typedef TYPE complex_type;
typedef typename TYPE::value_type value_type;
typedef CODE code_type;
virtual int bits() = 0;
virtual void hardN(code_type *, complex_type *) = 0;
virtual void softN(code_type *, complex_type *, value_type) = 0;
virtual void mapN(complex_type *, code_type *) = 0;
virtual void hard(code_type *, complex_type) = 0;
virtual void soft(code_type *, complex_type, value_type) = 0;
virtual complex_type map(code_type *) = 0;
virtual ~ModulationInterface() = default;
};
template <typename MOD, int NUM>
struct Modulation : public ModulationInterface<typename MOD::complex_type, typename MOD::code_type>
{
typedef typename MOD::complex_type complex_type;
typedef typename MOD::value_type value_type;
typedef typename MOD::code_type code_type;
int bits()
{
return MOD::BITS;
}
void hardN(code_type *b, complex_type *c)
{
for (int i = 0; i < NUM; ++i)
MOD::hard(b + i * MOD::BITS, c[i]);
}
void softN(code_type *b, complex_type *c, value_type precision)
{
for (int i = 0; i < NUM; ++i)
MOD::soft(b + i * MOD::BITS, c[i], precision);
}
void mapN(complex_type *c, code_type *b)
{
for (int i = 0; i < NUM; ++i)
c[i] = MOD::map(b + i * MOD::BITS);
}
void hard(code_type *b, complex_type c)
{
MOD::hard(b, c);
}
void soft(code_type *b, complex_type c, value_type precision)
{
MOD::soft(b, c, precision);
}
complex_type map(code_type *b)
{
return MOD::map(b);
}
};
#endif