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