Open kwccoin opened 1 year ago
I test the change to the code
cnot_re=re.compile('^(cx|cy|cz) (q\[[0-4]\]), (q\[[0-4]\])$')
for l in lines:
l=l.strip()
if not l: continue
# CNOT operates on two qubits so gets special processing
cnot=cnot_re.match(l)
if cnot:
control_qubit=cnot.group(2)
target_qubit=cnot.group(3)
It should be fine of course that means cy and cz now all cx which is not right.
However to do cy and cz require touching the Gate Class. A lot of not sure about this why there is a need to change basis (see wiki CNOT especially the one on 2 bit using H as its own inverse (See (H1 ⊗ H1)−1 . CNOT . (H1 ⊗ H1)) to H2 . CNOT . H2 which is in the logic. But why CNOT 0->1 use simple logic and CNOT 1-> 0 not. Still working on it. Also the whole class is handcrafted; need some programming as said in the "TODO" section but that is 7 years ago.
Possibly above my "pay grade"!
Minor: On the section about "Working with Individual States and gates", one minor issue is that the qc has to be either "qc.reset()" or redefine "qc = ...". I suspect the other issue can be handled.
Major: try to reproduce the circuit of teleport from quirk to composer. It can be done on the IBM openqasm 2.0 composer but not here. The issue is that there is no cz operator. I suspect one can amend these lines but not sure I am expert enough to try.
Somehow the cx in the first line need to increase to cover cy and cz and then apply the appropriate logic to it (the line l="..." for the "translation".
The regular expression might be easily fixed by changing into something like
and some change in logic of the "if cnot" so to use group 2 and 3 not 1 and 2 and use group 1 to handle cx/cy/cz
But the logic under self.apply_two_qubit_gate_CNOT is not that easy as it involved different way to handle cx/cy/cz gate change.