mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
added typedef to shorten the random generator lines
This commit is contained in:
parent
ab44dc4042
commit
903bf07584
3 changed files with 22 additions and 18 deletions
|
|
@ -28,8 +28,8 @@ int main()
|
|||
uint8_t code[L];
|
||||
for (int i = 0; i < L; ++i)
|
||||
code[i] = target[i];
|
||||
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
||||
auto noise = std::bind(distribution, generator);
|
||||
typedef std::uniform_int_distribution<BCH::value_type> distribution;
|
||||
auto noise = std::bind(distribution(0, BCH::N-1), generator);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
int n = noise();
|
||||
if (n < BCH::K)
|
||||
|
|
@ -61,8 +61,8 @@ int main()
|
|||
uint8_t *code = new uint8_t[L];
|
||||
for (int i = 0; i < L; ++i)
|
||||
code[i] = target[i];
|
||||
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
||||
auto noise = std::bind(distribution, generator);
|
||||
typedef std::uniform_int_distribution<BCH::value_type> distribution;
|
||||
auto noise = std::bind(distribution(0, BCH::N-1), generator);
|
||||
for (int i = 0; i < 12; ++i) {
|
||||
int n = noise();
|
||||
if (n < BCH::K)
|
||||
|
|
@ -88,8 +88,8 @@ int main()
|
|||
BCH::value_type code[BCH::N];
|
||||
for (int i = 0; i < BCH::N; ++i)
|
||||
code[i] = target[i];
|
||||
std::uniform_int_distribution<BCH::value_type> distribution(0, BCH::N-1);
|
||||
auto noise = std::bind(distribution, generator);
|
||||
typedef std::uniform_int_distribution<BCH::value_type> distribution;
|
||||
auto noise = std::bind(distribution(0, BCH::N-1), generator);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
code[noise()] ^= 1;
|
||||
decode(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||
|
|
@ -111,8 +111,8 @@ int main()
|
|||
BCH::value_type *code = new BCH::value_type[BCH::N];
|
||||
for (int i = 0; i < BCH::N; ++i)
|
||||
code[i] = target[i];
|
||||
std::uniform_int_distribution<BCH::value_type> distribution(0, BCH::N-1);
|
||||
auto noise = std::bind(distribution, generator);
|
||||
typedef std::uniform_int_distribution<BCH::value_type> distribution;
|
||||
auto noise = std::bind(distribution(0, BCH::N-1), generator);
|
||||
for (int i = 0; i < 12; ++i)
|
||||
code[noise()] ^= 1;
|
||||
(*decode)(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ int main()
|
|||
RS::value_type code[RS::N];
|
||||
for (int i = 0; i < RS::N; ++i)
|
||||
code[i] = target[i];
|
||||
auto pos = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N-1), generator);
|
||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||
typedef std::uniform_int_distribution<RS::value_type> distribution;
|
||||
auto pos = std::bind(distribution(0, RS::N-1), generator);
|
||||
auto val = std::bind(distribution(0, RS::N), generator);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
code[pos()] = val();
|
||||
decode(code, code + RS::K);
|
||||
|
|
@ -47,8 +48,9 @@ int main()
|
|||
RS::value_type code[RS::N];
|
||||
for (int i = 0; i < RS::N; ++i)
|
||||
code[i] = target[i];
|
||||
auto pos = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N-1), generator);
|
||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||
typedef std::uniform_int_distribution<RS::value_type> distribution;
|
||||
auto pos = std::bind(distribution(0, RS::N-1), generator);
|
||||
auto val = std::bind(distribution(0, RS::N), generator);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
code[pos()] = val();
|
||||
decode(code, code + RS::K);
|
||||
|
|
@ -70,8 +72,9 @@ int main()
|
|||
RS::value_type *code = new RS::value_type[RS::N];
|
||||
for (int i = 0; i < RS::N; ++i)
|
||||
code[i] = target[i];
|
||||
auto pos = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N-1), generator);
|
||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||
typedef std::uniform_int_distribution<RS::value_type> distribution;
|
||||
auto pos = std::bind(distribution(0, RS::N-1), generator);
|
||||
auto val = std::bind(distribution(0, RS::N), generator);
|
||||
for (int i = 0; i < 32; ++i)
|
||||
code[pos()] = val();
|
||||
(*decode)(code, code + RS::K);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@ void rs_test(int trials)
|
|||
GF instance;
|
||||
DEC decode;
|
||||
ENC encode;
|
||||
auto rnd_cnt = std::bind(std::uniform_int_distribution<typename ENC::value_type>(0, ENC::NP), generator);
|
||||
auto rnd_len = std::bind(std::uniform_int_distribution<typename ENC::value_type>(1, ENC::K), generator);
|
||||
auto rnd_val = std::bind(std::uniform_int_distribution<typename ENC::value_type>(0, ENC::N), generator);
|
||||
typedef std::uniform_int_distribution<typename ENC::value_type> distribution;
|
||||
auto rnd_cnt = std::bind(distribution(0, ENC::NP), generator);
|
||||
auto rnd_len = std::bind(distribution(1, ENC::K), generator);
|
||||
auto rnd_val = std::bind(distribution(0, ENC::N), generator);
|
||||
while (--trials) {
|
||||
int data_len = rnd_len();
|
||||
auto rnd_pos = std::bind(std::uniform_int_distribution<typename ENC::value_type>(0, data_len + ENC::NP - 1), generator);
|
||||
auto rnd_pos = std::bind(distribution(0, data_len + ENC::NP - 1), generator);
|
||||
typename ENC::value_type data[data_len], orig_data[data_len];
|
||||
for (int i = 0; i < data_len; ++i)
|
||||
data[i] = orig_data[i] = rnd_val();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue