microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
library/fixed_point/src/Init.qs
18lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | import Types.FixedPoint; |
| 5 | import Convert.FixedPointAsBoolArray; |
| 6 | |
| 7 | /// # Summary |
| 8 | /// Initialize a quantum fixed-point number to a classical constant. |
| 9 | /// |
| 10 | /// # Input |
| 11 | /// ## constant |
| 12 | /// Constant to which to initialize the quantum fixed-point number. |
| 13 | /// ## fp |
| 14 | /// Fixed-point number (of type FixedPoint) to initialize. |
| 15 | operation PrepareFxP(constant : Double, fp : FixedPoint) : Unit is Adj + Ctl { |
| 16 | let bits = FixedPointAsBoolArray(fp::IntegerBits, Length(fp::Register) - fp::IntegerBits, constant); |
| 17 | ApplyPauliFromBitString(PauliX, true, bits, fp::Register); |
| 18 | } |
| 19 | |