Skip to content
Construct PsiQDK Workbench

Reference: Square Root Qubricks

Contents


Sqrt

Sqrt(**kwargs)

Bases: Qubrick

Qubrick for square root.

This is implemented starting from "T-count and Qubit Optimized Quantum Circuit Design of the Non-Restoring Square Root Algorithm" (arxiv:1712.08254 ⧉) but with multiple fixes and optimizations:

  • Qubit highwater and Toffoli count are significantly reduced from the original paper.
  • The original paper doesn't work when the high 2 input qubits are 1, but this one does.
  • The original paper requires n to be even and >= 6, this one has no restrictions (for tiny inputs it auto-pads them to 6).

compute

compute(input_qreg: Qubits | QUInt)

Compute square root.

Parameters:

Name Type Description Default
input_qreg Qubits or QUInt

Input register for square root operation

required
Note

For more details, see Built-in Qubricks tutorial ⧉.

RSqrt

RSqrt(**kwargs)

Bases: Qubrick

Fast reciprocal square root.

compute

compute(lhs: Qubits | QUInt)

This computes reg = rsqrt(reg) in-place, where the input is a positive integer and the output is a fixed-point fraction with all bits below the decimal.

Parameters:

Name Type Description Default
lhs Qubits or QUInt

Left-hand operand and destination

required
Note

For more details, see Built-in Qubricks tutorial ⧉