From 8268ba3f856e66c11bf3944604e4ea4da1fc54be Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Thu, 27 Sep 2018 10:06:09 +0200 Subject: [PATCH] moved code[j] out of the inner loop --- bose_chaudhuri_hocquenghem_decoder.hh | 12 ++++++++---- reed_solomon_decoder.hh | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bose_chaudhuri_hocquenghem_decoder.hh b/bose_chaudhuri_hocquenghem_decoder.hh index 2ab1e13..fedb0a1 100644 --- a/bose_chaudhuri_hocquenghem_decoder.hh +++ b/bose_chaudhuri_hocquenghem_decoder.hh @@ -24,12 +24,14 @@ public: int compute_syndromes(uint8_t *code, ValueType *syndromes) { // $syndromes_i = code(pe^{FCR+i})$ + ValueType coeff(get_be_bit(code, 0)); for (int i = 0; i < NR; ++i) - syndromes[i] = ValueType(get_be_bit(code, 0)); + syndromes[i] = coeff; for (int j = 1; j < N; ++j) { + ValueType coeff(get_be_bit(code, j)); IndexType root(FCR), pe(1); for (int i = 0; i < NR; ++i) { - syndromes[i] = fma(root, syndromes[i], ValueType(get_be_bit(code, j))); + syndromes[i] = fma(root, syndromes[i], coeff); root *= pe; } } @@ -81,12 +83,14 @@ 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] = code[0]; + syndromes[i] = coeff; for (int j = 1; j < N; ++j) { + ValueType coeff(code[j]); IndexType root(FCR), pe(1); for (int i = 0; i < NR; ++i) { - syndromes[i] = fma(root, syndromes[i], code[j]); + syndromes[i] = fma(root, syndromes[i], coeff); root *= pe; } } diff --git a/reed_solomon_decoder.hh b/reed_solomon_decoder.hh index 02a2f78..2334880 100644 --- a/reed_solomon_decoder.hh +++ b/reed_solomon_decoder.hh @@ -23,12 +23,14 @@ 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] = code[0]; + syndromes[i] = coeff; for (int j = 1; j < N; ++j) { + ValueType coeff(code[j]); IndexType root(FCR), pe(1); for (int i = 0; i < NR; ++i) { - syndromes[i] = fma(root, syndromes[i], code[j]); + syndromes[i] = fma(root, syndromes[i], coeff); root *= pe; } }