69 for(
size_t j=s-1; j>=2; j--){
77 for(
size_t j=0; j<s; j++)
100 const size_t i0 = 2*i;
101 const size_t i1 = i0 + 1;
102 const size_t j0 = 2*j;
103 const size_t j1 = j0 + 1;
105 std::swap(m[i0], m[j0]);
106 std::swap(m[i1], m[j1]);
109 if(m[k] == i0) m[k] = (int)j0;
110 else if(m[k] == (
int)j0) m[k] = (
int)i0;
111 else if(m[k] == (
int)i1) m[k] = (
int)j1;
112 else if(m[k] == (
int)j1) m[k] = (
int)i1;
122 for(
size_t j=0; j<n; j++)
127 for(
size_t j=0; j<n; j++){
128 const size_t src = std::max(next++, j/2 + 1);
130 if(nCopy[j] >
int(2*src + 1))
136 for(
size_t k=0; k<n; k++)
140 nCopy[nCopy[k]] = -1;
149 const size_t i0 =
m_nMap[2*i];
150 const size_t j0 =
m_nMap[2*j];
158 const size_t i1 =
m_nMap[2*i + 1];
159 const size_t j1 =
m_nMap[2*j + 1];
172CMatching::operator std::string()
const{
175 for(
size_t i=0; i<m_nWidth-1; i++)
176 str += std::to_string(m_nMatching[i]) +
" ";
178 return str + std::to_string(m_nMatching[m_nWidth - 1]);
#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.
Interface for the matching CMatching.
bool Next()
Advance to next matching.
void Normalize()
Normalize.
CMatching()
Void constructor.
int m_nStack[MAXINPUTS+1]
Stack to remove recursion from permutation.
void Initialize()
Initialize.
size_t & operator[](const size_t)
Overloaded index operator.
void Swap(const size_t, const size_t)
Swap.
size_t m_nMap[MAXINPUTS+1]
Matching index map.
size_t m_nMatching[MAXINPUTS+1]
Matching.
void SwapPair(int[], size_t, size_t)
Swap pair.
static size_t m_nWidth
Comparator network width.