cirq.measure_state_vector¶

cirq.
measure_state_vector
(state: numpy.ndarray, indices: List[int], out: numpy.ndarray = None) → Tuple[List[bool], numpy.ndarray][source]¶ Performs a measurement of the state in the computational basis.
This does not modify
state
unless the optionalout
isstate
.Parameters:  state – The state to be measured. This state is assumed to be normalized. The state must be of size 2 ** integer. The state can be of shape (2 ** integer) or (2, 2, …, 2).
 indices – Which qubits are measured. The state is assumed to be supplied in big endian order. That is the xth index of v, when expressed as a bitstring, has the largest values in the 0th index.
 out – An optional place to store the result. If out is the same as the state parameter, then state will be modified inline. If out is not None, then the result is put into out. If out is None a new value will be allocated. In all of these case out will be the same as the returned ndarray of the method. The shape and dtype of out will match that of state if out is None, otherwise it will match the shape and dtype of out.
Returns: A tuple of a list and an numpy array. The list is an array of booleans corresponding to the measurement values (ordered by the indices). The numpy array is the post measurement state. This state has the same shape and dtype as the input state.
Raises:  ValueError if the size of state is not a power of 2.
 IndexError if the indices are out of range for the number of qubits – corresponding to the state.