qrisp.QuantumCircuit.statevector_array#

QuantumCircuit.statevector_array()[source]#

Performs a simulation of the statevector of self and returns a numpy array of complex numbers.

Note

Qrisps qubit ordering convention is reversed when compared to Qiskit, because of simulation efficiency reasons. As a rule of thumb you can remember:

The statevector array of the following circuit has the amplitude 1 at the index 0010 = 2

qb.0: ─────

qb.1: ─────
      ┌───┐
qb.2: ┤ X ├
      └───┘
qb.3: ─────
Returns:
numpy.ndarray

The statevector of this circuit.

Examples

We create a QuantumCircuit, perform some operations and retrieve the statevector array.

>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(4)
>>> qc.h(qc.qubits)
>>> qc.z(-1)
>>> qc.statevector_array()
array([ 0.24999997+0.j, -0.24999997+0.j,  0.24999997+0.j, -0.24999997+0.j,
        0.24999997+0.j, -0.24999997+0.j,  0.24999997+0.j, -0.24999997+0.j,
        0.24999997+0.j, -0.24999997+0.j,  0.24999997+0.j, -0.24999997+0.j,
        0.24999997+0.j, -0.24999997+0.j,  0.24999997+0.j, -0.24999997+0.j],
      dtype=complex64)