atlas_q.grover.FunctionOracle#
- class atlas_q.grover.FunctionOracle(n_qubits, marking_fn, device='cuda', dtype=torch.complex128)[source]#
Bases:
OracleBaseOracle based on a marking function
Marks states where f(x) = True by applying phase flip. Implements O_f |x⟩ = (-1)^f(x) |x⟩
- Example:
# Mark state |5⟩ oracle = FunctionOracle(n_qubits=4, marking_fn=lambda x: x == 5)
Methods
apply(mps)Apply oracle by marking all states where marking_fn returns True
get_marked_count()Return number of marked items
mark(mps, state)Mark a specific basis state by flipping its phase
Methods