Skip to content

hal.codes.directional_codes

DirectionalCode

DirectionalCode(v1, v2, grid_type, layout_type=1)

Generates a directional code instance based on the provided v1 and v2 vectors.

This class implements the construction of directional codes as described in the paper "Directional Codes: a new family of quantum LDPC codes on hexagonal- and square-grid connectivity hardware". It can generate the parity check matrix and a Tanner graph representation of the code.

Args: v1 (tuple[int, int]): The first vector defining the parallelogram for the torus. v2 (tuple[int, int]): The second vector defining the parallelogram for the torus. grid_type (str): The type of grid to use, either "square" or "hex". layout (str, optional): The layout of X and Z stabilizers. Defaults to "Layout 1".

_connect_hex

_connect_hex()

Connects nodes for a hexagonal-style grid with toric boundary conditions.

This implementation creates a 'brickwork' pattern, ensuring every node has a degree of 3, using only horizontal and vertical connections on the grid.

_connect_square

_connect_square()

Connects nodes for a square-grid with toric boundary conditions.

_generate_connectivity

_generate_connectivity()

Adds edges to the graph based on the specified grid type.

_generate_nodes

_generate_nodes()

Creates qldpc.Node objects, adds them to the graph, and assigns positions.