microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
amcasey/ArrayWrap

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/deutsch_algo/examples/OracleImplementationDemo.qs

35lines · modecode

1namespace Kata {
2 import Std.Diagnostics.*;
3 import Std.Math.*;
4
5 operation PhaseOracle_Zero(x : Qubit) : Unit {
6 // Do nothing...
7 }
8
9 operation PhaseOracle_One(x : Qubit) : Unit {
10 // Apply a global phase of -1
11 R(PauliI, 2.0 * PI(), x);
12 }
13
14 operation PhaseOracle_X(x : Qubit) : Unit {
15 Z(x);
16 }
17
18 @EntryPoint()
19 operation OracleImplementationDemo() : Unit {
20 use q = Qubit();
21 Ry(2.0 * ArcCos(0.6), q);
22 Message("The qubit state before oracle application is 0.6|0⟩ + 0.8|1⟩:");
23 DumpMachine();
24
25 // Apply the oracle.
26 // Experiment with using other oracles to see their behavior!
27 // (Note that the -1 global phase might not show up in simulation)
28 PhaseOracle_X(q);
29
30 Message("The qubit state after oracle application:");
31 DumpMachine();
32
33 Reset(q);
34 }
35}
36