|
FZGPUModules 2.0
GPU-accelerated modular compression pipelines
|
#include <negabinary.h>
Static Public Member Functions | |
| static FZ_HOST_DEVICE constexpr UInt | encode (SInt n) noexcept |
| static FZ_HOST_DEVICE constexpr SInt | decode (UInt u) noexcept |
Negabinary (base -2) encoding helper.
Maps signed integers to unsigned negabinary representations using a compact XOR-mask formula. After differencing smooth data the high-order bits vanish faster than zigzag, producing denser zero runs at high bit-planes when followed by bitshuffle + RZE. Encode and decode are both O(1) bitwise ops.
All functions are __host__ __device__ — callable from CUDA kernels and host code. Used internally by NegabinaryStage<TIn, TOut>.
| T | Signed integer type (int8_t, int16_t, int32_t, int64_t). |
|
inlinestaticconstexprnoexcept |
Negabinary encode: signed integer → unsigned negabinary.
The formula (n + MASK) ^ MASK converts two's complement to base-(-2).
|
inlinestaticconstexprnoexcept |
Negabinary decode: unsigned negabinary → signed integer. Inverse of encode(); decode(encode(n)) == n for all n.
Derivation from encode u = (n + MASK) ^ MASK: u ^ MASK = n + MASK n = (u ^ MASK) - MASK (unsigned subtraction wraps, then reinterpret as SInt)