qrisp.quantum_backtracking.QuantumBacktrackingTree.qstep_diffuser#

QuantumBacktrackingTree.qstep_diffuser(**kwargs)#

Performs the operators \(R_A\) or \(R_B\). For more information on these operators check the paper.

Parameters:
evenbool

Depending on the parameter, the diffuser acts on the subspaces \(\mathcal H_x=\{\ket{x}\}\cup\{\ket{y}\,|\,x\rightarrow y\}\) where \(x\) has odd (even=False) or even (even=True) height. Note that “even” refers to the parity of the h attribute instead of the distance from the root. If the max_depth of the tree is odd, and even=False then \(R_A\) (otherwise \(R_B\)) is performed, and vice verse if the max_depth is even.

ctrlList[Qubit], optional

A list of qubits that allows performant controlling. The default is [].

Examples

We set up a QuantumBackTrackingTree and perform the diffuser on a marked node

from qrisp import auto_uncompute, QuantumBool, QuantumFloat
from qrisp.quantum_backtracking import QuantumBacktrackingTree

@auto_uncompute
def reject(tree):
    return QuantumBool()

@auto_uncompute
def accept(tree):
    return (tree.h == 1)

tree = QuantumBacktrackingTree(3, QuantumFloat(
    1, name = "branch_qf*"), accept, reject)

tree.init_node([1,1])
>>> print(tree.qs.statevector())
|0>*|1>**3
>>> tree.qstep_diffuser(even = False)
>>> print(tree.qs.statevector())
|0>*|1>**3

We see that the node (as expected) is invariant under \(R_A\).