guppyalgos.primitives.subroutines.reflection¶
Reflection box.
Functions
|
Apply an externally controlled reflection about the all-zero state. |
|
Apply a Householder reflection about the all-zero state. |
Classes
Guppy struct representing a reflection operator. |
|
Externally controlled reflection about an all-zero register state. |
- class guppyalgos.primitives.subroutines.reflection.Reflection¶
Guppy struct representing a reflection operator.
The operator is
\[R = I - 2\lvert 0^n\rangle\langle 0^n\rvert\]and is used in the qubitization walk operator \(W = R L\).
- cnx_method¶
- class guppyalgos.primitives.subroutines.reflection.ReflectionCntrl¶
Externally controlled reflection about an all-zero register state.
The struct packages the decomposition needed to apply
cntrl_reflection_box()to an arbitraryn_qubitsregister. Itscomposemethod negates only the joint basis state \(\lvert 1\rangle\lvert 0^n\rangle\), where the first qubit is the external control. It therefore acts as the identity when that control is \(\lvert 0\rangle\) and as \(I - 2\lvert 0^n\rangle\!\langle 0^n\rvert\) when it is \(\lvert 1\rangle\).This callable wrapper is used by controlled qubitization to apply the reflection part of the walk operator conditionally. Both the external control and reflected register are borrowed and mutated in place.
- Variables:
cnx_method – Decomposition of an
n_qubits-controlled \(X\) used by the controlled reflection.
- cnx_method¶
- guppyalgos.primitives.subroutines.reflection.cntrl_reflection_box(control, qreg, cnx_box)¶
Apply an externally controlled reflection about the all-zero state.
This implements the joint operator
\[C(R) = \lvert 0\rangle\!\langle 0\rvert \otimes I + \lvert 1\rangle\!\langle 1\rvert \otimes \left(I - 2\lvert 0^n\rangle\!\langle 0^n\rvert\right),\]where the first subsystem is
controland the second isqreg. Equivalently, the amplitude of \(\lvert 1\rangle\lvert 0^n\rangle\) is negated and every other computational-basis amplitude is unchanged. Ifcontrolis in a superposition, this conditional sign becomes a relative phase and may entangle it withqreg.The qubits in
qregare implemented as open controls by conjugating them with \(X\). The resulting multi-controlled \(Z\) usesqregas its controls,controlas its target, andcnx_boxfor the underlying multi-controlled \(X\) decomposition. All arguments are borrowed and restored in place; the function allocates no persistent output register.- Parameters:
control (
qubit) – External control, active on \(\lvert 1\rangle\).qreg (
array[qubit,TypeVar(n_qubits, bound=nat)]) – Register reflected about \(\lvert 0^n\rangle\) when the external control is active.cnx_box (
Callable[[array[qubit,TypeVar(n_qubits, bound=nat)],qubit],None]) – Decomposition of ann_qubits-controlled \(X\), used to implement the multi-controlled \(Z\).
- Return type:
- guppyalgos.primitives.subroutines.reflection.reflection_box(qreg, cnx_box)¶
Apply a Householder reflection about the all-zero state.
The reflection operator is
\[R = I - 2\lvert 0^n\rangle\langle 0^n\rvert,\]where \(\lvert 0^n\rangle\) is the all-zero state and \(I\) is the identity operator. It flips the sign of the all-zero state and leaves all other states unchanged. For one qubit, \(R = -Z\).
The reflection is implemented using a multi-controlled \(Z\) gate with open controls, decomposed using
cnx_box. Thus, the gate is applied when every control qubit is in state \(\lvert 0\rangle\).- Return type: