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 90
Added some math funcs implementation #500
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a52fcc1
Added sqrt implementation and tests.
kuzminrobin af50dfe
Restructured the files.
kuzminrobin debfa49
Restructured sqrt.
kuzminrobin dc623c1
CR changes
kuzminrobin a9e9b70
Fixed the Linux build break.
kuzminrobin 2763869
Added Log() and ArcTan2().
kuzminrobin 6e16e4a
Added pauli_to_string
kuzminrobin 47053d5
CR changes.
kuzminrobin 2d91081
CR changes.
kuzminrobin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #include <cmath> | ||
| #include "quantum__qis.hpp" | ||
|
|
||
| extern "C" | ||
| { | ||
|
|
||
| // Implementations: | ||
| bool quantum__qis__isnan__body(double d) | ||
| { | ||
| return std::isnan(d); // https://en.cppreference.com/w/cpp/numeric/math/isnan | ||
| } | ||
|
|
||
| double quantum__qis__infinity__body() | ||
| { | ||
| return INFINITY; // https://en.cppreference.com/w/c/numeric/math/INFINITY | ||
| } | ||
|
|
||
| bool quantum__qis__isinf__body(double d) | ||
| { | ||
| return std::isinf(d); // https://en.cppreference.com/w/cpp/numeric/math/isinf | ||
| } | ||
|
|
||
| double quantum__qis__arctan2__body(double y, double x) | ||
| { | ||
| return std::atan2(y, x); // https://en.cppreference.com/w/cpp/numeric/math/atan2 | ||
kuzminrobin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } // extern "C" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| // these are all the static methods and const fields form System.Math class of .NET CLR | ||
| // that are not exposed as language operators and are relevant within type System. | ||
| // If there are two versions of the function for Int and Double types, the corresponding | ||
| // functions have suffix I or D. ExpD also has a suffix to avoid name clash with Primitives.Exp. | ||
|
|
||
| namespace Microsoft.Quantum.Math { | ||
kuzminrobin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// # Summary | ||
| /// Returns the natural logarithmic base to double-precision. | ||
| /// | ||
| /// # Output | ||
| /// A double-precision approximation of the natural logarithic base, | ||
| /// $e \approx 2.7182818284590452354$. | ||
| /// | ||
| /// # See Also | ||
| /// - Microsoft.Quantum.Math.PI | ||
| function E() : Double { | ||
| return 2.7182818284590452354; | ||
| } | ||
|
|
||
| /// # Summary | ||
| /// Represents the ratio of the circumference of a circle to its diameter. | ||
| /// | ||
| /// # Ouptut | ||
| /// A double-precision approximation of the the circumference of a circle | ||
| /// to its diameter, $\pi \approx 3.14159265358979323846$. | ||
| /// | ||
| /// # See Also | ||
| /// - Microsoft.Quantum.Math.E | ||
| function PI() : Double { | ||
| return 3.14159265358979323846; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.