Performs a bit shift in the quantum device. While
exp_shiftperforms a bit shift in the compiler (thus costing no quantum gates) this method performs the bitshift on the hardware.
This has the advantage, that it can be controlled if called within a ControlEnvironment and furthermore admits bit shifts based on the state of a QuantumFloat
Bit bit shifts based on a QuantumFloat are currently only possible if both self and
Quantum bit shifting extends the QuantumFloat (ie. it allocates additional qubits).
- shift_amountint or QuantumFloat
The amount to shift.
Tried to shift QuantumFloat exponent by non-integer value
Quantum-quantum bitshifting is currently only supported for unsigned arguments
We create a QuantumFloat and a QuantumBool to perform a controlled bit shift.
from qrisp import QuantumFloat, QuantumBool, h qf = QuantumFloat(4) qf[:] = 1 qbl = QuantumBool() h(qbl) with qbl: qf.quantum_bit_shift(2)
Evaluate the result
>>> print(qf.qs.statevector()) sqrt(2)*(|1>*|False> + |4>*|True>)/2