BchCode constructor

BchCode({
  1. required BinaryExtensionField field,
  2. required int designedDistance,
  3. int firstRoot = 1,
  4. int shortening = 0,
})

Creates a BCH code descriptor.

Implementation

BchCode({
  required this.field,
  required this.designedDistance,
  this.firstRoot = 1,
  this.shortening = 0,
}) {
  if (!field.isPrimitivePolynomial()) {
    throw RohdHclException('BCH construction requires a primitive field.');
  }
  if (designedDistance < 2) {
    throw ArgumentError.value(designedDistance, 'designedDistance');
  }
  if (shortening < 0 || shortening >= fullLength) {
    throw ArgumentError.value(shortening, 'shortening');
  }
  if (shortening > 0 && shortening > messageBits) {
    throw ArgumentError.value(
      shortening,
      'shortening',
      'Cannot shorten more information bits than the parent code has.',
    );
  }
  if (firstRoot < 0 || firstRoot >= fullLength) {
    throw ArgumentError.value(firstRoot, 'firstRoot');
  }
  if (designedDistance > fullLength) {
    throw ArgumentError.value(designedDistance, 'designedDistance');
  }
}