mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
renamed and updated Bhattacharyya code construction
This commit is contained in:
parent
c5940d059c
commit
46153c59b2
5 changed files with 12 additions and 12 deletions
|
|
@ -6,12 +6,12 @@ Copyright 2023 Ahmet Inan <inan@aicodix.de>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include "sort.hh"
|
||||||
|
|
||||||
namespace CODE {
|
namespace CODE {
|
||||||
|
|
||||||
template <int MAX_M>
|
template <int MAX_M>
|
||||||
class PolarSeqConst0
|
class BhattacharyyaSequence
|
||||||
{
|
{
|
||||||
void compute(double pe, int i, int h)
|
void compute(double pe, int i, int h)
|
||||||
{
|
{
|
||||||
|
|
@ -23,7 +23,7 @@ class PolarSeqConst0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double prob[1<<MAX_M];
|
double prob[1<<MAX_M];
|
||||||
int index[1<<MAX_M];
|
MergeSort<int, 1<<MAX_M> sort;
|
||||||
public:
|
public:
|
||||||
void operator()(int *sequence, int level, double erasure_probability = std::exp(-1.))
|
void operator()(int *sequence, int level, double erasure_probability = std::exp(-1.))
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ public:
|
||||||
compute(erasure_probability, 0, length / 2);
|
compute(erasure_probability, 0, length / 2);
|
||||||
for (int i = 0; i < length; ++i)
|
for (int i = 0; i < length; ++i)
|
||||||
sequence[i] = i;
|
sequence[i] = i;
|
||||||
std::sort(sequence, sequence+length, [this](int a, int b){ return prob[a] > prob[b]; });
|
sort(sequence, length, [this](int a, int b){ return prob[a] > prob[b]; });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ int main()
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
if (1) {
|
if (1) {
|
||||||
auto construct = new CODE::PolarSeqConst0<M>;
|
auto construct = new CODE::BhattacharyyaSequence<M>;
|
||||||
std::cerr << "sizeof(PolarSeqConst0<M>) = " << sizeof(CODE::PolarSeqConst0<M>) << std::endl;
|
std::cerr << "sizeof(BhattacharyyaSequence<M>) = " << sizeof(CODE::BhattacharyyaSequence<M>) << std::endl;
|
||||||
double better_SNR = design_SNR + 1.59175;
|
double better_SNR = design_SNR + 1.59175;
|
||||||
std::cerr << "better SNR: " << better_SNR << std::endl;
|
std::cerr << "better SNR: " << better_SNR << std::endl;
|
||||||
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ int main()
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
if (1) {
|
if (1) {
|
||||||
auto construct = new CODE::PolarSeqConst0<M>;
|
auto construct = new CODE::BhattacharyyaSequence<M>;
|
||||||
std::cerr << "sizeof(PolarSeqConst0<M>) = " << sizeof(CODE::PolarSeqConst0<M>) << std::endl;
|
std::cerr << "sizeof(BhattacharyyaSequence<M>) = " << sizeof(CODE::BhattacharyyaSequence<M>) << std::endl;
|
||||||
double better_SNR = design_SNR + 1.59175;
|
double better_SNR = design_SNR + 1.59175;
|
||||||
std::cerr << "better SNR: " << better_SNR << std::endl;
|
std::cerr << "better SNR: " << better_SNR << std::endl;
|
||||||
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ int main()
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
if (1) {
|
if (1) {
|
||||||
auto construct = new CODE::PolarSeqConst0<M>;
|
auto construct = new CODE::BhattacharyyaSequence<M>;
|
||||||
std::cerr << "sizeof(PolarSeqConst0<M>) = " << sizeof(CODE::PolarSeqConst0<M>) << std::endl;
|
std::cerr << "sizeof(BhattacharyyaSequence<M>) = " << sizeof(CODE::BhattacharyyaSequence<M>) << std::endl;
|
||||||
double better_SNR = design_SNR + 1.59175;
|
double better_SNR = design_SNR + 1.59175;
|
||||||
std::cerr << "better SNR: " << better_SNR << std::endl;
|
std::cerr << "better SNR: " << better_SNR << std::endl;
|
||||||
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
double probability = std::exp(-pow(10.0, better_SNR / 10));
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ int main()
|
||||||
delete freeze;
|
delete freeze;
|
||||||
} else {
|
} else {
|
||||||
auto sequence = new int[N];
|
auto sequence = new int[N];
|
||||||
auto construct = new CODE::PolarSeqConst0<M>;
|
auto construct = new CODE::BhattacharyyaSequence<M>;
|
||||||
std::cerr << "sizeof(PolarSeqConst0<M>) = " << sizeof(CODE::PolarSeqConst0<M>) << std::endl;
|
std::cerr << "sizeof(BhattacharyyaSequence<M>) = " << sizeof(CODE::BhattacharyyaSequence<M>) << std::endl;
|
||||||
(*construct)(sequence, M, probability);
|
(*construct)(sequence, M, probability);
|
||||||
delete construct;
|
delete construct;
|
||||||
for (int i = 0; i < N / 32; ++i)
|
for (int i = 0; i < N / 32; ++i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue