microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fedimser/memory-re

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

library/fixed_point/src/Init.qs

18lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4import Types.FixedPoint;
5import 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.
15operation 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