Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Single qubit gates #185

Merged
merged 9 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ RUN ${HOME}/scripts/prebuild-kata.sh tutorials/DeutschJozsaAlgorithm DeutschJozs
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/ExploringGroversAlgorithm ExploringGroversAlgorithmTutorial.ipynb
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/LinearAlgebra LinearAlgebra.ipynb
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/Qubit Qubit.ipynb
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/SingleQubitGates SingleQubitGates.ipynb
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Each kata is a separate project which includes:
which are used to represent quantum states and quantum operations.
* **[The Qubit](./tutorials/Qubit/)**.
This tutorial introduces you to the concept of a qubit.
* **[Single-Qubit Gates](./tutorials/SingleQubitGates/)**.
This tutorial introduces the concept of a quantum gate and walks you through the most common single-qubit gates.
* **[Deutsch–Jozsa algorithm](./tutorials/DeutschJozsaAlgorithm/)**.
This tutorial teaches you to implement classical functions and equivalent quantum oracles,
discusses the classical solution to the Deutsch–Jozsa problem, and introduces the Deutsch and Deutsch–Jozsa algorithms.
Expand Down
2 changes: 2 additions & 0 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
" which are used to represent quantum states and quantum operations.\n",
"* **[The Qubit](./tutorials/Qubit/Qubit.ipynb)**.\n",
" This tutorial introduces you to the concept of a qubit.\n",
"* **[Single-Qubit Gates](./tutorials/SingleQubitGates/SingleQubitGates.ipynb)**.\n",
" This tutorial introduces the concept of a quantum gate and walks you through the most common single-qubit gates.\n",
"* **[Deutsch–Jozsa algorithm](./tutorials/DeutschJozsaAlgorithm/DeutschJozsaAlgorithmTutorial.ipynb)**.\n",
" This tutorial teaches you to implement classical functions and equivalent quantum oracles, \n",
" discusses the classical solution to the Deutsch–Jozsa problem and introduces Deutsch and Deutsch–Jozsa algorithms.\n",
Expand Down
12 changes: 2 additions & 10 deletions tutorials/LinearAlgebra/LinearAlgebra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -962,17 +962,9 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Your function must return a value!\n"
]
}
],
"outputs": [],
"source": [
"@exercise\n",
"def find_eigenvalue(a : Matrix, v : Matrix) -> float:\n",
Expand Down
58 changes: 58 additions & 0 deletions tutorials/SingleQubitGates/ReferenceImplementation.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
}
17 changes: 17 additions & 0 deletions tutorials/SingleQubitGates/SingleQubitGates.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RootNamespace>Quantum.Kata.SingleQubitGates</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Standard" Version="0.9.1909.3002" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.9.1909.3002" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.9.1909.3002" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
</Project>
Loading