qrisp.inpl_add#
- inpl_add(qf1, qf2, ignore_rounding_error=False, ignore_overflow_error=False, adder='thapliyal')[source]#
Performs in-place addition of the second argument onto the first. In Python syntax:
qf1 += qf2
There are two different algorithms available: The Thapliyal adder and the Cuccaro adder
- Parameters:
- qf1QuantumFloat
The QuantumFloat that will be in-place modified.
- qf2QuantumFloat
The QuantumFloat that is being added.
- ignore_rounding_errorbool, optional
If set to False, an Exception will be raised if qf2 has higher precision than qf1. The default is False.
- ignore_overflow_errorbool, optional
If set to False, an Exception will be raised if qf2 has higher maximum significance than qf2. The default is False.
- adderstr, optional
Specifies the adder. Available are “thapliyal” and “cuccaro”. The default is “thapliyal”.
- Raises:
- Exception
Tried to add signed QuantumFloat onto non signed QuantumFloat.
Examples
We create two QuantumFloats and apply the inplace adder
>>> from qrisp import QuantumFloat, inpl_add >>> qf_0 = QuantumFloat(5) >>> qf_1 = QuantumFloat(5) >>> qf_0[:] = 4 >>> qf_1[:] = 3 >>> inpl_add(qf_0, qf_1) >>> print(qf_0) {7.0: 1.0}