Reference: Square Root Qubricks¶
Contents¶
Sqrt ¶
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 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 ¶
Bases: Qubrick
Fast reciprocal square root.
compute ¶
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 ⧉