IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

complement

complement(layout: Layout, size: Int = 1) -> Layout

Computes the complement layout for a given layout.

This function creates a layout that represents the "gaps" or complementary structure of the input layout. It's useful for creating hierarchical layouts where you need to fill in the spaces between existing layout elements.

Example:

from layout import Layout, IntTuple
from layout.layout import complement

# Compute the complement of a layout
var base = Layout(IntTuple(2, 3), IntTuple(3, 1))
var comp = complement(base, 10)
# Result: A layout that fills the gaps in the original layout

Args:

  • layout (Layout): The input layout to compute the complement for.
  • size (Int): The total size of the memory region to consider. Defaults to 1.

Returns:

Layout: A new layout representing the complement of the input layout.