コード例 #1
0
 def _define_decompositions(self):
     """
     gate cu3(theta,phi,lambda) c, t
     { u1((lambda-phi)/2) t; cx c,t;
       u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
       u3(theta/2,phi,0) t;
     }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(2, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("u1", 1, 0, 1)
     decomposition.add_basis_element("u3", 1, 0, 3)
     decomposition.add_basis_element("cx", 2, 0, 0)
     rule = [
         U1Gate((self.params[2] - self.params[1]) / 2, q[1]),
         CnotGate(q[0], q[1]),
         U3Gate(-self.params[0] / 2, 0,
                -(self.params[1] + self.params[2]) / 2, q[1]),
         CnotGate(q[0], q[1]),
         U3Gate(self.params[0] / 2, self.params[1], 0, q[1])
     ]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #2
0
 def _define_decompositions(self):
     decomposition = DAGCircuit()
     q = QuantumRegister(1, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("U", 1, 0, 3)
     rule = [UBase(self.params[0], self.params[1], self.params[2], q[0])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #3
0
 def _define_decompositions(self):
     decomposition = DAGCircuit()
     q = QuantumRegister(1, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("u1", 1, 0, 1)
     rule = [U1Gate(pi, q[0])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #4
0
ファイル: ry.py プロジェクト: nonhermitian/ReNomQ
 def _define_decompositions(self):
     """
     gate ry(theta) a { u3(theta, 0, 0) a; }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(1, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("u3", 1, 0, 3)
     rule = [U3Gate(self.params[0], 0, 0, q[0])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #5
0
ファイル: h.py プロジェクト: nonhermitian/ReNomQ
 def _define_decompositions(self):
     """
     gate h a { u2(0,pi) a; }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(1, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("u2", 1, 0, 2)
     rule = [U2Gate(0, pi, q[0])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #6
0
 def _define_decompositions(self):
     """
     gate cx c,t { CX c,t; }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(2, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("CX", 2, 0, 0)
     rule = [CXBase(q[0], q[1])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #7
0
ファイル: cz.py プロジェクト: nonhermitian/ReNomQ
 def _define_decompositions(self):
     """
     gate cz a,b { h b; cx a,b; h b; }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(2, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("h", 1, 0, 0)
     decomposition.add_basis_element("cx", 2, 0, 0)
     rule = [HGate(q[1]), CnotGate(q[0], q[1]), HGate(q[1])]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #8
0
ファイル: rzz.py プロジェクト: nonhermitian/ReNomQ
 def _define_decompositions(self):
     """
     gate rzz(theta) a, b { cx a, b; u1(theta) b; cx a, b; }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(2, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("u1", 1, 0, 1)
     decomposition.add_basis_element("cx", 2, 0, 0)
     rule = [
         CnotGate(q[0], q[1]),
         U1Gate(self.params[0], q[0]),
         CnotGate(q[0], q[1])
     ]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #9
0
 def _define_decompositions(self):
     """
     gate cswap a,b,c
     { cx c,b;
       ccx a,b,c;
       cx c,b;
     }
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(3, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("cx", 2, 0, 0)
     decomposition.add_basis_element("ccx", 3, 0, 0)
     rule = [
         CnotGate(q[2], q[1]),
         ToffoliGate(q[0], q[1], q[2]),
         CnotGate(q[2], q[1])
     ]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]
コード例 #10
0
ファイル: ccx.py プロジェクト: nonhermitian/ReNomQ
 def _define_decompositions(self):
     """
     gate ccx a,b,c
     {
     h c; cx b,c; tdg c; cx a,c;
     t c; cx b,c; tdg c; cx a,c;
     t b; t c; h c; cx a,b;
     t a; tdg b; cx a,b;}
     """
     decomposition = DAGCircuit()
     q = QuantumRegister(3, "q")
     decomposition.add_qreg(q)
     decomposition.add_basis_element("h", 1, 0, 0)
     decomposition.add_basis_element("cx", 2, 0, 0)
     decomposition.add_basis_element("t", 1, 0, 0)
     decomposition.add_basis_element("tdg", 1, 0, 0)
     decomposition.add_basis_element("s", 1, 0, 0)
     decomposition.add_basis_element("sdg", 1, 0, 0)
     rule = [
         HGate(q[2]),
         CnotGate(q[1], q[2]),
         TdgGate(q[2]),
         CnotGate(q[0], q[2]),
         TGate(q[2]),
         CnotGate(q[1], q[2]),
         TdgGate(q[2]),
         CnotGate(q[0], q[2]),
         TGate(q[1]),
         TGate(q[2]),
         HGate(q[2]),
         CnotGate(q[0], q[1]),
         TGate(q[0]),
         TdgGate(q[1]),
         CnotGate(q[0], q[1])
     ]
     for inst in rule:
         decomposition.apply_operation_back(inst)
     self._decompositions = [decomposition]