forneyMagnitudes method
Evaluates Forney magnitudes at the supplied error positions.
locator is ordered from constant term upward and must contain the
combined error-and-erasure locator. The returned values are ordered to
match positions and can be XORed into the received symbols.
Implementation
List<GfValue> forneyMagnitudes(
Iterable<GfValue> received,
List<GfValue> locator,
Iterable<int> positions,
) {
final symbols = received.toList(growable: false);
final errorPositions = _validateErasurePositions(positions);
if (symbols.length != length) {
throw ArgumentError.value(
symbols, 'received', 'Expected $length symbols.');
}
_requireSymbols(symbols);
if (locator.isEmpty || locator.length > paritySymbols + 1) {
throw ArgumentError.value(locator, 'locator');
}
_requireSymbols(locator);
final receivedSyndromes = syndromes(symbols);
final omega = List<GfValue>.filled(paritySymbols, field.zero);
for (var left = 0; left < locator.length; left++) {
for (var right = 0;
right < receivedSyndromes.length && left + right < omega.length;
right++) {
omega[left + right] += locator[left] * receivedSyndromes[right];
}
}
return [
for (final position in errorPositions)
_forneyMagnitudeAt(omega, locator, position),
];
}