forked from microsoft/QuantumKatas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReferenceImplementation.qs
58 lines (49 loc) · 1.62 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 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.SingleQubitGates {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Math;
// Exercise 1.
operation ApplyY_Reference (q : Qubit) : Unit is Adj+Ctl {
Y(q);
}
// Exercise 2.
operation GlobalPhaseI_Reference (q : Qubit) : Unit is Adj+Ctl {
X(q);
Z(q);
Y(q);
}
// Exercise 3.
operation SignFlipOnZero_Reference (q : Qubit) : Unit is Adj+Ctl {
X(q);
Z(q);
X(q);
}
// Exercise 4.
operation PrepareMinus_Reference (q : Qubit) : Unit is Adj+Ctl {
X(q);
H(q);
}
// Exercise 5.
operation ThreeQuatersPiPhase_Reference (q : Qubit) : Unit is Adj+Ctl {
S(q);
T(q);
}
// Exercise 6.
operation PrepareRotatedState_Reference (alpha : Double, beta : Double, q : Qubit) : Unit is Adj+Ctl {
let phi = ArcTan2(beta, alpha);
Rx(2.0 * phi, q);
}
// Exercise 7.
operation PrepareArbitraryState_Reference (alpha : Double, beta : Double, theta : Double, q : Qubit) : Unit is Adj+Ctl {
let phi = ArcTan2(beta, alpha);
Ry(2.0 * phi, q);
R1(theta, q);
}
}