cirq.qis.QuantumState

A quantum state.

Can be a state vector, a state tensor, or a density matrix.

data The data representing the quantum state.
qid_shape The qid shape.
validate Whether to check if the given data and qid shape represent a valid quantum state with the given dtype.
dtype The expected data type of the quantum state.
atol Absolute numerical tolerance to use for validation.

ValueError The qid shape was not specified and could not be inferred.
ValueError Invalid quantum state.

data The data underlying the quantum state.
dtype The data type of the quantum state.
qid_shape The qid shape of the quantum state.

Methods

density_matrix

View source

Return the density matrix of this state.

A density matrix stores the entries of a density matrix as a matrix (a two-dimensional array).

state_tensor

View source

Return the state tensor of this state.

A state tensor stores the amplitudes of a pure state as an array with shape equal to the qid shape of the state. If the state is a density matrix, this method returns None.

state_vector

View source

Return the state vector of this state.

A state vector stores the amplitudes of a pure state as a one-dimensional array. If the state is a density matrix, this method returns None.

state_vector_or_density_matrix

View source

Return the state vector or density matrix of this state.

If the state is a denity matrix, return the density matrix. Otherwise, return the state vector.

validate

View source

Check if this quantum state is valid.

Args
dtype The expected data type of the quantum state.
atol Absolute numerical tolerance to use for validation.

Raises
ValueError Invalid quantum state.