How to use the pennylane.Displacement 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 / qnodes / test_qnode_decorator.py View on Github external
def circuit(a):
        qml.Displacement(a, 0, wires=0)
        return qml.expval(qml.X(wires=0))
github XanaduAI / pennylane-sf / tests / test_gaussian.py View on Github external
def circuit(a, phi):
            qml.Displacement(a, phi, wires=1)
            return qml.probs(wires=1)
github XanaduAI / pennylane-sf / tests / test_fock.py View on Github external
def circuit(n, a):
            qml.ThermalState(n, wires=0)
            qml.Displacement(a, 0, wires=0)
            return qml.var(qml.NumberOperator(0))
github XanaduAI / pennylane / tests / test_default_gaussian.py View on Github external
def circuit(x):
            """Test quantum function"""
            qml.Displacement(x, 0, wires=0)
            return qml.expval(qml.X(0))
github XanaduAI / pennylane-sf / tests / test_gaussian.py View on Github external
def circuit(x):
            qml.Displacement(x, 0, wires=0)
            return qml.expval(qml.NumberOperator(0))
github XanaduAI / pennylane / tests / qnodes / test_qnode_cv.py View on Github external
def circuit(x):
                qml.Displacement(x, 0, wires=0)

                if cls.par_domain == "A":
                    cls(U, wires=w)
                else:
                    cls(wires=w)
                return qml.expval(qml.X(0))
github XanaduAI / pennylane / tests / qnodes / test_qnode_cv.py View on Github external
def qf(x, y):
            qml.Displacement(x, 0, wires=[0])
            qml.Displacement(1.2, y, wires=[1])
            qml.Beamsplitter(0.2, 1.7, wires=[0, 1])
            qml.Rotation(1.9, wires=[0])
            qml.Kerr(0.3, wires=[1])  # nongaussian succeeding both x and y due to the beamsplitter
            return qml.expval(qml.X(0)), qml.expval(qml.X(1))
github XanaduAI / pennylane / tests / test_operation.py View on Github external
def mean_photon_gaussian(mag_alpha, phase_alpha, phi):
            qml.Displacement(mag_alpha, phase_alpha, wires=0)
            qml.Rotation(phi, wires=0).inv()
            return qml.expval(qml.NumberOperator(0))
github XanaduAI / qml / demonstrations / tutorial_gaussian_transformation.py View on Github external
def mean_photon_gaussian(mag_alpha, phase_alpha, phi):
    qml.Displacement(mag_alpha, phase_alpha, wires=0)
    qml.Rotation(phi, wires=0)
    return qml.expval(qml.NumberOperator(0))
github XanaduAI / pennylane-sf / demos / quantum_neural_net.py View on Github external
def layer(w):
    """ Single layer of the continuous-variable quantum neural net."""

    # Bias
    qml.Displacement(w[0], w[1], [0])

    # Matrix multiplication of input layer
    qml.Rotation(w[2], [0])
    qml.Squeezing(w[3], w[4], [0])
    qml.Rotation(w[5], [0])

    # Element-wise nonlinear transformation
    qml.Kerr(w[6], [0])

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 20 days ago

Package Health Score

87 / 100
Full package analysis