How to calculate state fidelity in Qiskit?

I have a circuit with different structures, now I’m trying to calculate the fidelity between those with the original one. How do I calculate the fidelity? I want also to initialize the state vector by myself. Can someone show how to compute fidelity for the below example?

For example, if I have a circuit like below,

q = QuantumRegister(2)
qc = QuantumCircuit(q)
qc.cu1(3*pi/4, q[0], q[1]);
print(qc)

and different structure

q = QuantumRegister(2)
qc = QuantumCircuit(q)
qc.h(q[0]);
qc.h(q[1]);
qc.cu1(3*pi/4, q[0], q[1]);
qc.h(q[0]);
qc.h(q[1]);
print(qc)

Also I have to manually calculate fidelity using the matrices of the above circuit, can someone help?
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the Terms & Privacy policy.