![]() |
Sorting Network Search
Backtracking for Small Sorting Networks
|
Ternary reflected Gray code generator. More...
#include <TernaryGrayCode.h>
Public Member Functions | |
void | Initialize () |
Get first code word. More... | |
size_t | Next () |
Get next code word. More... | |
![]() | |
virtual void | Initialize () |
Get first code word. More... | |
virtual size_t | Next () |
Get next code word. More... | |
void | Print () |
Debug print. More... | |
Protected Attributes | |
int | m_nDirection [MAXINPUTS+3] |
Direction of ternary change. More... | |
![]() | |
size_t | m_nBit [MAXINPUTS+3] = {0} |
Current code word. More... | |
size_t | m_nStack [MAXINPUTS+3] = {0} |
Stack to remove recursion. More... | |
Additional Inherited Members | |
![]() | |
static void | SetWidth (const size_t) |
Set width. More... | |
static void | SetDepth (const size_t) |
Set depth. More... | |
![]() | |
static size_t | m_nWidth = 9 |
Comparator network width. More... | |
static size_t | m_nDepth = 6 |
Comparator network depth. More... | |
A ternary Gray code generates all strings of \(n\) bits in such a way that it is made up of the following bit pairs: 00 01 11, with an additional single bit if \(n\) is odd, and each string differs from the previous one in exactly one bit. For example, the following is the ternary reflected Gray code on 4 bits, with the ternary version followed by the binary equivalent, then by the index of the changed bit (from left to right starting at zero). The ternary digit 0 corresponds to the binary string 00, the ternary digit 1 corresponds to 10, and the ternary digit 2 corresponds to 11. There is no need for the bit pair 10 since each bit pair is input into a comparator on the first level of a first normal form comparator network.
This class implements a nonrecursive version of the algorithm from the paper.
Definition at line 63 of file TernaryGrayCode.h.
|
virtual |
Reset Gray code generator to the first word in Gray code order, the all-zero word.
Reimplemented from CBinaryGrayCode.
Definition at line 31 of file TernaryGrayCode.cpp.
|
virtual |
Get the next binary word in ternary reflected Gray code order, which will differ from the previous one in exactly one bit.
Reimplemented from CBinaryGrayCode.
Definition at line 42 of file TernaryGrayCode.cpp.
|
protected |
Definition at line 65 of file TernaryGrayCode.h.