How to use the pennylane.RX function in PennyLane

To help you get started, we’ve selected a few PennyLane examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XanaduAI / pennylane / tests / test_tf.py View on Github external
def circuit(w, x=None):
            qml.RX(w, wires=[0])
            qml.RX(x, wires=[1])
            return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))
github XanaduAI / pennylane / tests / qnode_new / test_qnode_base.py View on Github external
def non_mutable_circuit(x, *, c=None):
            qml.RX(x, wires=0)
            qml.RX(c, wires=0)
            return qml.expval(qml.PauliZ(0))
github XanaduAI / pennylane / tests / test_qnode.py View on Github external
def circuit(x):
            qml.RX(x, wires=[0])
            qml.CNOT(wires=[0, 1])
            return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)), qml.expval(qml.PauliX(0))
github XanaduAI / pennylane / tests / qnodes / test_qnode_metric_tensor.py View on Github external
def circuit(a):
            qml.RX(a, wires=0)
            return qml.expval(qml.PauliX(0))
github XanaduAI / pennylane / tests / qnode_new / test_qnode_base.py View on Github external
def circuit(x, y):
            qml.RX(x, wires=[0])
            qml.RY(y, wires=[1])
            qml.CNOT(wires=[0, 1])
            return qml.sample(qml.PauliZ(0) @ qml.PauliX(1))
github XanaduAI / pennylane / tests / qnodes / test_qnode_decorator.py View on Github external
def circuit(a):
        qml.RX(a, wires=0)
        return qml.expval(qml.PauliZ(wires=0))
github rigetti / pennylane-forest / tests / test_qpu.py View on Github external
def circuit_Zpl():
            qml.RX(0.0, wires=qubit)
            return qml.expval(qml.PauliZ(qubit))
github XanaduAI / pennylane-cirq / tests / test_var.py View on Github external
varphi = -0.543

        dev = device(3)

        obs = (
            qml.PauliZ(wires=[0], do_queue=False)
            @ qml.Hadamard(wires=[1], do_queue=False)
            @ qml.PauliY(wires=[2], do_queue=False)
        )

        with mimic_execution_for_var(dev):
            dev.apply(
                [
                    qml.RX(theta, wires=[0]),
                    qml.RX(phi, wires=[1]),
                    qml.RX(varphi, wires=[2]),
                    qml.CNOT(wires=[0, 1]),
                    qml.CNOT(wires=[1, 2]),
                ],
                rotations=obs.diagonalizing_gates(),
            )

        res = dev.var(obs)

        expected = (
            3
            + np.cos(2 * phi) * np.cos(varphi) ** 2
            - np.cos(2 * theta) * np.sin(varphi) ** 2
            - 2 * np.cos(theta) * np.sin(phi) * np.sin(2 * varphi)
        ) / 4

        assert np.allclose(res, expected, **tol)
github XanaduAI / pennylane / tests / qnodes / test_qnode_qubit.py View on Github external
def circuit4(a, b, c):
            qml.RX(b, wires=0)
            qml.RX(c, wires=1)
            return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))
github XanaduAI / pennylane / examples / pennylane_run_state_preparation.py View on Github external
def layer(params, j):
    for i in range(nr_qubits):
        qml.RX(params[i, j, 0], wires=i)
        qml.RY(params[i, j, 1], wires=i)
        qml.RZ(params[i, j, 2], wires=i)

    qml.CNOT(wires=[0, 1])
    qml.CNOT(wires=[0, 2])
    qml.CNOT(wires=[1, 2])

PennyLane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.

Apache-2.0
Latest version published 3 days ago

Package Health Score

87 / 100
Full package analysis