Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def circuit(x):
qml.RX(x, wires=[0])
qml.CNOT(wires=[0, 1], do_queue=False)
qml.RY(0.4, wires=[0])
qml.RZ(-0.2, wires=[1], do_queue=False)
return qml.expval(qml.PauliX(0)), qml.expval(qml.PauliZ(1))
def circuit(a):
qml.RX(a, wires=0)
qml.RY(a, wires=0)
return qml.var(qml.PauliZ(0))
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))
def circuit2(a, b):
qml.RX(a, wires=0)
qml.RY(b, wires=0)
return qml.expval(qml.PauliZ(wires=0))
def qf(x, y):
qml.RX(x, wires=[0])
qml.RY(x, wires=[0])
return qml.expval(qml.Hermitian(np.diag([y, 1]), 0))
def layer2_diag(x, y, z, h, g, f):
non_parametrized_layer(a, b, c)
qml.RX(x, wires=0)
qml.RY(y, wires=1)
qml.RZ(z, wires=2)
non_parametrized_layer(a, b, c)
qml.RY(f, wires=2)
return qml.var(qml.PauliX(1))
def quant_fun_flat(var):
qml.RX(var[0], wires=[0])
qml.RY(var[1], wires=[0])
qml.RY(var[2], wires=[0])
qml.RX(var[3], wires=[0])
return qml.expval(qml.PauliZ(0))
def RY_layer(w):
"""Layer of parametrized qubit rotations around the y axis.
"""
for idx, element in enumerate(w):
qml.RY(element, wires=idx)
def U_c():
"""Unitary matrix rotating the ground state of the ancillary qubits
to |sqrt(c)> = U_c |0>."""
# Circuit mapping |00> to sqrt_c[0] |00> + sqrt_c[1] |01> + sqrt_c[2] |10>
qml.RY(-2 * np.arccos(sqrt_c[0]), wires=ancilla_idx)
qml.CRY(-2 * np.arctan(sqrt_c[2] / sqrt_c[1]), wires=[ancilla_idx, ancilla_idx + 1])
qml.CNOT(wires=[ancilla_idx + 1, ancilla_idx])
def statepreparation(a):
qml.RY(a[0], wires=0)
qml.CNOT(wires=[0, 1])
qml.RY(a[1], wires=1)
qml.CNOT(wires=[0, 1])
qml.RY(a[2], wires=1)
qml.PauliX(wires=0)
qml.CNOT(wires=[0, 1])
qml.RY(a[3], wires=1)
qml.CNOT(wires=[0, 1])
qml.RY(a[4], wires=1)
qml.PauliX(wires=0)