40 std::vector<CComparator>* vecLevel =
new std::vector<CComparator>[
m_nDepth];
64 for(UINT j=i/2; j>0; j/=2){
66 const UINT nMax = nMin ^ j;
69 vecLevel[nCurLevel].push_back(
84 for(
auto& p: vecLevel[i])
85 if(p.m_nMax < p.m_nMin){
86 std::swap(p.m_nMin, p.m_nMax);
87 Twist(vecLevel, i + 1, p.m_nMin, p.m_nMax);
101 UINT nLevel, UINT nMin, UINT nMax)
104 for(
auto& p: vecLevel[i]){
106 if(p.m_nMin == nMin)p.m_nMin = nMax;
else
107 if(p.m_nMin == nMax)p.m_nMin = nMin;
110 if(p.m_nMax == nMin)p.m_nMax = nMax;
else
111 if(p.m_nMax == nMax)p.m_nMax = nMin;
124 for(
auto& p: vecLevel[i])
133 return std::wstring(L
"Bitonic" + std::to_wstring(
m_nInputs));
Interface for Batcher's bitonic sorting network.
void Twist(std::vector< CComparator > *, UINT, UINT, UINT)
Twist channels.
void MakeAllMinMax(std::vector< CComparator > *)
Make all comparators min-max.
CBitonicSort(const UINT)
Constructor.
void CreateMatchArray(std::vector< CComparator > *)
Create match array.
void CreateComparators(std::vector< CComparator > *)
Create comparators.
const std::wstring GetName() const
Get name.
A min-max or max-min comparator used in bitonic sort.
void InsertComparator(UINT, UINT, UINT)
Insert comparator.
UINT m_nInputs
Number of inputs.
void CreateMatchArray(UINT, UINT)
Create match array.
void CreateUsageArray()
Make usage array.
void CreateValueArray()
Make value array.