Skip to main content
edited tags
Link
glS
  • 26.9k
  • 6
  • 35
  • 121
Source Link
user12910
  • 451
  • 1
  • 4
  • 9

How to get state vector from QasmSimulator in Qiskit

I'm currently able to get state vector in Qiskit using state_vector backend using something like :

backend = Aer.get_backend('statevector_simulator')
job = execute(qc, backend=backend, shots=1, memory=True)
job_result = job.result()
print(job_result.get_statevector(qc))

But now I would like to get state vector using qasm_backend, I have seen in the Qiskit doc this sample code :

backend = QasmSimulator()
backend_options = {"method": "statevector"}

# Circuit execution
job = execute(qc, backend, backend_options=backend_options)

So I tried this backend implementation then trying to get state vector with :

job_result = job.result()
print(job_result.get_statevector(qc))

But it still gives me an error saying that get_statevector is not available, what is the right way to do that ?

Thank you.