added update_syndromes() helper

This commit is contained in:
Ahmet Inan 2018-09-27 10:33:47 +02:00
commit 6b3bc5e534
2 changed files with 39 additions and 21 deletions

View file

@ -19,21 +19,27 @@ public:
typedef typename GF::ValueType ValueType;
typedef typename GF::IndexType IndexType;
static const int N = GF::N, K = N - NR, NP = NR;
private:
ReedSolomonErrorCorrection<NR, FCR, GF> algorithm;
int compute_syndromes(ValueType *code, ValueType *syndromes)
void update_syndromes(ValueType *poly, ValueType *syndromes, int begin, int end)
{
// $syndromes_i = code(pe^{FCR+i})$
ValueType coeff(code[0]);
for (int i = 0; i < NR; ++i)
syndromes[i] = coeff;
for (int j = 1; j < N; ++j) {
ValueType coeff(code[j]);
for (int j = begin; j < end; ++j) {
ValueType coeff(poly[j]);
IndexType root(FCR), pe(1);
for (int i = 0; i < NR; ++i) {
syndromes[i] = fma(root, syndromes[i], coeff);
root *= pe;
}
}
}
public:
int compute_syndromes(ValueType *code, ValueType *syndromes)
{
// $syndromes_i = code(pe^{FCR+i})$
ValueType coeff(code[0]);
for (int i = 0; i < NR; ++i)
syndromes[i] = coeff;
update_syndromes(code, syndromes, 1, N);
int nonzero = 0;
for (int i = 0; i < NR; ++i)
nonzero += !!syndromes[i];