![]() |
Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
|
Ternary reflected Gray code generator. More...
#include <TernaryGrayCode.h>
Public Member Functions | |
~CTernaryGrayCode () | |
Destructor. More... | |
void | Initialize (const UINT) |
Get first code word. More... | |
UINT | Next () |
Get next code word. More... | |
![]() | |
~CBinaryGrayCode () | |
Destructor. More... | |
virtual void | Initialize (const UINT) |
Get first code word. More... | |
virtual UINT | Next () |
Get next code word. More... | |
Protected Attributes | |
int * | m_nDirection = nullptr |
Direction of ternary change. More... | |
Additional Inherited Members | |
![]() | |
UINT | m_nZeros = 0 |
Number of zeros in the code word. More... | |
UINT | m_nSize = 0 |
Size of the code word. More... | |
UINT * | m_nGrayCodeWord = nullptr |
Current code word. More... | |
UINT * | m_nGrayCodeStack = nullptr |
Stack to remove recursion. 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:
I. Parberry, "A computer assisted optimal depth lower bound for nine-Input sorting networks", Proceedings of Supercomputing '89, pp. 152-161, Reno, Nevada, 1989.
I. Parberry, A computer assisted optimal depth lower bound for nine-Input sorting networks". Mathematical Systems Theory, Vol. 24, pp. 101-116, 1991.
Definition at line 68 of file TernaryGrayCode.h.
CTernaryGrayCode::~CTernaryGrayCode | ( | ) |
Definition at line 6 of file TernaryGrayCode.cpp.
|
virtual |
Reset Gray code generator to the first word in Gray code order, the all-zero word.
n | Number of bits in the Gray code word. |
Reimplemented from CBinaryGrayCode.
Definition at line 14 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 29 of file TernaryGrayCode.cpp.
|
protected |
Definition at line 70 of file TernaryGrayCode.h.