Exemplo n.º 1
0
 def circuit(a, b):
     qml.RY(a, wires=0)
     qml.RX(b, wires=1)
     qml.CNOT(wires=[0, 1])
     return [qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))]
def layer(W):
    qml.Rot(W[0, 0], W[0, 1], W[0, 2], wires=0)
    qml.Rot(W[1, 0], W[1, 1], W[1, 2], wires=1)
    qml.CNOT(wires=[0, 1])
Exemplo n.º 3
0
 def circuit(a, b, c):
     qml.RX(a, wires=0)
     qml.RY(b, wires=0)
     qml.CNOT(wires=[0, 1])
     qml.PhaseShift(c, wires=1)
     return qml.expval(qml.PauliX(0)), qml.expval(qml.PauliX(1))
Exemplo n.º 4
0
 def func(x, y):
     """My function docstring"""
     qml.RX(x, wires=0)
     qml.RY(y, wires=1)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0))
Exemplo n.º 5
0
def ansatz():
    qml.Rot(0.3, 1.8, 5.4, wires=1)
    qml.RX(-0.5, wires=0)
    qml.RY(0.5, wires=1)
    qml.CNOT(wires=[0, 1])
Exemplo n.º 6
0
 def func(x, y):
     # the U2 operation is not supported on default.qubit
     # and is decomposed.
     qml.U2(x, y, wires=0)
     qml.CNOT(wires=[0, 1])
     return qml.probs(wires=0)
Exemplo n.º 7
0
 def func(x, y):
     qml.RX(x, wires=0)
     qml.RY(y, wires=1)
     qml.CNOT(wires=[0, 1])
     m = qml.expval(qml.PauliZ(0))
     return qml.expval(qml.PauliX(1)), m
Exemplo n.º 8
0
 def circuit(x):
     qml.RX(x, wires=0)
     qml.RY(0.1, wires=1)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
Exemplo n.º 9
0
 def circuit():
     """Reference QNode"""
     qml.Hadamard(wires=0)
     qml.CNOT(wires=[0, 1])
     qml.QubitUnitary(U2, wires=[0, 1])
     return qml.expval(qml.PauliZ(0))
Exemplo n.º 10
0
 def ansatz():
     qml.CNOT(wires=[0, 1])
Exemplo n.º 11
0
 def ansatz():
     qml.Hadamard(wires=0)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliX(wires=1))
Exemplo n.º 12
0
 def circuit():
     qml.Hadamard(wires=[0])
     qml.CNOT(wires=[0, 1])
     return [qml.sample(qml.PauliZ(0)), qml.sample(qml.PauliX(1))]
Exemplo n.º 13
0
 def circuit(x, y):
     qml.RX(x, wires=[0])
     qml.RY(y, wires=[1])
     qml.CNOT(wires=[0, 1])
     return [qml.var(qml.PauliZ(0)), qml.probs(wires=[1])]
Exemplo n.º 14
0
 def circuit(x, y):
     qml.RX(x, wires=[0])
     qml.RY(y, wires=[1])
     qml.CNOT(wires=[0, 1])
     return qml.probs(wires=[0]), qml.probs(wires=[1])
Exemplo n.º 15
0
 def circuit(theta, phi):
     qml.RX(theta, wires=0)
     qml.RX(phi, wires=0)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))
Exemplo n.º 16
0
 def circuit():
     qml.RY(np.pi / 2, wires=[0])
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0) @ qml.Identity(1))
Exemplo n.º 17
0
    def y_rotation(yAngle):
        qml.Hadamard(wires=0)
        qml.CNOT(wires=[0, 1])
        qml.RY(yAngle, wires=0)

        return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
Exemplo n.º 18
0
 def circuit():
     qml.Hadamard(0)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
Exemplo n.º 19
0
 def func(x, y):
     qml.RX(x, wires=0)
     qml.RY(y, wires=1)
     qml.CNOT(wires=[0, 1])
     return 5
Exemplo n.º 20
0
 def circuit(params, wires):
     qml.Hadamard(0)
     qml.CNOT(wires=[0, 1])
Exemplo n.º 21
0
 def circuit(p1, p2=y, **kwargs):
     qml.RX(p1, wires=0)
     qml.RY(p2[0] * p2[1], wires=1)
     qml.RX(kwargs["p3"], wires=0)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
Exemplo n.º 22
0
 def circuit(params, wires, statement=None):
     if statement:
         qml.Hadamard(0)
     qml.CNOT(wires=[0, 1])
Exemplo n.º 23
0
 def func():
     qml.Hadamard(wires=0)
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0))
Exemplo n.º 24
0
 def circuit(params, wires, rounds=1):
     for i in range(rounds):
         qml.Hadamard(0)
         qml.CNOT(wires=[0, 1])
Exemplo n.º 25
0
def ansatz(var):
    qml.Rot(0.3, 1.8, 5.4, wires=1)
    qml.RX(var[0], wires=0)
    qml.RY(var[1], wires=1)
    qml.CNOT(wires=[0, 1])
Exemplo n.º 26
0
 def circuit():
     qml.RX(0.5, wires=wires[0 % n_wires])
     qml.RY(2.0, wires=wires[1 % n_wires])
     if n_wires > 1:
         qml.CNOT(wires=[wires[0], wires[1]])
     return [qml.expval(qml.PauliZ(wires=w)) for w in wires]
Exemplo n.º 27
0
 def ansatz(weights, **kwargs):
     qml.RX(weights[0], wires=0)
     qml.RY(weights[1], wires=1)
     qml.CNOT(wires=[0, 1])
Exemplo n.º 28
0
 def circuit(a, b):
     qml.RX(a, wires=[0])
     qml.RX(b, wires=[1])
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))
Exemplo n.º 29
0
 def circuit(a, b):
     qml.RX(a, wires=0)
     qml.RY(b, wires=1)
     qml.CNOT(wires=[0, 1])
     return qml.probs(wires=[1])
Exemplo n.º 30
0
 def circuit(x, y, z):
     qml.CNOT(wires=[0, 1])
     return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))