cirq.sim.ActOnDensityMatrixArgs

State and context for an operation acting on a density matrix.

Inherits From: ActOnArgs, OperationTarget

To act on this object, directly edit the target_tensor property, which is storing the density matrix of the quantum system with one axis per qubit.

target_tensor The state vector to act on, stored as a numpy array with one dimension for each qubit in the system. Operations are expected to perform inplace edits of this object.
available_buffer A workspace with the same shape and dtype as target_tensor. Used by operations that cannot be applied to target_tensor inline, in order to avoid unnecessary allocations.
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.
qid_shape The shape of the target tensor.
prng The pseudo random number generator to use for probabilistic effects.
log_of_measurement_results A mutable object that measurements are being recorded into.

log_of_measurement_results Gets the log of measurement results.
qubits Gets the qubit order maintained by this target.

Methods

apply_operation

View source

copy

View source

Creates a copy of the object.

create_merged_state

View source

Creates a final merged state.

factor

View source

Splits two state spaces after a measurement or reset.

get_axes

View source

kronecker_product

View source

Joins two state spaces together.

measure

View source

Adds a measurement result to the log.

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.

rename

View source

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

View source

Samples the state value.

swap

View source

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

View source

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.

__getitem__

View source

Gets the item associated with the qubit.

__iter__

View source

Iterates the keys of the mapping.

__len__

View source

Gets the number of items in the mapping.