Skip to content

hal.codes.generalized_toric_codes

GeneralizedToricCode

GeneralizedToricCode(
    orders, poly_a, poly_b, field=None, lattice_vectors=None
)

Bases: CSSCode

Generalized toric codes on twisted tori for quantum error correction.

Construct a generalized toric code on twisted torus.

alpha property

alpha

Get α parameter from lattice vector a1 = (0, α).

beta property

beta

Get β parameter from lattice vector a2 = (β, γ).

gamma property

gamma

Get γ parameter from lattice vector a2 = (β, γ).

graph property

graph

Get the graph representation of this code.

is_twisted property

is_twisted

Check if this is a twisted torus (γ ≠ 0).

__str__

__str__()

Human-readable representation of this code.

_build_custom_matrices

_build_custom_matrices(orders_seq, poly_a, poly_b, field)

Build custom parity check matrices for twisted torus.

_extract_term_info

_extract_term_info(term, x, y)

Extract coefficient and exponents from a single term.

_extract_terms

_extract_terms(poly, field)

Extract polynomial terms from Laurent polynomial.

_find_independent_rows

_find_independent_rows(matrix)

Find linearly independent rows using row reduction.

_get_qubit_index

_get_qubit_index(
    base_row,
    base_col,
    shift_x,
    shift_y,
    edge_type,
    alpha,
    beta,
    gamma,
)

Get qubit index with twisted boundary conditions.

_qubit_index_twisted

_qubit_index_twisted(
    row, col, edge_type, alpha, beta, gamma
)

Get qubit index for edge at (row, col) on twisted torus.

_remove_redundant_from_matrices

_remove_redundant_from_matrices(Hx, Hz, field)

Remove redundant stabilizers.

from_paper_parameters classmethod

from_paper_parameters(
    a, b, c, d, lattice_vectors, field=None
)

Construct GeneralizedToricCode from paper's (a,b,c,d)-generalized toric code parameters.

Creates polynomials: f(x,y) = 1 + x + x^a * y^b g(x,y) = 1 + y + x^c * y^d

Args: a, b, c, d: Exponents for generalized toric code lattice_vectors: ((0, α), (β, γ)) defining the twisted torus field: Base field

get_qubit_pos

get_qubit_pos(qubit)

Get the canonical position of a qubit in this code.

get_stabilizer_ranks

get_stabilizer_ranks()

Get the ranks of the X and Z stabilizer matrices.

has_redundant_stabilizers

has_redundant_stabilizers()

Check if the code has any redundant stabilizers.

num_redundant_stabilizers

num_redundant_stabilizers()

Get the number of redundant X and Z stabilizers.

x_shift

x_shift(qubit_index, shift_x, alpha, beta, gamma)

Apply x-direction shift using Eq. (B4)

y_shift

y_shift(qubit_index, shift_y, alpha, beta)

Apply y-direction shift using Eq. (B1)