erasureLocator method

List<GfValue> erasureLocator(
  1. Iterable<int> positions
)

Builds the erasure-locator polynomial for transmitted symbol positions.

positions uses the same ordering as encode and syndromes, with position zero as the least-significant symbol. The returned coefficients are ordered from constant term upward and equal product(1 + alpha^position * x).

Implementation

List<GfValue> erasureLocator(Iterable<int> positions) {
  final erasurePositions = _validateErasurePositions(positions);

  var locator = <GfValue>[field.one];
  for (final position in erasurePositions) {
    final location = field.x.pow(BigInt.from(position));
    final next = List<GfValue>.filled(locator.length + 1, field.zero);
    for (var coefficient = 0; coefficient < locator.length; coefficient++) {
      next[coefficient] += locator[coefficient];
      next[coefficient + 1] += locator[coefficient] * location;
    }
    locator = next;
  }
  return List<GfValue>.unmodifiable(locator);
}