qc.cry(2 * math.acos(-0.26461538), q[0], q[2]) # qc.cry(2 * (2 * pi - math.acos(-0.23192983)), q[0], q[2]) # qc.cry(2 * math.acos(-0.23192983), q[0], q[2]) # qc.crz(math.pi, q[0], q[2]) # qc.cz(q[0], q[2]) qc.x(q[0]) # Step C: entangle the training data with the excited state of the ancilla and the ground state of the index qubit qc.ccry(2 * math.acos(-0.65752458), q[0], q[1], q[2]) qc.x(q[1]) # Step D: entangle the training data with the excited state of the ancilla and of the index qubit # qc.ccry(2 * (2 * pi - math.acos(0.92790088)), q[0], q[1], q[2]) qc.ccry(2 * math.acos(0.92790088), q[0], q[1], q[2]) # qc.ccrz(math.pi, q[0], q[1], q[2]) qc.ccz(q[0], q[1], q[2]) # Step E: Swap the data and the class qubits (due to the topology of IBM 5 QX) # and the class qubit is flipped given the index qubit is 1 qc.swap(q[2], q[3]) qc.cx(q[1], q[2]) # Step F: Hadamard gate on the ancilla qubit and measurement qc.h(q[0]) # Measurement qc.barrier(q) qc.measure(q[0], c[3]) qc.measure(q[1], c[2]) qc.measure(q[2], c[1]) qc.measure(q[3], c[0])