This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 179
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
FixedPoint conversion functions #559
Copy link
Copy link
Closed
Labels
Area-APIIssue concerns the API design of a library, such as style guide or design principles adherence.Issue concerns the API design of a library, such as style guide or design principles adherence.Kind-EnhancementNew feature or requestNew feature or requestPkg-NumericsIssue relates to the Microsoft.Quantum.Numerics package.Issue relates to the Microsoft.Quantum.Numerics package.trackingThis label will trigger gh-sync to create or update a mirror internal ADO issue.This label will trigger gh-sync to create or update a mirror internal ADO issue.
Description
FixedPoint conversion functions
Conceptual overview
This adds two functions to convert fixed-point representations to and from Bool[]. This extracts the underlying logic for PrepareFxP and MeasureFxP as functions.
Current status
This functions are only implicitly available and would require qubit allocation in order to access them.
Proposal
New and modified functions, operations, and UDTs
namespace Microsoft.Quantum.Convert
{
/// # Summary
/// Computes fixed-point approximation for a double and returns it as `Bool` array.
///
/// # Input
/// ## integerBits
/// Assumed number of integerBits (including the sign big)
/// ## fractionalBits
/// Assumed number of fractionalBits
/// ## value
/// Value to be approximated
function FixedPointAsBoolArray(integerBits : Int, fractionalBits : Int, value : Double) : Bool[] {}
/// # Summary
/// Returns the double value of a fixed-point approximation from of a `Bool` array.
///
/// # Input
/// ## integerBits
/// Assumed number of integerBits (including the sign big)
/// ## bits
/// Bit-string representation of approximated number
function BoolArrayAsFixedPoint(integerBits : Int, bits : Bool[]) : Double {}
/// # Summary
/// Discretizes a double value as a double and returns its approximated representation as a double.
///
/// # Input
/// ## integerBits
/// Assumed number of integerBits (including the sign big)
/// ## fractionalBits
/// Assumed number of fractionalBits
/// ## value
/// Value to be approximated
function DoubleAsFixedPoint(integerBits : Int, fractionalBits : Int, value : Double) : Double {
return BoolArrayAsFixedPoint(integerBits, fractionalBits, FixedPointAsBoolArray(integerBits, fractionalBits, value));
}
}Examples
Current status
TODO.
Using proposed changes
TODO.
Open design questions and considerations
These functions should be used in the implementation of PrepareFxP and MeasureFxP.
Metadata
Metadata
Assignees
Labels
Area-APIIssue concerns the API design of a library, such as style guide or design principles adherence.Issue concerns the API design of a library, such as style guide or design principles adherence.Kind-EnhancementNew feature or requestNew feature or requestPkg-NumericsIssue relates to the Microsoft.Quantum.Numerics package.Issue relates to the Microsoft.Quantum.Numerics package.trackingThis label will trigger gh-sync to create or update a mirror internal ADO issue.This label will trigger gh-sync to create or update a mirror internal ADO issue.