forked from microsoft/QuantumKatas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReferenceImplementation.qs
38 lines (31 loc) · 1.31 KB
/
ReferenceImplementation.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
//////////////////////////////////////////////////////////////////////
// This file contains reference solutions to all tasks.
// You should not modify anything in this file.
// We recommend that you try to solve the tasks yourself first,
// but feel free to look up the solution if you get stuck.
//////////////////////////////////////////////////////////////////////
namespace Quantum.Kata.MultiQubitGates {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
operation CompoundGate_Reference (qs : Qubit[]) : Unit is Adj {
S(qs[0]);
Y(qs[2]);
}
operation BellState_Reference (qs : Qubit[]) : Unit is Adj {
H(qs[0]);
CNOT(qs[0], qs[1]);
}
operation QubitSwap_Reference (qs : Qubit[], index1 : Int, index2 : Int) : Unit is Adj {
SWAP(qs[index1], qs[index2]);
}
operation ControlledRotation_Reference (qs : Qubit[], theta : Double) : Unit is Adj {
let control = qs[0];
let target = qs[1];
Controlled Rx([control], (theta, target));
}
operation MultiControls_Reference (controls : Qubit[], target : Qubit, controlBits : Bool[]) : Unit is Adj {
(ControlledOnBitString(controlBits, X))(controls, target);
}
}