microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/pythontelem

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/polar_multiplication/Verification.qs

27lines · modecode

1namespace Kata.Verification {
2 open Microsoft.Quantum.Convert;
3 open Microsoft.Quantum.Math;
4
5 @EntryPoint()
6 operation CheckSolution() : Bool {
7 for _ in 0 .. 24 {
8 let x = DrawRandomComplex();
9 let y = DrawRandomComplex();
10 let xp = ComplexAsComplexPolar(x);
11 let yp = ComplexAsComplexPolar(y);
12
13 let expected = ComplexAsComplexPolar(TimesC(x, y));
14 let actual = Kata.ComplexPolarMult(xp, yp);
15
16 if not ComplexPolarEqual(expected, actual) {
17 Message("Incorrect");
18 Message($"For x = {ComplexPolarAsString(xp)}, y = {ComplexPolarAsString(yp)} " +
19 $"expected return {ComplexPolarAsString(expected)}, actual return {ComplexPolarAsString(actual)}.");
20 return false;
21 }
22 }
23
24 Message("Correct!");
25 return true;
26 }
27}