to_valid_state_vector(state_rep: Union[int, numpy.ndarray], num_qubits: int, dtype: Type[numpy.number] = <class 'numpy.complex64'>) → numpy.ndarray¶
Verifies the state_rep is valid and converts it to ndarray form.This method is used to support passing in an integer representing acomputational basis state or a full wave function as a representation ofa state.
- state_rep – If an int, the state returned is the state corresponding to a computational basis state. If an numpy array this is the full wave function. Both of these are validated for the given number of qubits, and the state must be properly normalized and of the appropriate dtype.
- num_qubits – The number of qubits for the state. The state_rep must be valid for this number of qubits.
- dtype – The numpy dtype of the state, will be used when creating the state for a computational basis state, or validated against if state_rep is a numpy array.
A numpy ndarray corresponding to the state on the given number of qubits.
ValueError if the state is not valid.