BinaryLinearRecurrenceDescriptor constructor

BinaryLinearRecurrenceDescriptor({
  1. required BinaryMatrix stateMatrix,
  2. BinaryMatrix? inputMatrix,
  3. BigInt? offset,
})

Creates a binary linear recurrence descriptor.

Implementation

BinaryLinearRecurrenceDescriptor({
  required this.stateMatrix,
  this.inputMatrix,
  BigInt? offset,
}) : offset = offset ?? BigInt.zero {
  if (stateMatrix.rowCount != stateMatrix.columnCount) {
    throw RohdHclException(
        'Binary recurrence state matrix must be square, but is '
        '${stateMatrix.rowCount}x${stateMatrix.columnCount}.');
  }
  if (inputMatrix != null && inputMatrix!.rowCount != stateWidth) {
    throw RohdHclException(
        'Binary recurrence input matrix must have $stateWidth rows, but has '
        '${inputMatrix!.rowCount}.');
  }
  if (this.offset.isNegative || this.offset >= (BigInt.one << stateWidth)) {
    throw RohdHclException(
        'Binary recurrence offset ${this.offset} does not fit in '
        '$stateWidth state bits.');
  }
}