![]() |
Abstract wrapper around a stabilizer state for the act_on protocol.
Inherits From: ActOnArgs
, OperationTarget
cirq.sim.ActOnStabilizerArgs(
state: cirq.sim.clifford.act_on_stabilizer_args.TStabilizerState
,
prng: Optional[np.random.RandomState] = None,
log_of_measurement_results: Optional[Dict[str, List[int]]] = None,
qubits: Optional[Sequence['cirq.Qid']] = None,
classical_data: Optional['cirq.ClassicalDataStore'] = None
)
Args | |
---|---|
state
|
The quantum stabilizer state to use in the simulation or act_on invocation. |
prng
|
The pseudo random number generator to use for probabilistic effects. |
qubits
|
Determines the canonical ordering of the qubits. This is often used in specifying the initial state, i.e. the ordering of the computational basis states. |
log_of_measurement_results
|
A mutable object that measurements are being recorded into. |
classical_data
|
The shared classical data container for this simulation. |
Attributes | |
---|---|
allows_factoring
|
Subclasses that allow factorization should override this. |
can_represent_mixed_states
|
|
classical_data
|
The shared classical data container for this simulation.. |
ignore_measurement_results
|
|
log_of_measurement_results
|
Gets the log of measurement results. |
prng
|
|
qubit_map
|
|
qubits
|
Gets the qubit order maintained by this target. |
state
|
Methods
apply_operation
apply_operation(
op: 'cirq.Operation'
)
copy
copy(
deep_copy_buffers: bool = True
) -> cirq.sim.act_on_args.TSelf
Creates a copy of the object.
Args | |
---|---|
deep_copy_buffers
|
If True, buffers will also be deep-copied. Otherwise the copy will share a reference to the original object's buffers. |
Returns | |
---|---|
A copied instance. |
create_merged_state
create_merged_state() -> cirq.sim.act_on_args.TSelf
Creates a final merged state.
factor
factor(
qubits: Sequence['cirq.Qid'], *, validate=True, atol=1e-07, inplace=False
) -> Tuple[cirq.sim.act_on_args.TSelf
, cirq.sim.act_on_args.TSelf
]
Splits two state spaces after a measurement or reset.
get_axes
get_axes(
qubits: Sequence['cirq.Qid']
) -> List[int]
kronecker_product
kronecker_product(
other: cirq.sim.act_on_args.TSelf
,
*,
inplace=False
) -> cirq.sim.act_on_args.TSelf
Joins two state spaces together.
measure
measure(
qubits: Sequence['cirq.Qid'], key: str, invert_mask: Sequence[bool]
)
Measures the qubits and records to log_of_measurement_results
.
Any bitmasks will be applied to the measurement record. If
self._ignore_measurement_results
is set, it dephases instead of
measuring, and no measurement result will be logged.
Args | |
---|---|
qubits
|
The qubits to measure. |
key
|
The key the measurement result should be logged under. Note
that operations should only store results under keys they have
declared in a _measurement_key_names_ method.
|
invert_mask
|
The invert mask for the measurement. |
Raises | |
---|---|
ValueError
|
If a measurement key has already been logged to a key. |
rename
rename(
q1: 'cirq.Qid', q2: 'cirq.Qid', *, inplace=False
)
Renames q1
to q2
.
Args | |
---|---|
q1
|
The qubit to rename. |
q2
|
The new name. |
inplace
|
True to rename the qubit in the current object, False to create a copy with the qubit renamed. |
Returns | |
---|---|
The original object with the qubits renamed if inplace is requested, or a copy of the original object with the qubits renamed otherwise. |
Raises | |
---|---|
ValueError
|
If the qubits are of different dimensionality. |
sample
@abc.abstractmethod
sample( qubits: List['cirq.Qid'], repetitions: int = 1, seed: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None ) -> np.ndarray
Samples the state value.
swap
swap(
q1: 'cirq.Qid', q2: 'cirq.Qid', *, inplace=False
)
Swaps two qubits.
This only affects the index, and does not modify the underlying state.
Args | |
---|---|
q1
|
The first qubit to swap. |
q2
|
The second qubit to swap. |
inplace
|
True to swap the qubits in the current object, False to create a copy with the qubits swapped. |
Returns | |
---|---|
The original object with the qubits swapped if inplace is requested, or a copy of the original object with the qubits swapped otherwise. |
Raises | |
---|---|
ValueError
|
If the qubits are of different dimensionality. |
transpose_to_qubit_order
transpose_to_qubit_order(
qubits: Sequence['cirq.Qid'], *, inplace=False
) -> cirq.sim.act_on_args.TSelf
Physically reindexes the state by the new basis.
Args | |
---|---|
qubits
|
The desired qubit order. |
inplace
|
True to perform this operation inplace. |
Returns | |
---|---|
The state with qubit order transposed and underlying representation updated. |
Raises | |
---|---|
ValueError
|
If the provided qubits do not match the existing ones. |
with_qubits
with_qubits(
qubits
) -> cirq.sim.act_on_args.TSelf
Extend current state space with added qubits.
The state of the added qubits is the default value set in the subclasses. A new state space is created as the Kronecker product of the original one and the added one.
Args | |
---|---|
qubits
|
The qubits to be added to the state space. |
Regurns:
A new subclass object containing the extended state space.
__getitem__
__getitem__(
item: Optional['cirq.Qid']
) -> cirq.sim.act_on_args.TSelf
Gets the item associated with the qubit.
__iter__
__iter__() -> Iterator[Optional['cirq.Qid']]
Iterates the keys of the mapping.
__len__
__len__() -> int
Gets the number of items in the mapping.