Esempio n. 1
0
qc.h(q[1])
qc.h(q[2])

# Step B: entangle the test example with the ground state of the ancilla
# qc.cry(2 * math.acos(-0.8448179), q[0], q[3])
# qc.cry(2 * (2 * pi - math.acos(-0.36817031)), q[0], q[3])
qc.cry(2 * math.acos(-0.36817031), q[0], q[3])
qc.cz(q[0], q[3])
# qc.crz(math.pi, q[0], q[3])
qc.x(q[0])

# Step C: entangle the first trainning example with the excited state of the ancilla and the ground states of the two index qubits
# qc.cccry(2 * (2 * pi - math.acos(-0.99407732)), q[0], q[1], q[2], q[3])
qc.cccry(2 * math.acos(-0.99407732), q[0], q[1], q[2], q[3])
# qc.cccrz(math.pi, q[0], q[1], q[2], q[3])
qc.cccz(q[0], q[1], q[2], q[3])
qc.x(q[1])
qc.x(q[2])

# Step D: entangle the second trainning example with the excited state of the ancilla and the LSB and the ground state of the MSB of the index qubits
qc.cccry(2 * math.acos(-0.30654501), q[0], q[1], q[2], q[3])
qc.cx(q[1], q[2])
qc.swap(q[1], q[2])

# Step E: entangle the third trainning example with the excited state of the ancilla and the MSB and the ground state of the LSB of the index qubits
# qc.cccry(2 * (2 * pi - math.acos(-0.92072409)), q[0], q[1], q[2], q[3])
qc.cccry(2 * math.acos(-0.92072409), q[0], q[1], q[2], q[3])
# qc.cccrz(math.pi, q[0], q[1], q[2], q[3])
qc.cccz(q[0], q[1], q[2], q[3])
qc.cx(q[1], q[2])