Defines the kronecker product order of qubits.
cirq.QubitOrder(
explicit_func: Callable[[Iterable[raw_types.Qid]], Tuple[raw_types.Qid, ...]]
) -> None
Used in the notebooks
Methods
as_qubit_order
View source
@staticmethod
as_qubit_order(
val: 'qubit_order_or_list.QubitOrderOrList'
) -> 'QubitOrder'
Converts a value into a basis.
Args |
val
|
An iterable or a basis.
|
Returns |
The basis implied by the value.
|
Raises |
ValueError
|
If val is not an iterable or a QubitOrder .
|
explicit
View source
@staticmethod
explicit(
fixed_qubits: Iterable[cirq.Qid
],
fallback: Optional['QubitOrder'] = None
) -> 'QubitOrder'
A basis that contains exactly the given qubits in the given order.
Args |
fixed_qubits
|
The qubits in basis order.
|
fallback
|
A fallback order to use for extra qubits not in the
fixed_qubits list. Extra qubits will always come after the
fixed_qubits, but will be ordered based on the fallback. If no
fallback is specified, a ValueError is raised when extra qubits
are specified.
|
Returns |
A Basis instance that forces the given qubits in the given order.
|
Raises |
ValueError
|
If a qubit appears twice in fixed_qubits , or there were is no fallback
specified but there are extra qubits.
|
map
View source
map(
internalize: Callable[[TExternalQubit], TInternalQubit],
externalize: Callable[[TInternalQubit], TExternalQubit]
) -> 'QubitOrder'
Transforms the Basis so that it applies to wrapped qubits.
Args |
externalize
|
Converts an internal qubit understood by the underlying
basis into an external qubit understood by the caller.
|
internalize
|
Converts an external qubit understood by the caller
into an internal qubit understood by the underlying basis.
|
Returns |
A basis that transforms qubits understood by the caller into qubits
understood by an underlying basis, uses that to order the qubits,
then wraps the ordered qubits back up for the caller.
|
order_for
View source
order_for(
qubits: Iterable[cirq.Qid
]
) -> Tuple[cirq.Qid
, ...]
Returns a qubit tuple ordered corresponding to the basis.
Args |
qubits
|
Qubits that should be included in the basis. (Additional
qubits may be added into the output by the basis.)
|
Returns |
A tuple of qubits in the same order that their single-qubit
matrices would be passed into np.kron when producing a matrix for
the entire system.
|
sorted_by
View source
@staticmethod
sorted_by(
key: Callable[[cirq.Qid
], Any]
) -> 'QubitOrder'
A basis that orders qubits ascending based on a key function.
Args |
key
|
A function that takes a qubit and returns a key value. The
basis will be ordered ascending according to these key values.
|
Returns |
A basis that orders qubits ascending based on a key function.
|