Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
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
22 changes: 22 additions & 0 deletions Simulation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library2", "src\Simulation\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "src\Simulation\Simulators.Tests\TestProjects\UnitTests\UnitTests.csproj", "{46278108-D247-4EFC-AC34-23D4A676F62F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulation", "Simulation", "{652D1D9B-234B-4DBF-9971-34F866AE58BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QsharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -389,6 +393,22 @@ Global
{46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|x64.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|x64.Build.0 = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|Any CPU.Build.0 = Release|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|x64.ActiveCfg = Release|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|x64.Build.0 = Release|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -416,6 +436,8 @@ Global
{7256B986-6705-42FC-9F57-485D72D9DE51} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{A85277B3-4E07-4E15-8F0C-07CC855A3BCB} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{46278108-D247-4EFC-AC34-23D4A676F62F} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{652D1D9B-234B-4DBF-9971-34F866AE58BA} = {99E234BC-997E-4E63-9F5C-3C3977543404}
{8D993092-F295-41A3-B1D0-DD5EAFA17B8F} = {652D1D9B-234B-4DBF-9971-34F866AE58BA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821}
Expand Down
1 change: 1 addition & 0 deletions build/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.cs
Pack-One '../src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj' '-IncludeReferencedProjects'
Pack-Dotnet '../src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj'
Pack-Dotnet '../src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj'
Pack-Dotnet '../src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj'
Pack-Dotnet '../src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj'
Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec'
Pack-One '../src/Quantum.Development.Kit/Microsoft.Quantum.Development.Kit.nuspec'
Expand Down
1 change: 1 addition & 0 deletions src/Simulation/EntryPointDriver.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ let private compileCsharp (sources : string seq) =
"System.Runtime.Extensions"
"System.Runtime.Numerics"
"Microsoft.Quantum.EntryPointDriver"
"Microsoft.Quantum.QSharp.Foundation"
"Microsoft.Quantum.QSharp.Core"
"Microsoft.Quantum.QsDataStructures"
"Microsoft.Quantum.Runtime.Core"
Expand Down
102 changes: 0 additions & 102 deletions src/Simulation/QsharpCore/Intrinsic.qs
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,6 @@ namespace Microsoft.Quantum.Intrinsic {
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;

/// # Summary
/// The random operation takes an array of doubles as input, and returns
/// a randomly-selected index into the array as an `Int`.
/// The probability of selecting a specific index is proportional to the value
/// of the array element at that index.
/// Array elements that are equal to zero are ignored and their indices are never
/// returned. If any array element is less than zero,
/// or if no array element is greater than zero, then the operation fails.
///
/// # Input
/// ## probs
/// An array of floating-point numbers proportional to the probability of
/// selecting each index.
///
/// # Output
/// An integer $i$ with probability $\Pr(i) = p_i / \sum_i p_i$, where $p_i$
/// is the $i$th element of `probs`.
operation Random (probs : Double[]) : Int {
body intrinsic;
}


/// # Summary
/// Asserts that measuring the given qubits in the given Pauli basis will
/// always have the given result.
///
/// # Input
/// ## bases
/// A measurement effect to assert the probability of, expressed as a
/// multi-qubit Pauli operator.
/// ## qubits
/// A register on which to make the assertion.
/// ## result
/// The expected result of `Measure(bases, qubits)`.
/// ## msg
/// A message to be reported if the assertion fails.
///
/// # Remarks
/// Note that the Adjoint and Controlled versions of this operation will not
/// check the condition.
///
/// # See Also
/// - AssertProb
operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit
is Adj + Ctl {
body intrinsic;
}


/// # Summary
/// Asserts that measuring the given qubits in the given Pauli basis will have the given result
/// with the given probability, within some tolerance.
///
/// # Input
/// ## bases
/// A measurement effect to assert the probability of, expressed as a
/// multi-qubit Pauli operator.
/// ## qubits
/// A register on which to make the assertion.
/// ## result
/// An expected result of `Measure(bases, qubits)`.
/// ## prob
/// The probability with which the given result is expected.
/// ## msg
/// A message to be reported if the assertion fails.
///
/// # Example
/// ```qsharp
/// using (register = Qubit()) {
/// H(register);
/// AssertProb([PauliZ], [register], One, 0.5,
/// "Measuring in conjugate basis did not give 50/50 results.", 1e-5);
/// }
/// ```
///
/// # Remarks
/// Note that the Adjoint and Controlled versions of this operation will not
/// check the condition.
///
/// # See Also
/// - Assert
operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit
is Adj + Ctl {
body intrinsic;
}


/// # Summary
/// Logs a message.
///
/// # Input
/// ## msg
/// The message to be reported.
///
/// # Remarks
/// The specific behavior of this function is simulator-dependent,
/// but in most cases the given message will be written to the console.
function Message (msg : String) : Unit {
body intrinsic;
}


//-------------------------------------------------
// Clifford and related operations
//-------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<ItemGroup>
<ProjectReference Include="..\Core\Microsoft.Quantum.Runtime.Core.csproj" />
<ProjectReference Include="..\QsharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj" />
<ProjectReference Include="..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
</ItemGroup>

Expand Down
68 changes: 68 additions & 0 deletions src/Simulation/QsharpFoundation/Assert.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Intrinsic {
/// # Summary
/// Asserts that measuring the given qubits in the given Pauli basis will
/// always have the given result.
///
/// # Input
/// ## bases
/// A measurement effect to assert the probability of, expressed as a
/// multi-qubit Pauli operator.
/// ## qubits
/// A register on which to make the assertion.
/// ## result
/// The expected result of `Measure(bases, qubits)`.
/// ## msg
/// A message to be reported if the assertion fails.
///
/// # Remarks
/// Note that the Adjoint and Controlled versions of this operation will not
/// check the condition.
///
/// # See Also
/// - AssertProb
operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit
is Adj + Ctl {
body intrinsic;
}


/// # Summary
/// Asserts that measuring the given qubits in the given Pauli basis will have the given result
/// with the given probability, within some tolerance.
///
/// # Input
/// ## bases
/// A measurement effect to assert the probability of, expressed as a
/// multi-qubit Pauli operator.
/// ## qubits
/// A register on which to make the assertion.
/// ## result
/// An expected result of `Measure(bases, qubits)`.
/// ## prob
/// The probability with which the given result is expected.
/// ## msg
/// A message to be reported if the assertion fails.
///
/// # Example
/// ```qsharp
/// using (register = Qubit()) {
/// H(register);
/// AssertProb([PauliZ], [register], One, 0.5,
/// "Measuring in conjugate basis did not give 50/50 results.", 1e-5);
/// }
/// ```
///
/// # Remarks
/// Note that the Adjoint and Controlled versions of this operation will not
/// check the condition.
///
/// # See Also
/// - Assert
operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit
is Adj + Ctl {
body intrinsic;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Microsoft.Quantum.Simulation.QuantumProcessor.Extensions //ToDo: update namespace to a more appropriate name
{
open Microsoft.Quantum.Intrinsic;

operation NoOp() : Unit is Ctl + Adj {}

// Private helper operations.
Expand Down
18 changes: 18 additions & 0 deletions src/Simulation/QsharpFoundation/Message.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Intrinsic {
/// # Summary
/// Logs a message.
///
/// # Input
/// ## msg
/// The message to be reported.
///
/// # Remarks
/// The specific behavior of this function is simulator-dependent,
/// but in most cases the given message will be written to the console.
function Message(msg : String) : Unit {
body intrinsic;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.602-beta">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<QsharpDocsGeneration>true</QsharpDocsGeneration>
<CsharpGeneration>false</CsharpGeneration> <!-- we will provide our own -->
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
</PropertyGroup>

<PropertyGroup>
<Authors>Microsoft</Authors>
<Description>Foundation implementation for the Q# programming language.</Description>
<PackageReleaseNotes>See: https://docs.microsoft.com/en-us/quantum/relnotes/</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/microsoft/qsharp-runtime</PackageProjectUrl>
<PackageIconUrl>https://secure.gravatar.com/avatar/bd1f02955b2853ba0a3b1cdc2434e8ec.png</PackageIconUrl>
<PackageTags>Quantum Q# Qsharp</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Core\Microsoft.Quantum.Runtime.Core.csproj" />
<ProjectReference Include="..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
</ItemGroup>

<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>

</Project>

25 changes: 25 additions & 0 deletions src/Simulation/QsharpFoundation/Random.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Intrinsic {
/// # Summary
/// The random operation takes an array of doubles as input, and returns
/// a randomly-selected index into the array as an `Int`.
/// The probability of selecting a specific index is proportional to the value
/// of the array element at that index.
/// Array elements that are equal to zero are ignored and their indices are never
/// returned. If any array element is less than zero,
/// or if no array element is greater than zero, then the operation fails.
///
/// # Input
/// ## probs
/// An array of floating-point numbers proportional to the probability of
/// selecting each index.
///
/// # Output
/// An integer $i$ with probability $\Pr(i) = p_i / \sum_i p_i$, where $p_i$
/// is the $i$th element of `probs`.
operation Random(probs : Double[]) : Int {
body intrinsic;
}
}