ReedSolomonModifiedSyndrome constructor
- Logic syndromes,
- Logic erasureLocator, {
- required ReedSolomonCode code,
- required int erasureCount,
- String name = 'reed_solomon_modified_syndrome',
Creates a modified-syndrome generator.
Implementation
ReedSolomonModifiedSyndrome(
Logic syndromes,
Logic erasureLocator, {
required ReedSolomonCode code,
required this.erasureCount,
super.name = 'reed_solomon_modified_syndrome',
}) : super(
definitionName: 'ReedSolomonModifiedSyndrome_D${code.field.degree}_R'
'${code.paritySymbols}_E$erasureCount',
) {
final width = code.field.degree;
if (erasureCount < 0 || erasureCount > code.paritySymbols) {
throw ArgumentError.value(erasureCount, 'erasureCount');
}
final syndromeCount = code.paritySymbols;
if (syndromes.width != syndromeCount * width) {
throw PortWidthMismatchException(syndromes, syndromeCount * width);
}
if (erasureLocator.width != (erasureCount + 1) * width) {
throw PortWidthMismatchException(
erasureLocator,
(erasureCount + 1) * width,
);
}
final localSyndromes =
addInput('syndromes', syndromes, width: syndromes.width);
final localLocator = addInput(
'erasureLocator',
erasureLocator,
width: erasureLocator.width,
);
GfLogic syndrome(int index) => GfLogic.of(
localSyndromes.slice((index + 1) * width - 1, index * width),
field: code.field,
);
GfLogic locator(int index) => GfLogic.of(
localLocator.slice((index + 1) * width - 1, index * width),
field: code.field,
);
final modified = <Logic>[];
for (var outputIndex = 0;
outputIndex < syndromeCount - erasureCount;
outputIndex++) {
final sourceIndex = outputIndex + erasureCount;
var value = GfLogic.constant(code.field.zero);
for (var coefficient = 0;
coefficient <= erasureCount && coefficient <= sourceIndex;
coefficient++) {
value += locator(coefficient) * syndrome(sourceIndex - coefficient);
}
modified.add(value);
}
addOutput(
'modifiedSyndromes',
width: (syndromeCount - erasureCount) * width,
).gets(modified.rconcat());
}