Circuit.get_statevector
- Circuit.get_statevector(in_state, params=[])[source]
Return the result of applying self to in_state
- Parameters:
params (
RealVector
) – Optionally specify parameters overriding the ones stored in the circuit. (Default: use parameters already in circuit.)- Returns:
The StateVector object for the new state after the circuit
- Raises:
ValueError – If parameters are specified and invalid.
- Return type:
Examples
>>> from bqskit.ir.gates import HGate >>> circ = Circuit(1) >>> op = Operation(HGate(), [0]) >>> circ.append(op) >>> V = StateVector([1,0]) >>> np.allclose(circ.get_statevector(V), np.array([1,1])/np.sqrt(2)) True