0
$\begingroup$

When you have a quantum circuit and use QuantumCircuit.data you get a list with objects of this type (this is the one for a X gate acting on qubit 0 y a 2 qubits Quantum Circuit):

(qiskit.extensions.standard.x.XGate object at 0x0000019B8DEC2EB8, [Qubit(QuantumRegister(2, 'q'), 0)], [])

The first element represents the operation. What does the sequence of digits 0x0000019B8DEC2EB8 mean? I suppose it has something to do with the location or the time, but I do not know how to obtain each digit. I need to know exactly how to reproduce one of these sequences myself.

Thank you so much in advance.

$\endgroup$
0
$\begingroup$

That is the address in memory (represented as a hexademical number) of that specific gate object. It can be used to differentiate that specific X gate object from a different X gate object. Other than that it general is not useful, and it's definitely not something you would ever need to manually reproduce.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thank you! Really good explanation. $\endgroup$ – Paula G Mar 4 at 19:08
1
$\begingroup$

These numbers are memory addresses of the Gate objects in python. Instances of any python class will have them (though they may not always be shown):

>>> class B():
...   def __init__(self):
...     pass
...
>>> B()
<__main__.B object at 0x106e63d30>
>>> B()
<__main__.B object at 0x106e63da0>

They don't have any meaning in the context of the QuantumCircuit and they'll essentially be random every time you recreate your circuit. (Really, they shouldn't be included in the display of the Gate object).

Why do you need to know how to reproduce these sequences? There's probably another way to accomplish your goal.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ I need a way to identify that this information corresponds to the x gate so I can use a conditional if to assign the corresponding x matrix to a new variable x=np.array([0,1],[1,0]). I have managed to do this using qasm. The problem comes when you have, for example, a u3 gate as qasm gives you a string of the form u3(3.14159265358979,3.14159265358979,3.14159265358979) (for qc.u3(np.pi,np.pi,np.pi,0)). So this is not a list but a string so I have to extract the corresponding numbers and convert their corresponding string to floats. $\endgroup$ – Paula G Mar 4 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.