Esempio n. 1
0
def canonical_matrix(a=0.0, b=0.0, c=0.0):
    """
    Produces the matrix form of a "canonical operator"

        exp(-i (a XX + b YY + c ZZ)) .
    """
    return RXXGate(2 * a).to_matrix() @ RYYGate(2 * b).to_matrix() @ RZZGate(-2 * c).to_matrix()
    def test_cswap_rzz(self):
        """Test controlled swap and rzz gates"""
        qr = QuantumRegister(5, "q")
        circuit = QuantumCircuit(qr)
        circuit.cswap(0, 1, 2)
        circuit.append(RZZGate(3 * pi / 4).control(3, ctrl_state="010"), [2, 1, 4, 3, 0])

        self.circuit_drawer(circuit, filename="cswap_rzz.png")
Esempio n. 3
0
    def test_cswap_rzz(self):
        """Test controlled swap and rzz gates"""
        filename = self._get_resource_path('test_latex_cswap_rzz.tex')
        qr = QuantumRegister(5, 'q')
        circuit = QuantumCircuit(qr)
        circuit.x(0)
        circuit.x(1)
        circuit.cswap(0, 1, 2)
        circuit.append(RZZGate(3 * pi / 4).control(3, ctrl_state='010'), [2, 1, 4, 3, 0])

        circuit_drawer(circuit, filename=filename, output='latex_source')

        self.assertEqualToReference(filename)