microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
samples/testing/operations/src/OperationEquivalence.qs
15lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | import Std.Diagnostics.*; |
| 5 | import CustomOperation.*; |
| 6 | /// # Summary |
| 7 | /// Verifies the equivalence of quantum operations up to a global phase using `Fact` function |
| 8 | /// and the `CheckOperationsAreEqual` operation. You can either run this here, |
| 9 | /// by clicking `Run` in VsCode or call `TestEquivalence` operation in Python. |
| 10 | @EntryPoint() |
| 11 | operation TestEquivalence() : Unit { |
| 12 | let actual = qs => ApplySWAP(qs[0], qs[1]); |
| 13 | let expected = qs => SWAP(qs[0], qs[1]); |
| 14 | Fact(CheckOperationsAreEqual(2, actual, expected), "Actual and expected operation should be same"); |
| 15 | } |
| 16 | |