View source on GitHub
|
A qubit on a 1d lattice with nearest-neighbor connectivity.
Inherits From: Qid
cirq.LineQubit(
x: int
) -> cirq.LineQubit
Used in the notebooks
| Used in the guide | Used in the tutorials |
|---|---|
LineQubits have a single attribute, and integer coordinate 'x', which identifies the qubits location on the line. LineQubits are ordered by this integer.
One can construct new cirq.LineQubits by adding or subtracting integers:
cirq.LineQubit(1) + 3cirq.LineQubit(4)
cirq.LineQubit(2) - 1cirq.LineQubit(1)
Args | |
|---|---|
x
|
The x coordinate. |
Attributes | |
|---|---|
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
is_adjacent
is_adjacent(
other: cirq.Qid
) -> bool
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
neighbors(
qids: (Iterable[ops.Qid] | None) = None
) -> set[_BaseLineQid]
Returns qubits that are potential neighbors to this LineQubit
| Args | |
|---|---|
qids
|
optional Iterable of qubits to constrain neighbors to. |
range
@staticmethodrange( *range_args ) -> list[LineQubit]
Returns a range of line qubits.
| Args | |
|---|---|
*range_args
|
Same arguments as python's built-in range method. |
| Returns | |
|---|---|
| A list of line qubits. |
validate_dimension
@staticmethodvalidate_dimension( dimension: int ) -> None
Raises an exception if dimension is not positive.
| Raises | |
|---|---|
ValueError
|
dimension is not positive.
|
with_dimension
with_dimension(
dimension: int
) -> LineQid
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__
__add__(
other: (int | Self)
) -> Self
__eq__
__eq__(
other
) -> bool
Return self==value.
__ge__
__ge__(
other
) -> bool
Return self>=value.
__gt__
__gt__(
other
) -> bool
Return self>value.
__le__
__le__(
other
) -> bool
Return self<=value.
__lt__
__lt__(
other
) -> bool
Return self<value.
__ne__
__ne__(
other
) -> bool
Return self!=value.
__neg__
__neg__() -> Self
__radd__
__radd__(
other: int
) -> Self
__rsub__
__rsub__(
other: int
) -> Self
__sub__
__sub__(
other: (int | Self)
) -> Self
View source on GitHub