cirq.final_wavefunction

cirq.final_wavefunction(program: cirq.CIRCUIT_LIKE, *, initial_state: Union[int, Sequence[Union[int, float, complex]], numpy.ndarray] = 0, param_resolver: Union[cirq.ParamResolver, Dict[Union[str, sympy.core.symbol.Symbol], Union[float, str, sympy.core.basic.Basic]], None] = None, qubit_order: Union[cirq.ops.qubit_order.QubitOrder, Iterable[cirq.ops.raw_types.Qid]] = <cirq.ops.qubit_order.QubitOrder object>, dtype: Type[numpy.number] = <class 'numpy.complex64'>, seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None) → np.ndarray[source]

Returns the state vector resulting from acting operations on a state.

By default the input state is the computational basis zero state, in which
case the output is just the first column of the implied unitary matrix.
Parameters
  • program – The circuit, gate, operation, or tree of operations to apply to the initial state in order to produce the result.

  • param_resolver – Parameters to run with the program.

  • qubit_order – Determines the canonical ordering of the qubits. This is often used in specifying the initial state, i.e. the ordering of the computational basis states.

  • initial_state – If an int, the state is set to the computational basis state corresponding to this state. Otherwise if this is a np.ndarray it is the full initial state. In this case it must be the correct size, be normalized (an L2 norm of 1), and be safely castable to an appropriate dtype for the simulator.

  • dtype – The numpy.dtype used by the simulation. Typically one of numpy.complex64 or numpy.complex128.

  • seed – The random seed to use for this simulator.

Returns

The wavefunction resulting from applying the given unitary operations to the desired initial state. Specifically, a numpy array containing the the amplitudes in np.kron order, where the order of arguments to kron is determined by the qubit order argument (which defaults to just sorting the qubits that are present into an ascending order).