![]() |
Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
|
Code for useful helper functions. More...
#include "Helpers.h"Go to the source code of this file.
Functions | |
| bool | odd (const UINT n) |
| Parity test. More... | |
| bool | IsPowerOf2 (const UINT n) |
| Power of 2 test. More... | |
| UINT | CeilLog2 (const UINT n) |
| Ceiling of log base 2. More... | |
| UINT CeilLog2 | ( | const UINT | n | ) |
Compute the ceiling of log base 2. For speed, this relies on the Windows API function _BitScanReverse, which uses the corresponding native machine-code instruction to find the index of the most significant 1 in the binary representation of an unsigned integer. In retrospect this is probably overkill for this application but you have to admit that it's cool.
| n | A number. |
< Ceiling of log base 2.
Definition at line 52 of file Helpers.cpp.
| bool IsPowerOf2 | ( | const UINT | n | ) |
Power of 2 test.
| n | A number. |
Definition at line 40 of file Helpers.cpp.
| bool odd | ( | const UINT | n | ) |
Parity test.
| n | A number. |
Definition at line 32 of file Helpers.cpp.