Skip to main content

Mojo function

morton_decode_2d

morton_decode_2d(flat_idx: UInt32) -> Tuple[UInt32, UInt32]

Decode a linear index to (tile_m, tile_n) via Morton Z-order.

Even bits of flat_idx -> tile_n, odd bits -> tile_m. The decoded pair may fall outside any rectangular grid that isn't a power-of-2 square; the caller checks bounds.

Returns:

Tuple[UInt32, UInt32]