atlas_q.grover.FunctionOracle#

class atlas_q.grover.FunctionOracle(n_qubits, marking_fn, device='cuda', dtype=torch.complex128)[source]#

Bases: OracleBase

Oracle 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

__init__(n_qubits, marking_fn, device='cuda', dtype=torch.complex128)[source]#

Methods

__init__(n_qubits, marking_fn[, device, dtype])

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

apply(mps)[source]#

Apply oracle by marking all states where marking_fn returns True

Returns:

New MPS after oracle application