As stated in the title, quantum_bit_shift from SBP arithmetic should not be used in function of the same name for the QuantumFloat class.
|
def quantum_bit_shift(self, shift_amount): |
|
""" |
|
Performs a bit shift in the quantum device. |
|
While :meth:`exp_shift<qrisp.QuantumFloat.exp_shift>` performs 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 |
|
:ref:`ControlEnvironment` and furthermore admits bit shifts based on the |
|
state of a QuantumFloat |
|
|
|
.. note:: |
|
|
|
Bit bit shifts based on a QuantumFloat are currently only possible |
|
if both self and ``shift_amount`` are unsigned. |
|
|
|
.. warning:: |
|
|
|
Quantum bit shifting extends the QuantumFloat (ie. it allocates |
|
additional qubits). |
|
|
|
Parameters |
|
---------- |
|
shift_amount : int or QuantumFloat |
|
The amount to shift. |
|
|
|
Raises |
|
------ |
|
Exception |
|
Tried to shift QuantumFloat exponent by non-integer value |
|
Exception |
|
Quantum-quantum bitshifting is currently only supported for unsigned arguments |
|
|
|
Examples |
|
-------- |
|
|
|
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 |
|
|
|
""" |
|
|
|
from qrisp.alg_primitives.arithmetic import quantum_bit_shift |
|
|
|
quantum_bit_shift(self, shift_amount) |
As stated in the title,
quantum_bit_shiftfrom SBP arithmetic should not be used in function of the same name for theQuantumFloatclass.Qrisp/src/qrisp/qtypes/quantum_float.py
Lines 1084 to 1142 in 0f9adb0