hiperwalk.Coined.set_shift#

Coined.set_shift(shift='default')[source]#

Set the shift operator.

Defines either the flipflop or the persistent shift operator. Following this, the evolution operator updates accordingly.

Parameters:
shift: {‘default’, ‘flipflop’, ‘persistent’, ‘ff’, ‘p’}

Whether to create the flip flop or the persistent shift. By default, creates the persistent shift if it is defined; otherwise creates the flip flop shift. Argument 'ff' is an alias for 'flipflop'. Argument 'p' is an alias for 'persistent'.

Raises:
AttributeError

If shift='persistent' and the persistent shift operator cannot be defined.

Notes

Note

Check Coined Notes for details about the computational basis.

The flip-flop shift operator \(S\) is defined as

\[S \ket{v, u} = \ket{u, v},\]

in the context of arc notation, where \((v, u)\) and \((u, v)\) represent opposite arcs. This can be equivalently expressed as \(S\ket{i} = \ket{j}\), where \(i\) is the label of the arc \((v, u)\) and \(j\) is the label of the arc \((u, v)\). The flip-flop shift satisfies the property \(S^2 = I\).

The persistent shift, also known as the moving shift, is defined for graphs with a clear notion of direction or rotation. When the shift operator is applied repeatedly, it causes the walker to continue moving persistently in the same direction. Unlike the flip-flop shift, the persistent shift does not satisfy \(S^2 = I\).

For a more comprehensive understanding of the shift operator, refer to Section 7.2: Coined Walks on Arbitrary Graphs in the book “Quantum Walks and Search Algorithms” [1].

References

[1]

R. Portugal. “Quantum walks and search algorithms”, 2nd edition, Springer, 2018.

Examples

Consider the Graph presented in the Graph Notes Section example. The corresponding flip-flop shift operator is

>>> import hiperwalk as hpw
>>> A = scipy.sparse.csr_array([[0, 1, 0, 0],
...                             [1, 0, 1, 1],
...                             [0, 1, 0, 1],
...                             [0, 1, 1, 0]])
>>> qw = hpw.Coined(hpw.Graph(A))
>>> qw.set_shift(shift='flipflop')
>>> S = qw.get_shift().todense()
>>> S
array([[0, 1, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0]], dtype=int8)

Note that as required, \(S^2 = I\), \(S \ket 0 = \ket 1\), \(S \ket 1 = \ket 0\), \(S \ket 2 = \ket 4\), \(S \ket 4 = \ket 2\), etc.

>>> (S @ S == np.eye(8)).all() # True by definition
True
>>> S @ np.array([1, 0, 0, 0, 0, 0, 0, 0]) # S|0> = |1>
array([0, 1, 0, 0, 0, 0, 0, 0])
>>> S @ np.array([0, 1, 0, 0, 0, 0, 0, 0]) # S|1> = |0>
array([1, 0, 0, 0, 0, 0, 0, 0])
>>> S @ np.array([0, 0, 1, 0, 0, 0, 0, 0]) # S|2> = |4>
array([0, 0, 0, 0, 1, 0, 0, 0])
>>> S @ np.array([0, 0, 0, 0, 1, 0, 0, 0]) # S|4> = |2>
array([0, 0, 1, 0, 0, 0, 0, 0])