decode static method
Implementation
static void decode(UGaloisField field, Int32List received, int twoS) {
final UGfPoly poly = UGfPoly(field, received);
final Int32List syndromes = Int32List(twoS);
bool noError = true;
for (int i = 0; i < twoS; i++) {
final int evaluated = poly.evaluate(field.exp(i + field.generatorBase));
syndromes[twoS - 1 - i] = evaluated;
if (evaluated != 0) noError = false;
}
if (noError) return;
final UGfPoly syndrome = UGfPoly(field, syndromes);
final List<UGfPoly> sigmaOmega = _euclidean(field, UGfPoly.monomial(field, twoS, 1), syndrome, twoS);
final UGfPoly sigma = sigmaOmega[0];
final UGfPoly omega = sigmaOmega[1];
final Int32List positions = _findErrorLocations(field, sigma);
final Int32List magnitudes = _findErrorMagnitudes(field, omega, positions);
for (int i = 0; i < positions.length; i++) {
final int position = received.length - 1 - field.log(positions[i]);
if (position < 0) throw const UCodeDecodeException("Bad error location");
received[position] = UGaloisField.addOrSubtract(received[position], magnitudes[i]);
}
}