microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billti/copilot

Branches

Tags

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

Clone

HTTPS

Download ZIP

samples/testing/operations/src/OperationEquivalence.qs

17lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4namespace 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