1

I am newly using Qiskit to learn quantum computing. Now I want to know if there is any way to make this:

For instance, I obtain an array X, where each element is sum of something else, say X[0] = y[0][0]+y[0][1]+...+y[0][m], X[1] = y[1][0]+y[1][1]+..., ..., till X[n], each element in X is obtained in one iteration. The task is to find a certain X[i] == k.

Then should I finish all the iterations before Grover's iterates? I have read some textbooks and papers where oracles are constructed by some binary function marking target states as 1 with conditions. What I can do now in Qiskit as I know, is to mark the index indicating the position of target element like

from qiskit.circuit.library import Diagonal
from qiskit.quantum_info import Statevector 
mark_state = Statevector.from_label('100')
mark_circuit = Diagonal((-1)**mark_state.data) # circuit that induces a -1 phase on the mark_state

That's in Qiskit Terra. Another way in Qiskit Aqua is to call APIs of Oracles and Grover, but Oracles only accept logical expression, truth table and custom circuit: construction of any one needs to know the exact X and location of the X[i] as I understand.

All I want to do is to illustrate the quadric advantage taken by Grover's algorithm. If it's possible, the iterations shouldn't be traversed, at least outside the oracle, but then how to implement it in code?

Zaragoss
  • 11
  • 4

0 Answers0