This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some math funcs implementation (#500)
* Added sqrt implementation and tests. * Restructured the files. * Restructured sqrt. * CR changes * Fixed the Linux build break. * Added Log() and ArcTan2(). * Added pauli_to_string * CR changes. * CR changes.
- Loading branch information
1 parent
ce2580e
commit fbd4b38
Showing
19 changed files
with
1,034 additions
and
196 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 | ||
} | ||
|
||
} // extern "C" |
This file contains 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 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 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 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 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 { | ||
|
||
/// # 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 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.