cirq.LineQid

A qid on a 1d lattice with nearest-neighbor connectivity.

Inherits From: Qid

Used in the notebooks

Used in the tutorials

LineQids have a single attribute, and integer coordinate 'x', which identifies the qids location on the line. LineQids are ordered by this integer.

One can construct new cirq.LineQids by adding or subtracting integers:

cirq.LineQid(1, dimension=2) + 3
cirq.LineQid(4, dimension=2)
cirq.LineQid(2, dimension=3) - 1
cirq.LineQid(1, dimension=3)

x The x coordinate.
dimension The dimension of the qid's Hilbert space, i.e. the number of quantum levels.

dimension Returns the dimension or the number of quantum levels this qid has. E.g. 2 for a qubit, 3 for a qutrit, etc.
x

Methods

for_gate

View source

Returns a range of line qids with the same qid shape as the gate.

Args
val Any value that supports the cirq.qid_shape protocol. Usually a gate.
start The x coordinate of the first LineQid.
step The amount to increment each x coordinate.

for_qid_shape

View source

Returns a range of line qids for each entry in qid_shape with matching dimension.

Args
qid_shape A sequence of dimensions for each LineQid to create.
start The x coordinate of the first LineQid.
step The amount to increment each x coordinate.

is_adjacent

View source

Determines if two qubits are adjacent line qubits.

Args
other cirq.Qid to test for adjacency.

Returns: True iff other and self are adjacent.

neighbors

View source

Returns qubits that are potential neighbors to this LineQubit

Args
qids optional Iterable of qubits to constrain neighbors to.

range

View source

Returns a range of line qids.

Args
*range_args Same arguments as python's built-in range method.
dimension The dimension of the qid's Hilbert space, i.e. the number of quantum levels.

Returns
A list of line qids.

validate_dimension

View source

Raises an exception if dimension is not positive.

Raises
ValueError dimension is not positive.

with_dimension

View source

Returns a new qid with a different dimension.

Child classes can override. Wraps the qubit object by default.

Args
dimension The new dimension or number of levels.

__add__

View source

__eq__

View source

Return self==value.

__ge__

View source

Return self>=value.

__gt__

View source

Return self>value.

__le__

View source

Return self<=value.

__lt__

View source

Return self<value.

__ne__

View source

Return self!=value.

__neg__

View source

__radd__

View source

__rsub__

View source

__sub__

View source