qrisp.q_isqrt#

q_isqrt(R: QuantumFloat) QuantumFloat[source]#

Computes the integer square root of a QuantumFloat, as well as the remainder using the non-Restoring square root algorithm. Does not yield plausible output when applied to negative integers.

Parameters:
RQuantumFloat

QuantumFloat value to compute the integer square root of.

Returns:
QuantumFloat

The integer square root of R.

Also transforms input value R into the remainder.

Examples

Calculate the integer square root of 131:

>>> from qrisp import QuantumFloat, q_isqrt
>>> R = QuantumFloat(8, 0)
>>> R[:] = 131
>>> res = q_isqrt(R)
>>> print(res.get_measurement())
>>> print(R.get_measurement())
{11: 1.0}
{10: 1.0}