|View source on GitHub|
Verifies the state_rep is valid and converts it to ndarray form.
cirq.qis.to_valid_state_vector( state_rep: "cirq.STATE_VECTOR_LIKE", num_qubits: Optional[int] = None, *, qid_shape: Optional[Sequence[int]] = None, dtype: Optional['DTypeLike'] = None, atol: float = 1e-07 ) -> np.ndarray
This method is used to support passing in an integer representing a computational basis state or a full state vector as a representation of a pure state.
||If an int, the state vector returned is the state vector corresponding to a computational basis state. If a numpy array this is the full state vector. Both of these are validated for the given number of qubits, and the state must be properly normalized and of the appropriate dtype.|
||The number of qubits for the state vector. The state_rep must be valid for this number of qubits.|
||The expected qid shape of the state vector. Specify this argument when using qudits.|
||The numpy dtype of the state vector, will be used when creating the state for a computational basis state, or validated against if state_rep is a numpy array.|
||Numerical tolerance for verifying that the norm of the state vector is close to 1.|
|A numpy ndarray corresponding to the state vector on the given number of qubits.|