cirq.GridQid

class cirq.GridQid(row: int, col: int, *, dimension: int)[source]

A qid on a 2d square lattice

GridQid uses row-major ordering:

GridQid(0, 0, dimension=2) < GridQid(0, 1, dimension=2)
< GridQid(1, 0, dimension=2) < GridQid(1, 1, dimension=2)

New GridQid can be constructed by adding or subtracting tuples

>>> cirq.GridQid(2, 3, dimension=2) + (3, 1)
cirq.GridQid(5, 4, dimension=2)

>>> cirq.GridQid(2, 3, dimension=2) - (1, 2)
cirq.GridQid(1, 1, dimension=2)
__init__(row: int, col: int, *, dimension: int) → None[source]

Initializes a grid qid at the given row, col coordinate

Parameters
  • row – the row coordinate

  • col – the column coordinate

  • dimension – The dimension of the qid, e.g. the number of quantum levels.

Methods

from_diagram(diagram, dimension)

Parse ASCII art device layout into info about qids and

is_adjacent(other)

Determines if two qubits are adjacent qubits.

neighbors([qids])

Returns qubits that are potential neighbors to this GridQid

rect(rows, cols[, top, left])

Returns a rectangle of GridQid.

square(diameter[, top, left])

Returns a square of GridQid.

validate_dimension(dimension)

Raises an exception if dimension is not positive.

with_dimension(dimension)

Returns a new qid with a different dimension.

Attributes

col

dimension

Returns the dimension or the number of quantum levels this qid has.

row