36 size_t m_nCurIndex = 0;
46 const size_t minIndex = std::min(m_nCurIndex,
Permute(copy,
m_nWidth/2));
55 }
while(curMatching.
Next());
62 std::cout <<
m_stlResults.size() <<
" second levels found out of ";
63 std::cout << m_nCurIndex <<
" matchings" << std::endl;
81 nCopy[i] = (
int)matching[i];
86 if(nCopy[i] > nCopy[i+1])
87 std::swap(nCopy[i], nCopy[i+1]);
95 if(nCopy[i] > nCopy[max])
101 index += b*(n - 2 - nCopy[max - 1]);
106 if(nCopy[j] > nCopy[max - 1])
125 size_t nMinIndex = 99999;
127 for(
size_t i=0; i<n; i++){
129 nMinIndex = std::min(nMinIndex,
Permute(matching, n - 1));
132 matching.
Swap(
odd(n)? 0: i, n - 1);
133 nMinIndex = std::min(nMinIndex,
GetIndex(matching));
160 for(
size_t i =
oddfloor(n); i>1; i-=2)
170 const std::string fname =
"level2-" + std::to_string(
m_nWidth) +
".txt";
171 std::ofstream outfile(fname);
173 if(outfile.is_open())
175 outfile << std::string(m) << std::endl;
#define evenceil(n)
If odd, round up to make even.
#define MAXINPUTS
Maximum width, that is, number of inputs.
#define oddfloor(n)
If even, round down to make odd.
#define odd(n)
Oddness test.
Interface for the Level 2 search CLevel2Search.
const std::vector< CMatching > & GetMatchings() const
Get matching vector.
size_t GetIndex(CMatching &)
Get the index of a matching.
const size_t GetNumMatchings(const size_t) const
Number of matchings.
std::vector< CMatching > m_stlResults
Results.
void Save() const
Save results to log file for debugging purposes.
size_t Permute(CMatching &, const size_t)
Permute the matching.
std::set< size_t > m_stlUsed
Set of indices of used matchings.
CLevel2Search()
Constructor.
bool Next()
Advance to next matching.
void Initialize()
Initialize.
void Swap(const size_t, const size_t)
Swap.
static size_t m_nWidth
Comparator network width.