applyPacked method
Applies this permutation to fixed-width elements packed into value.
Implementation
BigInt applyPacked(BigInt value, {int elementWidth = 1}) {
if (elementWidth <= 0) {
throw RohdHclException('Permutation element width must be positive.');
}
final packedWidth = length * elementWidth;
if (value.isNegative || value >= (BigInt.one << packedWidth)) {
throw RohdHclException(
'Packed permutation value $value does not fit in $packedWidth bits.');
}
final mask = (BigInt.one << elementWidth) - BigInt.one;
var result = BigInt.zero;
for (var outputIndex = 0; outputIndex < length; outputIndex++) {
final sourceIndex = _sourceIndices[outputIndex];
final element = (value >> (sourceIndex * elementWidth)) & mask;
result |= element << (outputIndex * elementWidth);
}
return result;
}