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.
- Loading branch information
1 parent
6b7665c
commit 1527b19
Showing
11 changed files
with
493 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include <cmath> | ||
|
||
extern "C" | ||
{ | ||
|
||
// Declarations: | ||
bool quantum__qis__isnan__body(double d); | ||
double quantum__qis__inf__body(); | ||
bool quantum__qis__isinf__body(double d); | ||
|
||
// Implementations: | ||
bool quantum__qis__isnan__body(double d) | ||
{ | ||
return 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 isinf(d); // https://en.cppreference.com/w/cpp/numeric/math/isinf | ||
} | ||
|
||
} // 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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
#include <cmath> | ||
#include <cstdint> | ||
|
||
#include "catch.hpp" | ||
|
||
extern "C" double __quantum__qis__sqrt__body(double); // NOLINT | ||
extern "C" uint64_t Microsoft__Quantum__Testing__QIR__Math__TestSqrt__body(); // NOLINT | ||
|
||
TEST_CASE("QIR: math.sqrt", "[qir.math][qir.math.sqrt]") | ||
{ | ||
REQUIRE(2.0 == __quantum__qis__sqrt__body((double)4.0)); | ||
REQUIRE(3.0 == __quantum__qis__sqrt__body((double)9.0)); | ||
REQUIRE(10.0 == __quantum__qis__sqrt__body((double)100.0)); | ||
|
||
REQUIRE( isnan(__quantum__qis__sqrt__body((double)-5.0)) ); // (double)NAN == sqrt((double)-5.0) | ||
REQUIRE( isnan(__quantum__qis__sqrt__body(nan(""))) ); // (double)NAN == sqrt((double)<quiet NAN>) | ||
REQUIRE( isinf(__quantum__qis__sqrt__body((double)INFINITY)) ); // +-infinity == sqrt((double) +infinity) | ||
REQUIRE(0 == Microsoft__Quantum__Testing__QIR__Math__TestSqrt__body()); | ||
} |
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,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Quantum.Testing.QIR.Math | ||
{ | ||
open Microsoft.Quantum.Intrinsic; | ||
|
||
function TestSqrt() : Int | ||
{ | ||
mutable testResult = 0; | ||
|
||
if( 2.0 != Sqrt( 4.0) ) { set testResult = 1; } | ||
else { if( 3.0 != Sqrt( 9.0) ) { set testResult = 2; } | ||
else { if( 10.0 != Sqrt(100.0) ) { set testResult = 3; } | ||
|
||
else { if( not IsNan(Sqrt(-5.0))) { set testResult = 4; } | ||
else { if( not IsNan(Sqrt(NAN()))) { set testResult = 5; } | ||
else { if( not IsInf(Sqrt(INFINITY()))) { set testResult = 6; } | ||
}}}}} | ||
|
||
return testResult; | ||
} | ||
} | ||
|
Oops, something went wrong.