A verifiable quantum advantage towards real world applications: Quantum Echoes
Learn more cirq.measure_state_vector
Performs a measurement of the state in the computational basis.
cirq.measure_state_vector( state_vector: np.ndarray, indices: Sequence[int], *, qid_shape: (tuple[int, ...] | None) = None, out: (np.ndarray | None) = None, seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None ) -> tuple[list[int], np.ndarray]
Used in the notebooks
This does not modify state unless the optional out is state.
Args |
state_vector | The state to be measured. This state vector is assumed to be normalized. The state vector must be of size 2 ** integer. The state vector can be of shape (2 ** integer) or (2, 2, ..., 2). |
indices | Which qubits are measured. The state_vector 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. |
qid_shape | The qid shape of the state_vector. Specify this argument when using qudits. |
out | An optional place to store the result. If out is the same as the state_vector parameter, then state_vector 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_vector if out is None, otherwise it will match the shape and dtype of out. |
seed | A seed for the pseudorandom number generator. |
Returns |
A tuple of a list and a 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 vector. This state vector has the same shape and dtype as the input state_vector. |
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. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]