Compare commits

...

3 commits

Author SHA1 Message Date
Ahmet Inan
da33b7b68c candidates are sorted now 2024-03-09 16:09:50 +01:00
Ahmet Inan
ca8546deb1 use the faster second version of the estimator 2021-09-10 23:56:42 +02:00
Ahmet Inan
c223befa1a use the repeated median estimator of Siegel 2021-09-10 00:15:21 +02:00

View file

@ -9,8 +9,8 @@ Copyright 2021 Ahmet Inan <inan@aicodix.de>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
namespace DSP { using std::abs; using std::min; using std::cos; using std::sin; } namespace DSP { using std::abs; using std::min; using std::cos; using std::sin; }
#include "repeated_median.hh"
#include "bip_buffer.hh" #include "bip_buffer.hh"
#include "theil_sen.hh"
#include "xorshift.hh" #include "xorshift.hh"
#include "trigger.hh" #include "trigger.hh"
#include "complex.hh" #include "complex.hh"
@ -193,7 +193,7 @@ struct Decoder
DSP::BlockDC<value, value> blockdc; DSP::BlockDC<value, value> blockdc;
DSP::Hilbert<cmplx, filter_len> hilbert; DSP::Hilbert<cmplx, filter_len> hilbert;
DSP::BipBuffer<cmplx, buffer_len> input_hist; DSP::BipBuffer<cmplx, buffer_len> input_hist;
DSP::TheilSenEstimator<value, cols_max> tse; DSP::RepeatedMedianEstimator2<value, cols_max> rme;
SchmidlCox<value, cmplx, search_pos, symbol_len/2, guard_len> correlator; SchmidlCox<value, cmplx, search_pos, symbol_len/2, guard_len> correlator;
CODE::CRC<uint16_t> crc0; CODE::CRC<uint16_t> crc0;
CODE::CRC<uint32_t> crc1; CODE::CRC<uint32_t> crc1;
@ -519,13 +519,13 @@ struct Decoder
index[i] = i + code_off; index[i] = i + code_off;
phase[i] = arg(cons[cons_cols*j+i] * conj(mod_map(tmp))); phase[i] = arg(cons[cons_cols*j+i] * conj(mod_map(tmp)));
} }
tse.compute(index, phase, cons_cols); rme.compute(index, phase, cons_cols);
//std::cerr << "Theil-Sen slope = " << tse.slope() << std::endl; //std::cerr << "rme slope = " << rme.slope() << std::endl;
//std::cerr << "Theil-Sen yint = " << tse.yint() << std::endl; //std::cerr << "rme yint = " << rme.yint() << std::endl;
sum_slope += tse.slope(); sum_slope += rme.slope();
sum_yint += tse.yint(); sum_yint += rme.yint();
for (int i = 0; i < cons_cols; ++i) for (int i = 0; i < cons_cols; ++i)
cons[cons_cols*j+i] *= DSP::polar<value>(1, -tse(i+code_off)); cons[cons_cols*j+i] *= DSP::polar<value>(1, -rme(i+code_off));
} }
value avg_slope = sum_slope / cons_rows; value avg_slope = sum_slope / cons_rows;
value avg_yint = sum_yint / cons_rows; value avg_yint = sum_yint / cons_rows;
@ -557,20 +557,15 @@ struct Decoder
for (int i = 0; i < cons_cnt; ++i) for (int i = 0; i < cons_cnt; ++i)
mod_soft(code+mod_bits*i, cons[i], precision); mod_soft(code+mod_bits*i, cons[i], precision);
lengthen(); lengthen();
CODE::PolarHelper<mesg_type>::PATH metric[mesg_type::SIZE]; polardec(0, mesg, code, frozen_bits, code_order);
polardec(metric, mesg, code, frozen_bits, code_order);
systematic(); systematic();
int order[mesg_type::SIZE];
for (int k = 0; k < mesg_type::SIZE; ++k)
order[k] = k;
std::sort(order, order+mesg_type::SIZE, [metric](int a, int b){ return metric[a] < metric[b]; });
int best = -1; int best = -1;
for (int k = 0; k < mesg_type::SIZE; ++k) { for (int k = 0; k < mesg_type::SIZE; ++k) {
crc1.reset(); crc1.reset();
for (int i = 0; i < crc_bits; ++i) for (int i = 0; i < crc_bits; ++i)
crc1(mesg[i].v[order[k]] < 0); crc1(mesg[i].v[k] < 0);
if (crc1() == 0) { if (crc1() == 0) {
best = order[k]; best = k;
break; break;
} }
} }