mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
made T a template parameter
This commit is contained in:
parent
f8b782033d
commit
77f27a8c5e
4 changed files with 7 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ Copyright 2020 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
namespace CODE {
|
||||
|
||||
template <int N, int K>
|
||||
template <int N, int K, int T>
|
||||
class ShortBCHCodeDecoder
|
||||
{
|
||||
static const int P = N - K;
|
||||
|
|
@ -35,7 +35,7 @@ class ShortBCHCodeDecoder
|
|||
return sum;
|
||||
}
|
||||
public:
|
||||
ShortBCHCodeDecoder(int generator, int T)
|
||||
ShortBCHCodeDecoder(int generator)
|
||||
{
|
||||
for (int i = 0; i < W; ++i)
|
||||
par[i] = modgen(i << P, generator);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ int main()
|
|||
if (1) {
|
||||
// Perfect binary Golay code using x^11+x^9+x^7+x^6+x^5+x+1
|
||||
const int N = 23, K = 12, T = 3, POLY = 0b101011100011;
|
||||
CODE::ShortBCHCodeDecoder<N, K> decode(POLY, T);
|
||||
CODE::ShortBCHCodeDecoder<N, K, T> decode(POLY);
|
||||
int target = 0b10101101101111011111001;
|
||||
int damaged = target;
|
||||
typedef std::uniform_int_distribution<int> distribution;
|
||||
|
|
@ -30,7 +30,7 @@ int main()
|
|||
if (1) {
|
||||
// Perfect binary Golay code using x^11+x^10+x^6+x^5+x^4+x^2+1
|
||||
const int N = 23, K = 12, T = 3, POLY = 0b110001110101;
|
||||
CODE::ShortBCHCodeDecoder<N, K> decode(POLY, T);
|
||||
CODE::ShortBCHCodeDecoder<N, K, T> decode(POLY);
|
||||
int target = 0b10101101101100100010101;
|
||||
int damaged = target;
|
||||
typedef std::uniform_int_distribution<int> distribution;
|
||||
|
|
@ -43,7 +43,7 @@ int main()
|
|||
if (1) {
|
||||
// NASA INTRO BCH(15, 5) T=3
|
||||
const int N = 15, K = 5, T = 3, POLY = 0b10100110111;
|
||||
CODE::ShortBCHCodeDecoder<N, K> decode(POLY, T);
|
||||
CODE::ShortBCHCodeDecoder<N, K, T> decode(POLY);
|
||||
int target = 0b110010001111010;
|
||||
int damaged = target;
|
||||
typedef std::uniform_int_distribution<int> distribution;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ template <int N, int K, int T, int POLY>
|
|||
void bch_test(int trials)
|
||||
{
|
||||
CODE::ShortBCHCodeEncoder<N, K> encode(POLY);
|
||||
CODE::ShortBCHCodeDecoder<N, K> decode(POLY, T);
|
||||
CODE::ShortBCHCodeDecoder<N, K, T> decode(POLY);
|
||||
std::random_device rd;
|
||||
typedef std::default_random_engine generator;
|
||||
typedef std::uniform_int_distribution<int> distribution;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ int popcnt(TYPE x)
|
|||
int main()
|
||||
{
|
||||
CODE::ShortBCHCodeEncoder<CODE_LEN, DATA_LEN> encode(GEN_POLY);
|
||||
CODE::ShortBCHCodeDecoder<CODE_LEN, DATA_LEN> decode(GEN_POLY, RADIUS_T);
|
||||
CODE::ShortBCHCodeDecoder<CODE_LEN, DATA_LEN, RADIUS_T> decode(GEN_POLY);
|
||||
|
||||
std::random_device rd;
|
||||
std::default_random_engine generator(rd());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue