Phase and Reflection Operators¶
Phase and reflection operators implement conditional phase flips, global phases, Grover reflections and similar operations, and are widely used in quantum search and amplitude amplification algorithms.
Overview¶
Operator |
Operation |
Unitarity class |
|---|---|---|
|
Flip the phase when the specified registers are all zero |
SelfAdjoint |
|
Reflection about the |
SelfAdjoint |
|
Multiply by a complex global phase factor |
BaseOperator |
—
ZeroConditionalPhaseFlip (zero-conditional phase flip)¶
Operation: Applies a \(-1\) phase flip to the basis states when all of the specified registers have value zero.
Parameters: A list of register identifiers (list of names or list of IDs).
Mathematical representation:
Purpose: Building the Oracle in Grover’s algorithm. When the target state is |0...0⟩, this operator is exactly the phase Oracle.
import pysparq as ps
ps.System.clear()
ps.System.add_register("addr", ps.UnsignedInteger, 3)
ps.System.add_register("data", ps.UnsignedInteger, 4)
state = ps.SparseState()
ps.Hadamard_Int("addr", 3)(state)
# After loading, flip the phase when the data corresponding to addr is 0
ps.ZeroConditionalPhaseFlip(["data"])(state)
# A list of register names also works
ps.ZeroConditionalPhaseFlip(["addr", "data"])(state)
—
Reflection_Bool (reflection)¶
Operation: Reflection about the |0⟩ state, i.e. the core component of the Grover diffusion operator.
Parameters:
reg— target register (name or ID, or a list)inverse— whether to use the inverse reflection (optional, defaultFalse)
Mathematical representation:
Purpose: The diffusion operator in Grover’s algorithm is composed of Hadamard + Reflection + Hadamard.
ps.System.clear()
ps.System.add_register("q", ps.Boolean, 1)
state = ps.SparseState()
ps.Hadamard_Bool("q")(state)
# Reflection
ps.Reflection_Bool("q")(state)
—
GlobalPhase (global phase)¶
Operation: Multiplies the entire quantum state by a complex global phase factor.
Parameters: c — the complex phase factor.
Dagger: Multiplies by the complex conjugate.
Note: A global phase is unobservable in quantum mechanics, but in some algorithms (such as amplitude encoding, QDA) it must be tracked exactly.
import numpy as np
# Global phase rotation e^{iπ/4}
op = ps.GlobalPhase(np.exp(1j * np.pi / 4))
op(state)
# Undo
op.dag(state)