ket.qulib.oracle¶
Quantum oracles.
Functions ket.qulib.oracle
¶
|
Transform qubits from \(\ket{\texttt{state}}\) to \(-\ket{\texttt{state}}\). |
|
Create an inefficient xor oracle for a given function. |
- phase_oracle(state: int, qubits: Quant | None = None) Quant | Callable[[Quant], Quant] ¶
Transform qubits from \(\ket{\texttt{state}}\) to \(-\ket{\texttt{state}}\).
This gate is useful for marking states in Grover’s algorithm.
- xor_oracle(func)¶
Create an inefficient xor oracle for a given function.
This oracle will compute the xor of the function’s output with the input. The function must take an integer input and return an integer output.
\[\left|x\right>\left|y\right> \mapsto \left|x\right>\left|y \oplus f(x)\right>\]Example:
def my_function(x: int) -> int: return x + 1 oracle = xor_oracle(my_function) oracle(x, y)
- Parameters:
func – Function to create the oracle for.
- Returns:
Oracle that computes the xor of the function’s output with the input.