(nC: int, nQ: int, statePrep: Callable[[cudaq.qubit], None],
oracle: Callable[[cudaq.qubit], None])
| 64 | |
| 65 | @cudaq.kernel |
| 66 | def qpe(nC: int, nQ: int, statePrep: Callable[[cudaq.qubit], None], |
| 67 | oracle: Callable[[cudaq.qubit], None]): |
| 68 | q = cudaq.qvector(nC + nQ) |
| 69 | countingQubits = q.front(nC) |
| 70 | stateRegister = q.back() |
| 71 | statePrep(stateRegister) |
| 72 | h(countingQubits) |
| 73 | for i in range(nC): |
| 74 | for j in range(2**i): |
| 75 | cudaq.control(oracle, [countingQubits[i]], stateRegister) |
| 76 | iqft(countingQubits) |
| 77 | mz(countingQubits) |
| 78 | |
| 79 | cudaq.set_random_seed(13) |
| 80 | counts = cudaq.sample(qpe, 3, 1, xGate, tGate) |