本文整理汇总了C++中Permutation::isEven方法的典型用法代码示例。如果您正苦于以下问题:C++ Permutation::isEven方法的具体用法?C++ Permutation::isEven怎么用?C++ Permutation::isEven使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permutation
的用法示例。
在下文中一共展示了Permutation::isEven方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makePermutationEvenIfNecessary
//static
void TruthTableUtils::makePermutationEvenIfNecessary(TruthTable* tablePtr, uint k, uint n)
{
const ProgramOptions& options = ProgramOptions::get();
if (k > n && options.isTuningEnabled && options.options.getBool("complete-permutation-to-even", false))
{
TruthTable& table = *tablePtr;
Permutation permutation = PermutationUtils::createPermutation(table, false);
if (!permutation.isEven())
{
uint totalInputCount = (uint)1 << k;
uint originalInputCount = (uint)1 << n;
uint firstIndex = originalInputCount;
uint lastIndex = firstIndex + 1;
int distanceChange = calculateHammingDistanceChangeForTwoEntriesSwap(table,
firstIndex, lastIndex);
for (uint outerIndex = firstIndex; outerIndex < totalInputCount; ++outerIndex)
{
for (uint innerIndex = outerIndex + 1; innerIndex < totalInputCount; ++innerIndex)
{
int diff = calculateHammingDistanceChangeForTwoEntriesSwap(table,
outerIndex, innerIndex);
if (diff > distanceChange)
{
distanceChange = diff;
firstIndex = outerIndex;
lastIndex = innerIndex;
}
}
}
swap(table[firstIndex], table[lastIndex]);
}
}
}