IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

morton_decode_2d

def 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]