microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
katas/content/linear_algebra/inner_product/Verification.qs
21lines · modecode
| 1 | namespace Kata.Verification { |
| 2 | open Microsoft.Quantum.Math; |
| 3 | |
| 4 | function InnerProduct_Reference() : Complex { |
| 5 | return Complex(-18., 72.); |
| 6 | } |
| 7 | |
| 8 | @EntryPoint() |
| 9 | operation CheckSolution() : Bool { |
| 10 | let actual = Kata.InnerProduct(); |
| 11 | let expected = InnerProduct_Reference(); |
| 12 | if AbsComplex(MinusC(actual, expected)) > 1e-9 { |
| 13 | Message("Incorrect"); |
| 14 | Message($"Expected {ComplexAsString(expected)}, actual {ComplexAsString(actual)}"); |
| 15 | return false; |
| 16 | } |
| 17 | |
| 18 | Message("Correct!"); |
| 19 | return true; |
| 20 | } |
| 21 | } |
| 22 | |