FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
fz::Zigzag< T > Struct Template Reference

#include <zigzag.h>

Static Public Member Functions

static FZ_HOST_DEVICE constexpr UInt encode (SInt x) noexcept
 
static FZ_HOST_DEVICE constexpr SInt decode (UInt u) noexcept
 

Detailed Description

template<typename T>
struct fz::Zigzag< T >

Zigzag (two's-complement to magnitude-sign) encoding helper.

Maps signed integers to unsigned integers such that small-magnitude values (positive and negative) produce small non-negative codes — ideal before entropy coding or bitshuffle. Encode and decode are both O(1) bitwise ops.

All functions are __host__ __device__ — callable from CUDA kernels and host code. Used internally by ZigzagStage<TIn, TOut>.

Template Parameters
TSigned integer type (int8_t, int16_t, int32_t, int64_t).

Member Function Documentation

◆ encode()

template<typename T >
static FZ_HOST_DEVICE constexpr UInt fz::Zigzag< T >::encode ( SInt  x)
inlinestaticconstexprnoexcept

Zigzag encode: signed integer → unsigned integer.

Small-magnitude signed values map to small unsigned values: 0 → 0, -1 → 1, 1 → 2, -2 → 3, 2 → 4, …

◆ decode()

template<typename T >
static FZ_HOST_DEVICE constexpr SInt fz::Zigzag< T >::decode ( UInt  u)
inlinestaticconstexprnoexcept

Zigzag decode: unsigned integer → signed integer. Inverse of encode(); decode(encode(x)) == x for all x.