예제 #1
0
 def circuit(x=None):
     qml.DisplacementEmbedding(features=x, wires=range(n_wires), method="phase", c=1.0)
     qml.Beamsplitter(np.pi / 2, 0, wires=[0, 1])
     qml.DisplacementEmbedding(features=[0, 0], wires=range(n_wires), method="phase", c=1.0)
     return [
         qml.expval(qml.NumberOperator(wires=0)),
         qml.expval(qml.NumberOperator(wires=1)),
     ]
예제 #2
0
    def test_expansion(self, features):
        """Checks the queue for the default settings."""

        op = qml.DisplacementEmbedding(features=features, wires=range(3))
        tape = op.expand()

        assert len(tape.operations) == len(features)
        for idx, gate in enumerate(tape.operations):
            assert gate.name == "Displacement"
            assert gate.parameters[0] == features[idx]
예제 #3
0
 def circuit2():
     qml.DisplacementEmbedding(features, wires=["z", "a", "k"])
     return qml.expval(qml.Identity("z"))
예제 #4
0
 def circuit():
     qml.DisplacementEmbedding(features, wires=range(3))
     return qml.expval(qml.Identity(0))
예제 #5
0
 def circuit(x=None):
     qml.DisplacementEmbedding(features=x, wires=range(n_wires), method="amplitude", c=1.0)
     return [
         qml.expval(qml.NumberOperator(wires=0)),
         qml.expval(qml.NumberOperator(wires=1)),
     ]
예제 #6
0
def circuit_template(features):
    qml.DisplacementEmbedding(features, range(3))
    qml.Beamsplitter(0.5, 0, wires=[2, 1])
    qml.Beamsplitter(0.5, 0, wires=[1, 0])
    return qml.expval(qml.X(0))
예제 #7
0
 def test_id(self):
     """Tests that the id attribute can be set."""
     template = qml.DisplacementEmbedding(np.array([1, 2]), wires=[0, 1], id="a")
     assert template.id == "a"
예제 #8
0
 def circuit(x=None):
     qml.DisplacementEmbedding(features=x, wires=[0, 1])
     return qml.expval(qml.X(0))
예제 #9
0
 def circuit(x=None):
     qml.DisplacementEmbedding(features=x, wires=range(n_wires), method="A")
     return [qml.expval(qml.X(i)) for i in range(n_wires)]