View source on GitHub |
A qid on a 1d lattice with nearest-neighbor connectivity.
Inherits From: Qid
cirq.LineQid(
x: int, dimension: int
) -> 'cirq.LineQid'
Used in the notebooks
Used in the tutorials |
---|
LineQid
s have a single attribute, and integer coordinate 'x', which
identifies the qids location on the line. LineQid
s are ordered by
this integer.
One can construct new cirq.LineQid
s 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)
Args | |
---|---|
x
|
The x coordinate. |
dimension
|
The dimension of the qid's Hilbert space, i.e. the number of quantum levels. |
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
for_gate
@staticmethod
for_gate( val: Any, start: int = 0, step: int = 1 ) -> List['LineQid']
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
@staticmethod
for_qid_shape( qid_shape: Sequence[int], start: int = 0, step: int = 1 ) -> List['LineQid']
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
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: Optional[Iterable[ops.Qid]] = None
) -> Set['_BaseLineQid']
Returns qubits that are potential neighbors to this LineQubit
Args | |
---|---|
qids
|
optional Iterable of qubits to constrain neighbors to. |
range
@staticmethod
range( *range_args, dimension: int ) -> List['LineQid']
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
@staticmethod
validate_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: Union[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: Union[int, Self]
) -> Self