microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
samples/testing/operations/src/CustomOperation.qs
16lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | /// # Summary |
| 5 | /// CNOT based SWAP operation for testing with `TestEquivalence` operation. |
| 6 | /// |
| 7 | /// # Input |
| 8 | /// ## q1 |
| 9 | /// First input qubit |
| 10 | /// ## q2 |
| 11 | /// Second input qubit |
| 12 | operation ApplySWAP(q1 : Qubit, q2 : Qubit) : Unit is Ctl + Adj { |
| 13 | CNOT(q1, q2); // q1, q1 xor q2 |
| 14 | CNOT(q2, q1); // q2, q1 xor q2 |
| 15 | CNOT(q1, q2); // q2, q1 |
| 16 | } |
| 17 | |