Esempio n. 1
0
 def testresolve(self, gate_from, gate_to, targets, controls):
     qc1 = QubitCircuit(2)
     qc1.add_gate(gate_from, targets=targets, controls=controls)
     U1 = gates.gate_sequence_product(qc1.propagators())
     qc2 = qc1.resolve_gates(basis=gate_to)
     U2 = gates.gate_sequence_product(qc2.propagators())
     assert _op_dist(U1, U2) < 1e-12
Esempio n. 2
0
 def testFREDKINdecompose(self):
     """
     FREDKIN to rotation and CNOT: compare unitary matrix for FREDKIN and product of
     resolved matrices in terms of rotation gates and CNOT.
     """
     qc1 = QubitCircuit(3)
     qc1.add_gate("FREDKIN", targets=[0, 1], controls=[2])
     U1 = gates.gate_sequence_product(qc1.propagators())
     qc2 = qc1.resolve_gates()
     U2 = gates.gate_sequence_product(qc2.propagators())
     assert _op_dist(U1, U2) < 1e-12
Esempio n. 3
0
 def testSNOTdecompose(self):
     """
     SNOT to rotation: compare unitary matrix for SNOT and product of
     resolved matrices in terms of rotation gates.
     """
     qc1 = QubitCircuit(1)
     qc1.add_gate("SNOT", targets=0)
     U1 = gates.gate_sequence_product(qc1.propagators())
     qc2 = qc1.resolve_gates()
     U2 = gates.gate_sequence_product(qc2.propagators())
     assert _op_dist(U1, U2) < 1e-12