diff --git a/AdvantageBenchmark/privateBuild/host.csproj b/AdvantageBenchmark/privateBuild/host.csproj index b24e3868c5e..5fbd6838ee9 100644 --- a/AdvantageBenchmark/privateBuild/host.csproj +++ b/AdvantageBenchmark/privateBuild/host.csproj @@ -1,4 +1,4 @@ - + @@ -8,4 +8,9 @@ false + + + + + diff --git a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj index e963b3081ad..b7284bec583 100644 --- a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj +++ b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj @@ -1,4 +1,4 @@ - + diff --git a/NOTICE.txt b/NOTICE.txt index ea1fd3063d2..114083df6a5 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2715,7 +2715,7 @@ SOFTWARE. ------------------------------------------------------------------- -Microsoft.Quantum.Compiler 0.12.20082209-beta - MIT +Microsoft.Quantum.Compiler 0.13.20102604 - MIT (c) 2008 VeriSign, Inc. diff --git a/Simulation.sln b/Simulation.sln index b7f85e48807..bf4e03b481d 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -1,534 +1,663 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28809.33 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Runtime.Core", "src\Simulation\Core\Microsoft.Quantum.Runtime.Core.csproj", "{E9123D45-C1B0-4462-8810-D26ED6D31944}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{058CB08D-BFA7-41E2-BE6B-0A0A72054F91}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.Common", "src\Simulation\Common\Microsoft.Quantum.Simulation.Common.csproj", "{8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulators", "src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator.Tests\Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{DD50D2D9-2765-449B-8C4B-835A428E160D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators", "src\Simulation\Simulators.Tests\Tests.Microsoft.Quantum.Simulators.csproj", "{23461B29-F9DE-4F5B-BC30-50BBE1A10B48}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulation", "simulation", "{34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.QSharp.Core", "src\Simulation\QSharpCore\Microsoft.Quantum.QSharp.Core.csproj", "{A6C5BA7A-DF6F-476F-9106-95905932B810}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "xunit", "xunit", "{34117E2A-DEDC-4274-AAA4-3C61ACF86284}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{03736C2E-DB2A-46A9-B7B2-C1216BDECB4F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Xunit", "src\Xunit\Microsoft.Quantum.Xunit.csproj", "{ECFE1CE8-46A1-4D14-99D6-AAF76B704638}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "generation", "generation", "{A567C185-A429-418B-AFDE-6F1785BA4A77}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.CSharpGeneration", "src\Simulation\CSharpGeneration.Tests\Tests.CSharpGeneration.fsproj", "{10D7C395-4F79-4DAF-9289-A4B8FAF6183A}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.Quantum.RoslynWrapper", "src\Simulation\RoslynWrapper\Microsoft.Quantum.RoslynWrapper.fsproj", "{618FBF9D-4EF3-435D-9728-81C726236668}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.RoslynWrapper", "src\Simulation\RoslynWrapper.Tests\Tests.RoslynWrapper.fsproj", "{48206BD6-48DD-4442-A395-3A6594E4C9C6}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.Quantum.CSharpGeneration", "src\Simulation\CSharpGeneration\Microsoft.Quantum.CSharpGeneration.fsproj", "{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProjects", "{09C842CB-930C-4C7D-AD5F-E30DE4A55820}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSharpExe", "src\Simulation\Simulators.Tests\TestProjects\QSharpExe\QSharpExe.csproj", "{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver.Tests\Tests.Microsoft.Quantum.EntryPointDriver.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library1", "src\Simulation\Simulators.Tests\TestProjects\Library1\Library1.csproj", "{7256B986-6705-42FC-9F57-485D72D9DE51}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library2", "src\Simulation\Simulators.Tests\TestProjects\Library2\Library2.csproj", "{A85277B3-4E07-4E15-8F0C-07CC855A3BCB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library with Spaces", "src\Simulation\Simulators.Tests\TestProjects\Library with Spaces\Library with Spaces.csproj", "{418E79F7-9FCF-4128-AA35-1334A685377D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "src\Simulation\Simulators.Tests\TestProjects\UnitTests\UnitTests.csproj", "{46278108-D247-4EFC-AC34-23D4A676F62F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure", "Azure", "{37CDC768-16D4-4574-8553-07D99D0A72F7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Quantum.Client", "src\Azure\Azure.Quantum.Client\Microsoft.Azure.Quantum.Client.csproj", "{7F05FD87-A2FB-4915-A988-4EF92AB82179}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Quantum.Client.Test", "src\Azure\Azure.Quantum.Client.Test\Microsoft.Azure.Quantum.Client.Test.csproj", "{4858E5E3-23FA-4928-B99A-54065875A2B9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoneywellExe", "src\Simulation\Simulators.Tests\TestProjects\HoneywellExe\HoneywellExe.csproj", "{1448512E-132F-4DA8-BCBA-D98F16B31600}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IonQExe", "src\Simulation\Simulators.Tests\TestProjects\IonQExe\IonQExe.csproj", "{55833C6C-6E91-4413-9F77-96B3A09666B8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QCIExe", "src\Simulation\Simulators.Tests\TestProjects\QCIExe\QCIExe.csproj", "{C015FF41-9A51-4AF0-AEFC-2547D596B10A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetedExe", "src\Simulation\Simulators.Tests\TestProjects\TargetedExe\TargetedExe.csproj", "{D292BF18-3956-4827-820E-254C3F81EF09}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntrinsicTests", "src\Simulation\Simulators.Tests\TestProjects\IntrinsicTests\IntrinsicTests.csproj", "{D5D41201-101F-4C0D-B6A0-201D8FC3AB91}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - MinSizeRel|Any CPU = MinSizeRel|Any CPU - MinSizeRel|x64 = MinSizeRel|x64 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU - RelWithDebInfo|x64 = RelWithDebInfo|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|x64.ActiveCfg = Debug|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|x64.Build.0 = Debug|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|x64.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|x64.Build.0 = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|Any CPU.Build.0 = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|x64.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|x64.Build.0 = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|x64.ActiveCfg = Debug|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|x64.Build.0 = Debug|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|x64.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|x64.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|Any CPU.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|x64.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|x64.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|x64.ActiveCfg = Debug|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|x64.Build.0 = Debug|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|x64.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|x64.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|Any CPU.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|x64.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|x64.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|x64.ActiveCfg = Debug|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|x64.Build.0 = Debug|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|x64.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|x64.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|Any CPU.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|x64.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|x64.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|x64.ActiveCfg = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|x64.Build.0 = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|Any CPU.Build.0 = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|x64.ActiveCfg = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|x64.Build.0 = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|x64.ActiveCfg = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|x64.Build.0 = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|Any CPU.Build.0 = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|x64.ActiveCfg = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|x64.Build.0 = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|x64.ActiveCfg = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|x64.Build.0 = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|Any CPU.Build.0 = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|x64.ActiveCfg = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|x64.Build.0 = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|x64.ActiveCfg = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|x64.Build.0 = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|Any CPU.Build.0 = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|x64.ActiveCfg = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|x64.Build.0 = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|x64.ActiveCfg = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|x64.Build.0 = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|Any CPU.Build.0 = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|x64.ActiveCfg = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|x64.Build.0 = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|Any CPU.Build.0 = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|x64.ActiveCfg = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|x64.Build.0 = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Release|Any CPU.ActiveCfg = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Release|Any CPU.Build.0 = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Release|x64.ActiveCfg = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.Release|x64.Build.0 = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|x64.ActiveCfg = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|x64.Build.0 = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|Any CPU.Build.0 = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|x64.ActiveCfg = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|x64.Build.0 = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|x64.ActiveCfg = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|x64.Build.0 = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|Any CPU.Build.0 = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|x64.ActiveCfg = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|x64.Build.0 = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.ActiveCfg = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.Build.0 = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.Build.0 = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.ActiveCfg = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.Build.0 = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|Any CPU.Build.0 = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|x64.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|x64.Build.0 = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|Any CPU.ActiveCfg = Release|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|Any CPU.Build.0 = Release|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|x64.ActiveCfg = Release|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|x64.Build.0 = Release|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU - {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|x64.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|x64.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|Any CPU.Build.0 = Release|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|x64.ActiveCfg = Release|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|x64.Build.0 = Release|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU - {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|x64.ActiveCfg = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|x64.Build.0 = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|Any CPU.Build.0 = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|x64.ActiveCfg = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|x64.Build.0 = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|x64.ActiveCfg = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|x64.Build.0 = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|Any CPU.Build.0 = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|x64.ActiveCfg = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|x64.Build.0 = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|x64.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|x64.Build.0 = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|Any CPU.Build.0 = Release|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|x64.ActiveCfg = Release|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|x64.Build.0 = Release|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU - {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|x64.ActiveCfg = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|x64.Build.0 = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|Any CPU.Build.0 = Release|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|x64.ActiveCfg = Release|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|x64.Build.0 = Release|Any CPU - {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {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 - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|x64.ActiveCfg = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|x64.Build.0 = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|Any CPU.Build.0 = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|x64.ActiveCfg = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|x64.Build.0 = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|x64.ActiveCfg = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|x64.Build.0 = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|Any CPU.Build.0 = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|x64.ActiveCfg = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|x64.Build.0 = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|x64.ActiveCfg = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|x64.Build.0 = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|Any CPU.Build.0 = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|x64.ActiveCfg = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|x64.Build.0 = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|x64.ActiveCfg = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|x64.Build.0 = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|Any CPU.Build.0 = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|x64.ActiveCfg = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|x64.Build.0 = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|x64.ActiveCfg = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|x64.Build.0 = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|Any CPU.Build.0 = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|x64.ActiveCfg = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|x64.Build.0 = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.ActiveCfg = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.Build.0 = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.Build.0 = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.ActiveCfg = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.Build.0 = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU - {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Debug|x64.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Debug|x64.Build.0 = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Release|Any CPU.Build.0 = Release|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Release|x64.ActiveCfg = Release|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.Release|x64.Build.0 = Release|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {E9123D45-C1B0-4462-8810-D26ED6D31944} = {03736C2E-DB2A-46A9-B7B2-C1216BDECB4F} - {058CB08D-BFA7-41E2-BE6B-0A0A72054F91} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {72B7E75C-D305-45BD-929E-C86298AAA8DE} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {DD50D2D9-2765-449B-8C4B-835A428E160D} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {23461B29-F9DE-4F5B-BC30-50BBE1A10B48} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {A6C5BA7A-DF6F-476F-9106-95905932B810} = {03736C2E-DB2A-46A9-B7B2-C1216BDECB4F} - {ECFE1CE8-46A1-4D14-99D6-AAF76B704638} = {34117E2A-DEDC-4274-AAA4-3C61ACF86284} - {10D7C395-4F79-4DAF-9289-A4B8FAF6183A} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {618FBF9D-4EF3-435D-9728-81C726236668} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {48206BD6-48DD-4442-A395-3A6594E4C9C6} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {09C842CB-930C-4C7D-AD5F-E30DE4A55820} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} - {2F5796A7-4AF8-4B78-928A-0A3A80752F9D} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {944FE7EF-9220-4CC6-BB20-CE517195B922} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {E2F30496-19D8-46A8-9BC0-26936FFE70D2} = {A567C185-A429-418B-AFDE-6F1785BA4A77} - {7256B986-6705-42FC-9F57-485D72D9DE51} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {A85277B3-4E07-4E15-8F0C-07CC855A3BCB} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {418E79F7-9FCF-4128-AA35-1334A685377D} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {46278108-D247-4EFC-AC34-23D4A676F62F} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {7F05FD87-A2FB-4915-A988-4EF92AB82179} = {37CDC768-16D4-4574-8553-07D99D0A72F7} - {4858E5E3-23FA-4928-B99A-54065875A2B9} = {37CDC768-16D4-4574-8553-07D99D0A72F7} - {1448512E-132F-4DA8-BCBA-D98F16B31600} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {55833C6C-6E91-4413-9F77-96B3A09666B8} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {C015FF41-9A51-4AF0-AEFC-2547D596B10A} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {D292BF18-3956-4827-820E-254C3F81EF09} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {D5D41201-101F-4C0D-B6A0-201D8FC3AB91} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28809.33 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Runtime.Core", "src\Simulation\Core\Microsoft.Quantum.Runtime.Core.csproj", "{E9123D45-C1B0-4462-8810-D26ED6D31944}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{058CB08D-BFA7-41E2-BE6B-0A0A72054F91}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.Common", "src\Simulation\Common\Microsoft.Quantum.Simulation.Common.csproj", "{8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulators", "src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator.Tests\Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{DD50D2D9-2765-449B-8C4B-835A428E160D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators", "src\Simulation\Simulators.Tests\Tests.Microsoft.Quantum.Simulators.csproj", "{23461B29-F9DE-4F5B-BC30-50BBE1A10B48}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulation", "simulation", "{34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.QSharp.Core", "src\Simulation\QSharpCore\Microsoft.Quantum.QSharp.Core.csproj", "{A6C5BA7A-DF6F-476F-9106-95905932B810}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "xunit", "xunit", "{34117E2A-DEDC-4274-AAA4-3C61ACF86284}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{03736C2E-DB2A-46A9-B7B2-C1216BDECB4F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Xunit", "src\Xunit\Microsoft.Quantum.Xunit.csproj", "{ECFE1CE8-46A1-4D14-99D6-AAF76B704638}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "generation", "generation", "{A567C185-A429-418B-AFDE-6F1785BA4A77}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.CSharpGeneration", "src\Simulation\CSharpGeneration.Tests\Tests.CSharpGeneration.fsproj", "{10D7C395-4F79-4DAF-9289-A4B8FAF6183A}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.Quantum.RoslynWrapper", "src\Simulation\RoslynWrapper\Microsoft.Quantum.RoslynWrapper.fsproj", "{618FBF9D-4EF3-435D-9728-81C726236668}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.RoslynWrapper", "src\Simulation\RoslynWrapper.Tests\Tests.RoslynWrapper.fsproj", "{48206BD6-48DD-4442-A395-3A6594E4C9C6}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.Quantum.CSharpGeneration", "src\Simulation\CSharpGeneration\Microsoft.Quantum.CSharpGeneration.fsproj", "{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProjects", "{09C842CB-930C-4C7D-AD5F-E30DE4A55820}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSharpExe", "src\Simulation\Simulators.Tests\TestProjects\QSharpExe\QSharpExe.csproj", "{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver.Tests\Tests.Microsoft.Quantum.EntryPointDriver.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library1", "src\Simulation\Simulators.Tests\TestProjects\Library1\Library1.csproj", "{7256B986-6705-42FC-9F57-485D72D9DE51}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library2", "src\Simulation\Simulators.Tests\TestProjects\Library2\Library2.csproj", "{A85277B3-4E07-4E15-8F0C-07CC855A3BCB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library with Spaces", "src\Simulation\Simulators.Tests\TestProjects\Library with Spaces\Library with Spaces.csproj", "{418E79F7-9FCF-4128-AA35-1334A685377D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "src\Simulation\Simulators.Tests\TestProjects\UnitTests\UnitTests.csproj", "{46278108-D247-4EFC-AC34-23D4A676F62F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure", "Azure", "{37CDC768-16D4-4574-8553-07D99D0A72F7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Quantum.Client", "src\Azure\Azure.Quantum.Client\Microsoft.Azure.Quantum.Client.csproj", "{7F05FD87-A2FB-4915-A988-4EF92AB82179}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Quantum.Client.Test", "src\Azure\Azure.Quantum.Client.Test\Microsoft.Azure.Quantum.Client.Test.csproj", "{4858E5E3-23FA-4928-B99A-54065875A2B9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoneywellExe", "src\Simulation\Simulators.Tests\TestProjects\HoneywellExe\HoneywellExe.csproj", "{1448512E-132F-4DA8-BCBA-D98F16B31600}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IonQExe", "src\Simulation\Simulators.Tests\TestProjects\IonQExe\IonQExe.csproj", "{55833C6C-6E91-4413-9F77-96B3A09666B8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QCIExe", "src\Simulation\Simulators.Tests\TestProjects\QCIExe\QCIExe.csproj", "{C015FF41-9A51-4AF0-AEFC-2547D596B10A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TargetedExe", "src\Simulation\Simulators.Tests\TestProjects\TargetedExe\TargetedExe.csproj", "{D292BF18-3956-4827-820E-254C3F81EF09}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{BC562DAE-FE2B-4A8C-880C-C546F83F99E4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulation", "Simulation", "{9008B252-2DF7-404B-B626-D4497BB70A05}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QSharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{DB45AD73-4D91-43F3-85CC-C63614A96FB0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.Type2.Core", "src\Simulation\Type2Core\Microsoft.Quantum.Type2.Core.csproj", "{AF6CD304-8E03-433D-AAA2-6E0094B53071}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Microsoft.Quantum.Simulators.Type2", "src\Simulation\Simulators.Type2.Tests\Tests.Microsoft.Quantum.Simulators.Type2.csproj", "{ED3D7040-4B3F-4217-A75E-9DF63DD84707}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulators.Tests", "Simulators.Tests", "{CF48986A-B487-407F-98A7-97AED29C6A43}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProjects", "{F5F80AEA-34F4-4E1D-8145-0634E9DCF2C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntrinsicTests", "src\Simulation\Simulators.Tests\TestProjects\IntrinsicTests\IntrinsicTests.csproj", "{4EF958CA-B4A6-4E5F-924A-100B5615BEC3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Microsoft.Quantum.Simulators.Type1", "src\Simulation\Simulators.Type1.Tests\Tests.Microsoft.Quantum.Simulators.Type1.csproj", "{EB6E3DBD-C884-4241-9BC4-8281191D1F53}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.Type1.Core", "src\Simulation\Type1Core\Microsoft.Quantum.Type1.Core.csproj", "{E1A463D7-2E23-4134-BE04-1EFF7A546813}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TargetDefinitions", "TargetDefinitions", "{93409CC3-8DF9-45FA-AE21-16A19FDEF650}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.Targets.Interfaces", "src\Simulation\TargetDefinitions\Interfaces\Microsoft.Quantum.Targets.Interfaces.csproj", "{789C86D9-CE77-40DA-BDDD-979436952512}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + MinSizeRel|Any CPU = MinSizeRel|Any CPU + MinSizeRel|x64 = MinSizeRel|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU + RelWithDebInfo|x64 = RelWithDebInfo|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|x64.ActiveCfg = Debug|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Debug|x64.Build.0 = Debug|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|x64.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.MinSizeRel|x64.Build.0 = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|Any CPU.Build.0 = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|x64.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.Release|x64.Build.0 = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {E9123D45-C1B0-4462-8810-D26ED6D31944}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|Any CPU.Build.0 = Debug|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|x64.ActiveCfg = Debug|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Debug|x64.Build.0 = Debug|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|x64.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.MinSizeRel|x64.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|Any CPU.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|Any CPU.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|x64.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.Release|x64.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|x64.ActiveCfg = Debug|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Debug|x64.Build.0 = Debug|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|x64.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.MinSizeRel|x64.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|Any CPU.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|x64.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.Release|x64.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Debug|x64.Build.0 = Debug|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|x64.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.MinSizeRel|x64.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|Any CPU.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|x64.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.Release|x64.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {72B7E75C-D305-45BD-929E-C86298AAA8DE}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|x64.ActiveCfg = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Debug|x64.Build.0 = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|Any CPU.Build.0 = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|x64.ActiveCfg = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.Release|x64.Build.0 = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {DD50D2D9-2765-449B-8C4B-835A428E160D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|x64.ActiveCfg = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Debug|x64.Build.0 = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|Any CPU.Build.0 = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|x64.ActiveCfg = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.Release|x64.Build.0 = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|x64.ActiveCfg = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Debug|x64.Build.0 = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|Any CPU.Build.0 = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|x64.ActiveCfg = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.Release|x64.Build.0 = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {A6C5BA7A-DF6F-476F-9106-95905932B810}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|x64.ActiveCfg = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Debug|x64.Build.0 = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|Any CPU.Build.0 = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|x64.ActiveCfg = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.Release|x64.Build.0 = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|x64.ActiveCfg = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Debug|x64.Build.0 = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|Any CPU.Build.0 = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|x64.ActiveCfg = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.Release|x64.Build.0 = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|Any CPU.Build.0 = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|x64.ActiveCfg = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Debug|x64.Build.0 = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Release|Any CPU.ActiveCfg = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Release|Any CPU.Build.0 = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Release|x64.ActiveCfg = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.Release|x64.Build.0 = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {618FBF9D-4EF3-435D-9728-81C726236668}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|x64.ActiveCfg = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Debug|x64.Build.0 = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|Any CPU.Build.0 = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|x64.ActiveCfg = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.Release|x64.Build.0 = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {48206BD6-48DD-4442-A395-3A6594E4C9C6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Debug|x64.Build.0 = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|Any CPU.Build.0 = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|x64.ActiveCfg = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.Release|x64.Build.0 = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.ActiveCfg = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.Build.0 = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.Build.0 = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.ActiveCfg = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.Build.0 = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|Any CPU.Build.0 = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|x64.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Debug|x64.Build.0 = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|Any CPU.ActiveCfg = Release|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|Any CPU.Build.0 = Release|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|x64.ActiveCfg = Release|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.Release|x64.Build.0 = Release|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {944FE7EF-9220-4CC6-BB20-CE517195B922}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|x64.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Debug|x64.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|Any CPU.Build.0 = Release|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|x64.ActiveCfg = Release|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.Release|x64.Build.0 = Release|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {E2F30496-19D8-46A8-9BC0-26936FFE70D2}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|x64.ActiveCfg = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Debug|x64.Build.0 = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|Any CPU.Build.0 = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|x64.ActiveCfg = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.Release|x64.Build.0 = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {7256B986-6705-42FC-9F57-485D72D9DE51}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|x64.ActiveCfg = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Debug|x64.Build.0 = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|Any CPU.Build.0 = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|x64.ActiveCfg = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.Release|x64.Build.0 = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|x64.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Debug|x64.Build.0 = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|Any CPU.Build.0 = Release|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|x64.ActiveCfg = Release|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.Release|x64.Build.0 = Release|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {418E79F7-9FCF-4128-AA35-1334A685377D}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|x64.ActiveCfg = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Debug|x64.Build.0 = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|Any CPU.Build.0 = Release|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|x64.ActiveCfg = Release|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.Release|x64.Build.0 = Release|Any CPU + {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {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 + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|x64.ActiveCfg = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Debug|x64.Build.0 = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|Any CPU.Build.0 = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|x64.ActiveCfg = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.Release|x64.Build.0 = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {7F05FD87-A2FB-4915-A988-4EF92AB82179}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|x64.ActiveCfg = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Debug|x64.Build.0 = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|Any CPU.Build.0 = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|x64.ActiveCfg = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.Release|x64.Build.0 = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {4858E5E3-23FA-4928-B99A-54065875A2B9}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|x64.ActiveCfg = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Debug|x64.Build.0 = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|Any CPU.Build.0 = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|x64.ActiveCfg = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.Release|x64.Build.0 = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {1448512E-132F-4DA8-BCBA-D98F16B31600}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|x64.ActiveCfg = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Debug|x64.Build.0 = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|Any CPU.Build.0 = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|x64.ActiveCfg = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.Release|x64.Build.0 = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {55833C6C-6E91-4413-9F77-96B3A09666B8}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|x64.ActiveCfg = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Debug|x64.Build.0 = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|Any CPU.Build.0 = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|x64.ActiveCfg = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.Release|x64.Build.0 = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.ActiveCfg = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.Build.0 = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.Build.0 = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.ActiveCfg = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.Build.0 = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Debug|x64.Build.0 = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Release|Any CPU.Build.0 = Release|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Release|x64.ActiveCfg = Release|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.Release|x64.Build.0 = Release|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {DB45AD73-4D91-43F3-85CC-C63614A96FB0}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Debug|x64.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Debug|x64.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Release|Any CPU.Build.0 = Release|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Release|x64.ActiveCfg = Release|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.Release|x64.Build.0 = Release|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {AF6CD304-8E03-433D-AAA2-6E0094B53071}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Debug|x64.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Debug|x64.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Release|Any CPU.Build.0 = Release|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Release|x64.ActiveCfg = Release|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.Release|x64.Build.0 = Release|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {ED3D7040-4B3F-4217-A75E-9DF63DD84707}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Debug|x64.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Debug|x64.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Release|Any CPU.Build.0 = Release|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Release|x64.ActiveCfg = Release|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.Release|x64.Build.0 = Release|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Debug|x64.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Debug|x64.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Release|Any CPU.Build.0 = Release|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Release|x64.ActiveCfg = Release|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.Release|x64.Build.0 = Release|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {EB6E3DBD-C884-4241-9BC4-8281191D1F53}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Debug|x64.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Debug|x64.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Release|Any CPU.Build.0 = Release|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Release|x64.ActiveCfg = Release|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.Release|x64.Build.0 = Release|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {E1A463D7-2E23-4134-BE04-1EFF7A546813}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Debug|Any CPU.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Debug|x64.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Debug|x64.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Release|Any CPU.ActiveCfg = Release|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Release|Any CPU.Build.0 = Release|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Release|x64.ActiveCfg = Release|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.Release|x64.Build.0 = Release|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {789C86D9-CE77-40DA-BDDD-979436952512}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E9123D45-C1B0-4462-8810-D26ED6D31944} = {03736C2E-DB2A-46A9-B7B2-C1216BDECB4F} + {058CB08D-BFA7-41E2-BE6B-0A0A72054F91} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {72B7E75C-D305-45BD-929E-C86298AAA8DE} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {DD50D2D9-2765-449B-8C4B-835A428E160D} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {23461B29-F9DE-4F5B-BC30-50BBE1A10B48} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {A6C5BA7A-DF6F-476F-9106-95905932B810} = {03736C2E-DB2A-46A9-B7B2-C1216BDECB4F} + {ECFE1CE8-46A1-4D14-99D6-AAF76B704638} = {34117E2A-DEDC-4274-AAA4-3C61ACF86284} + {10D7C395-4F79-4DAF-9289-A4B8FAF6183A} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {618FBF9D-4EF3-435D-9728-81C726236668} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {48206BD6-48DD-4442-A395-3A6594E4C9C6} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {B96E97F4-2DC8-45AC-ADF5-861D0D3073FC} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {09C842CB-930C-4C7D-AD5F-E30DE4A55820} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {2F5796A7-4AF8-4B78-928A-0A3A80752F9D} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {944FE7EF-9220-4CC6-BB20-CE517195B922} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {E2F30496-19D8-46A8-9BC0-26936FFE70D2} = {A567C185-A429-418B-AFDE-6F1785BA4A77} + {7256B986-6705-42FC-9F57-485D72D9DE51} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {A85277B3-4E07-4E15-8F0C-07CC855A3BCB} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {418E79F7-9FCF-4128-AA35-1334A685377D} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {46278108-D247-4EFC-AC34-23D4A676F62F} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {7F05FD87-A2FB-4915-A988-4EF92AB82179} = {37CDC768-16D4-4574-8553-07D99D0A72F7} + {4858E5E3-23FA-4928-B99A-54065875A2B9} = {37CDC768-16D4-4574-8553-07D99D0A72F7} + {1448512E-132F-4DA8-BCBA-D98F16B31600} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {55833C6C-6E91-4413-9F77-96B3A09666B8} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {C015FF41-9A51-4AF0-AEFC-2547D596B10A} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {D292BF18-3956-4827-820E-254C3F81EF09} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {9008B252-2DF7-404B-B626-D4497BB70A05} = {BC562DAE-FE2B-4A8C-880C-C546F83F99E4} + {DB45AD73-4D91-43F3-85CC-C63614A96FB0} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {AF6CD304-8E03-433D-AAA2-6E0094B53071} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {ED3D7040-4B3F-4217-A75E-9DF63DD84707} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {CF48986A-B487-407F-98A7-97AED29C6A43} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {F5F80AEA-34F4-4E1D-8145-0634E9DCF2C3} = {CF48986A-B487-407F-98A7-97AED29C6A43} + {4EF958CA-B4A6-4E5F-924A-100B5615BEC3} = {F5F80AEA-34F4-4E1D-8145-0634E9DCF2C3} + {EB6E3DBD-C884-4241-9BC4-8281191D1F53} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {E1A463D7-2E23-4134-BE04-1EFF7A546813} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {93409CC3-8DF9-45FA-AE21-16A19FDEF650} = {9008B252-2DF7-404B-B626-D4497BB70A05} + {789C86D9-CE77-40DA-BDDD-979436952512} = {93409CC3-8DF9-45FA-AE21-16A19FDEF650} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} + EndGlobalSection +EndGlobal + diff --git a/build/manifest.ps1 b/build/manifest.ps1 index 76d28c9c108..177c66f10e3 100644 --- a/build/manifest.ps1 +++ b/build/manifest.ps1 @@ -24,6 +24,8 @@ $artifacts = @{ "Microsoft.Quantum.Development.Kit", "Microsoft.Quantum.EntryPointDriver", "Microsoft.Quantum.QSharp.Core", + "Microsoft.Quantum.Type1.Core", + "Microsoft.Quantum.Type2.Core", "Microsoft.Quantum.Runtime.Core", "Microsoft.Quantum.Simulators", "Microsoft.Quantum.Xunit" @@ -37,6 +39,9 @@ $artifacts = @{ ".\src\Simulation\Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Runtime.Core.dll", ".\src\Simulation\EntryPointDriver\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.EntryPointDriver.dll", ".\src\Simulation\QSharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll", + ".\src\Simulation\Type1Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Type1.Core.dll", + ".\src\Simulation\Type2Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Type2.Core.dll", + ".\src\Simulation\QSharpFoundation\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Foundation.dll", ".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll", ".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll", ".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll", diff --git a/build/pack.ps1 b/build/pack.ps1 index 359a59cc9f6..1389c98ba8e 100644 --- a/build/pack.ps1 +++ b/build/pack.ps1 @@ -65,7 +65,11 @@ 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/TargetDefinitions/Interfaces/Microsoft.Quantum.Targets.Interfaces.csproj' +Pack-Dotnet '../src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj' Pack-Dotnet '../src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj' +Pack-Dotnet '../src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj' +Pack-Dotnet '../src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj' Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec' Pack-One '../src/Quantum.Development.Kit/Microsoft.Quantum.Development.Kit.nuspec' Pack-One '../src/Xunit/Microsoft.Quantum.Xunit.csproj' diff --git a/src/Simulation/CSharpGeneration.Tests/SimulationCodeTests.fs b/src/Simulation/CSharpGeneration.Tests/SimulationCodeTests.fs index f62be54fc08..f1902a91616 100644 --- a/src/Simulation/CSharpGeneration.Tests/SimulationCodeTests.fs +++ b/src/Simulation/CSharpGeneration.Tests/SimulationCodeTests.fs @@ -1710,7 +1710,7 @@ namespace N1 let testOneSpecialization pick (_,op) expected = let context = createTestContext op - let actual = op |> pick |> buildSpecialization context |> Option.map (fst >> formatSyntaxTree) + let actual = op |> pick |> buildSpecialization context op |> Option.map (fst >> formatSyntaxTree) Assert.Equal(expected |> Option.map clearFormatting, actual |> Option.map clearFormatting) [] @@ -2315,7 +2315,7 @@ namespace N1 [] let ``is abstract`` () = let testOne (_,op) expected = - let actual = op |> isAbstract + let actual = op |> isIntrinsic Assert.Equal(expected, actual) true |> testOne emptyOperation diff --git a/src/Simulation/CSharpGeneration.Tests/Tests.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration.Tests/Tests.CSharpGeneration.fsproj index 1c5df88da96..0a421156c67 100644 --- a/src/Simulation/CSharpGeneration.Tests/Tests.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration.Tests/Tests.CSharpGeneration.fsproj @@ -52,10 +52,9 @@ - - + diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index a2d82a34698..a78b19dd7c0 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/CSharpGeneration/SimulationCode.fs b/src/Simulation/CSharpGeneration/SimulationCode.fs index 89e49873194..6b4029c0030 100644 --- a/src/Simulation/CSharpGeneration/SimulationCode.fs +++ b/src/Simulation/CSharpGeneration/SimulationCode.fs @@ -45,6 +45,15 @@ module SimulationCode = "Microsoft.Quantum.Simulation.Core" ] + let autoNamespacesWithInterfaces = + [ + "System" + "Microsoft.Quantum.Core" + "Microsoft.Quantum.Intrinsic" + "Microsoft.Quantum.Intrinsic.Interfaces" + "Microsoft.Quantum.Simulation.Core" + ] + let funcsAsProps = [ ("Length", { Namespace = "Microsoft.Quantum.Core"; Name = "Length" } ) ("Start", { Namespace = "Microsoft.Quantum.Core"; Name = "RangeStart" } ) @@ -69,16 +78,24 @@ module SimulationCode = let prependNamespaceString (name : QsQualifiedName) = name.Namespace.Replace (".", "__") + "__" + name.Name + let isConcreteIntrinsic (context:CodegenContext) = + match context.assemblyConstants.TryGetValue AssemblyConstants.GenerateConcreteIntrinsic with + | true, "false" -> false + | true, _ -> true + | false, _ -> false + let needsFullPath context (op:QsQualifiedName) = let hasMultipleDefinitions() = if context.byName.ContainsKey op.Name then context.byName.[op.Name].Length > 1 else false let sameNamespace = match context.current with | None -> false | Some n -> n.Namespace = op.Namespace + let namespaces = if isConcreteIntrinsic context then autoNamespacesWithInterfaces else autoNamespaces + if sameNamespace then false elif hasMultipleDefinitions() then true else - not (autoNamespaces |> List.contains op.Namespace) + not (namespaces |> List.contains op.Namespace) let getOpName context n = if isCurrentOp context n then Directives.Self @@ -913,6 +930,18 @@ module SimulationCode = ``{`` [] ``}`` :> MemberDeclarationSyntax + /// Returns the constructor for the given intrinsic operation. + let buildIntrinsicConstructor context name : MemberDeclarationSyntax = + ``constructor`` name ``(`` [ ("m", ``type`` "IOperationFactory") ] ``)`` + ``:`` [ "m" ] + [ ``public`` ] + ``{`` + [ + (``ident`` "this") <|.|> (``ident`` "Gate") <-- (``ident`` "m") |~> ("IGate_" + name) |> statement + ] + ``}`` + :> MemberDeclarationSyntax + /// For each Operation used in the given OperationDeclartion, returns /// a Property that returns an instance of the operation by calling the /// IOperationFactory @@ -957,41 +986,33 @@ module SimulationCode = (``=>`` newInstance) :> MemberDeclarationSyntax - let buildSpecializationBody context (sp:QsSpecialization) = + let buildSpecializationBody (context:CodegenContext) (op:QsCallable) (sp:QsSpecialization) = + let getInputVarWithInit args = + let inData = ``ident`` "__in__" + let name = function | ValidName n -> n | InvalidName -> "" + let rec buildVariableName = function + | QsTupleItem one -> one.VariableName |> name + | QsTuple many -> "(" + (many |> Seq.map buildVariableName |> String.concat ",") + ")" + match args with + | QsTupleItem one -> (one.VariableName |> name, []) + | QsTuple many -> + if many.Length = 0 then + ("__in__", []) + elif many.Length = 1 then + ("__in__", [ ``var`` (buildVariableName many.[0]) (``:=`` <| inData) ]) + else + ("__in__", [ ``var`` (buildVariableName args) (``:=`` <| inData) ]) match sp.Implementation with | Provided (args, _) -> - let returnType = sp.Signature.ReturnType + let argName, argsInit = getInputVarWithInit args let statements = let builder = new SyntaxBuilder(context) builder.Namespaces.OnSpecializationDeclaration sp |> ignore builder.BuiltStatements - - let inData = ``ident`` "__in__" let ret = - match returnType.Resolution with - | QsTypeKind.UnitType -> - [ - ``#line hidden`` <| - ``return`` ( Some ((``ident`` "QVoid") <|.|> (``ident`` "Instance")) ) - ] - | _ -> - [] - let (argName, argsInit) = -//TODO: diagnostics. - let name = function | ValidName n -> n | InvalidName -> "" - let rec buildVariableName = function - | QsTupleItem one -> one.VariableName |> name - | QsTuple many -> "(" + (many |> Seq.map buildVariableName |> String.concat ",") + ")" - match args with - | QsTupleItem one -> (one.VariableName |> name, []) - | QsTuple many -> - if many.Length = 0 then - ("__in__", []) - elif many.Length = 1 then - ("__in__", [ ``var`` (buildVariableName many.[0]) (``:=`` <| inData) ]) - else - ("__in__", [ ``var`` (buildVariableName args) (``:=`` <| inData) ]) - + match sp.Signature.ReturnType.Resolution with + | QsTypeKind.UnitType -> [ ``return`` ( Some ((``ident`` "QVoid") <|.|> (``ident`` "Instance")) ) |> ``#line hidden`` ] + | _ -> [] Some (``() => {}`` [ argName ] (argsInit @ statements @ ret) :> ExpressionSyntax) | Generated SelfInverse -> let adjointedBodyName = @@ -1001,10 +1022,50 @@ module SimulationCode = //TODO: diagnostics. | _ -> "__Body__" Some (``ident`` adjointedBodyName :> ExpressionSyntax) + | Intrinsic when isConcreteIntrinsic context -> + // Add in the control qubits parameter when dealing with a controlled spec + let args = + match sp.Kind with + | QsControlled | QsControlledAdjoint -> + let ctlVar = + let name = ValidName("__controlQubits__") + let varType = Qubit |> ResolvedType.New |> ArrayType |> ResolvedType.New + let info = InferredExpressionInformation.New(false, false) + let pos = QsNullable.Null + let range = Range.Zero + {VariableName = name; Type = varType; InferredInformation = info; Position = pos; Range = range} + match op.ArgumentTuple with + | QsTuple many when many.Length = 1 -> + QsTuple(ImmutableArray.Create(QsTupleItem(ctlVar), many.[0])) + | _ -> QsTuple(ImmutableArray.Create(QsTupleItem(ctlVar), op.ArgumentTuple)) + | _ -> op.ArgumentTuple + let argName, argsInit = getInputVarWithInit args + let specCall = + (userDefinedName None op.FullName.Name) + "__" + + match sp.Kind with + | QsBody -> "" + | QsAdjoint -> "Adjoint" + | QsControlled -> "Controlled" + | QsControlledAdjoint -> "ControlledAdjoint" + + "Body" + let name = function | ValidName n -> ``ident`` n | InvalidName -> ``ident`` "" + let rec argsToVars = function + | QsTupleItem one -> [one.VariableName |> name] + | QsTuple many -> many |> Seq.map argsToVars |> List.concat + let callExp = (``ident`` "Gate") <.> (``ident`` specCall, argsToVars args) + let statements = + match sp.Signature.ReturnType.Resolution with + | QsTypeKind.UnitType -> + [ + callExp |> statement + ``return`` ( Some ((``ident`` "QVoid") <|.|> (``ident`` "Instance")) ) |> ``#line hidden`` + ] + | _ -> [ ``return`` ( Some callExp ) ] + Some (``() => {}`` [ argName ] (argsInit @ statements) :> ExpressionSyntax) | _ -> None - let buildSpecialization context (sp:QsSpecialization) : (PropertyDeclarationSyntax * _) option = + let buildSpecialization context (op:QsCallable) (sp:QsSpecialization) : (PropertyDeclarationSyntax * _) option = let inType = roslynTypeName context sp.Signature.ArgumentType let outType = roslynTypeName context sp.Signature.ReturnType let propertyType = "Func<" + inType + ", " + outType + ">" @@ -1014,7 +1075,7 @@ module SimulationCode = | QsAdjoint -> "Adjoint" | QsControlled -> "Controlled" | QsControlledAdjoint -> "ControlledAdjoint" - let body = buildSpecializationBody context sp + let body = buildSpecializationBody context op sp let attributes = match sp.Location with | Null -> [] @@ -1217,6 +1278,10 @@ module SimulationCode = ``get`` (``=>`` (``literal`` name) ) :> MemberDeclarationSyntax + let buildGate name = + ``propg`` ("IGate_" + name) "Gate" [ ``private``; ``protected`` ] + :> MemberDeclarationSyntax + let buildFullName (name : QsQualifiedName) = let fqn = let ns = name.Namespace @@ -1336,7 +1401,7 @@ module SimulationCode = let nonGeneric = if typeParameters.IsEmpty then name else sprintf "%s<%s>" name (String.Join(",", typeParameters)) (name, nonGeneric) - let isAbstract op = + let isIntrinsic op = let isBody (sp:QsSpecialization) = match sp.Kind with | QsBody when sp.Implementation <> Intrinsic -> true | _ -> false not (op.Specializations |> Seq.exists isBody) @@ -1385,16 +1450,20 @@ module SimulationCode = let opNames = operationDependencies op let inType = op.Signature.ArgumentType |> roslynTypeName context let outType = op.Signature.ReturnType |> roslynTypeName context + let opIsIntrinsic = isIntrinsic op + let isConcreteIntrinsic = opIsIntrinsic && isConcreteIntrinsic context - let constructors = [ (buildConstructor context name) ] + let constructors = [ ((if isConcreteIntrinsic then buildIntrinsicConstructor else buildConstructor) context name) ] let properties = let opProperties = buildOpsProperties context opNames - buildName name :: - buildFullName context.current.Value :: - if globalContext.entryPoints |> Seq.contains op.FullName then - buildOperationInfoProperty globalContext inType outType nonGenericName :: - opProperties - else opProperties + [ + yield buildName name + yield buildFullName context.current.Value + if globalContext.entryPoints |> Seq.contains op.FullName then + yield buildOperationInfoProperty globalContext inType outType nonGenericName + if isConcreteIntrinsic then yield buildGate name + yield! opProperties + ] let baseOp = if isFunction op then @@ -1411,7 +1480,7 @@ module SimulationCode = let typeParameters = typeParametersNames op.Signature let baseClass = genericBase baseOp ``<<`` typeArgsInterface ``>>`` let bodies, attr = - op.Specializations |> Seq.map (buildSpecialization context) |> Seq.choose id |> Seq.toList + op.Specializations |> Seq.map (buildSpecialization context op) |> Seq.choose id |> Seq.toList |> List.map (fun (x, y) -> (x :> MemberDeclarationSyntax, y)) |> List.unzip let inData = (buildDataWrapper context "In" op.Signature.ArgumentType) let outData = (buildDataWrapper context "Out" op.Signature.ReturnType) @@ -1441,7 +1510,7 @@ module SimulationCode = let modifiers = let access = classAccessModifier op.Modifiers.Access - if isAbstract op then + if opIsIntrinsic && not isConcreteIntrinsic then [ access; ``abstract``; ``partial`` ] else [ access; ``partial`` ] @@ -1625,7 +1694,8 @@ module SimulationCode = // Builds the C# syntaxTree for the Q# elements defined in the given file. let buildSyntaxTree localElements (context : CodegenContext) = - let usings = autoNamespaces |> List.map (fun ns -> ``using`` ns) + let namespaces = if isConcreteIntrinsic context then autoNamespacesWithInterfaces else autoNamespaces + let usings = namespaces |> List.map (fun ns -> ``using`` ns) let attributes = localElements |> List.map (snd >> buildDeclarationAttributes) |> List.concat let namespaces = localElements |> List.map (buildNamespace context) diff --git a/src/Simulation/Common/AssemblyCommon.props b/src/Simulation/Common/AssemblyCommon.props index 79fb4f744d9..14c45ada66c 100644 --- a/src/Simulation/Common/AssemblyCommon.props +++ b/src/Simulation/Common/AssemblyCommon.props @@ -5,6 +5,12 @@ Microsoft Microsoft Quantum Development Kit Preview © Microsoft Corporation. All rights reserved. + See: https://docs.microsoft.com/en-us/quantum/relnotes/ + MIT + https://docs.microsoft.com/quantum/ + https://github.com/microsoft/qsharp-runtime + qdk-nuget-icon.png + true + false + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj b/src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj index aa91f7830d6..b5169a63955 100644 --- a/src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj +++ b/src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj @@ -8,14 +8,8 @@ - Microsoft Core support for the Q# runtime. - See: https://docs.microsoft.com/en-us/quantum/relnotes/ - MIT - https://github.com/microsoft/qsharp-runtime - qdk-nuget-icon.png Quantum Q# QSharp - true diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj b/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj index a2f5670195d..e78068c09ba 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj +++ b/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj @@ -31,6 +31,8 @@ + + diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 5a1e04f636c..c386ef1014f 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -99,11 +99,13 @@ 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" "Microsoft.Quantum.Simulation.Common" "Microsoft.Quantum.Simulators" + "Microsoft.Quantum.Targets.Interfaces" ] |> List.map (fun name -> upcast MetadataReference.CreateFromFile (referencedAssembly name)) diff --git a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj index d9ceccdd347..3a6aa416ac1 100644 --- a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj @@ -11,14 +11,8 @@ - Microsoft Entry point driver for Q# command line applications. - See: https://docs.microsoft.com/en-us/quantum/relnotes/ - MIT - https://github.com/microsoft/qsharp-runtime - qdk-nuget-icon.png Quantum Q# QSharp - true @@ -26,7 +20,6 @@ - diff --git a/src/Simulation/EntryPointDriver/Simulation.cs b/src/Simulation/EntryPointDriver/Simulation.cs index 88f9882777d..4e942364fe4 100644 --- a/src/Simulation/EntryPointDriver/Simulation.cs +++ b/src/Simulation/EntryPointDriver/Simulation.cs @@ -3,6 +3,8 @@ using System; using System.CommandLine.Parsing; +using System.Linq; +using System.Reflection; using System.Threading.Tasks; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; @@ -31,7 +33,15 @@ internal static async Task Simulate( { if (simulator == settings.ResourcesEstimatorName) { - var resourcesEstimator = new ResourcesEstimator(); + // Force the explicit load of the QSharp.Core assembly so that the ResourcesEstimator + // can discover it dynamically at runtime and override the defined callables. + var coreAssemblyName = + (from aName in entryPoint.GetType().Assembly.GetReferencedAssemblies() + where aName.Name == "Microsoft.Quantum.QSharp.Core" + select aName).First(); + var coreAssembly = Assembly.Load(coreAssemblyName.FullName); + + var resourcesEstimator = new ResourcesEstimator(coreAssembly); await resourcesEstimator.Run(entryPoint.CreateArgument(parseResult)); Console.WriteLine(resourcesEstimator.ToTSV()); } diff --git a/src/Simulation/QCTraceSimulator.Tests/CircuitTests.cs b/src/Simulation/QCTraceSimulator.Tests/CircuitTests.cs index 77e0891babb..f569d23d7d1 100644 --- a/src/Simulation/QCTraceSimulator.Tests/CircuitTests.cs +++ b/src/Simulation/QCTraceSimulator.Tests/CircuitTests.cs @@ -28,7 +28,7 @@ private static Action GetTest( IOperationFactory sim ) where T : AbstractCal [Fact] public void DistinctQubitsTests() { - QCTraceSimulator sim = new QCTraceSimulator( new QCTraceSimulatorConfiguration() { UseDistinctInputsChecker = true } ); + QCTraceSimulator sim = new QCTraceSimulator(new QCTraceSimulatorConfiguration() { UseDistinctInputsChecker = true } ); Assert.Throws(GetTest(sim)); Assert.Throws(GetTest(sim)); Assert.Throws(GetTest(sim)); diff --git a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj index 49f799ff786..c525c469ca0 100644 --- a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj +++ b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj @@ -1,4 +1,4 @@ - + @@ -13,6 +13,8 @@ + + diff --git a/src/Simulation/QSharpCore/Diagnostics/DeprecatedDiagnostics.qs b/src/Simulation/QSharpCore/Diagnostics/DeprecatedDiagnostics.qs deleted file mode 100644 index 05a0a31185d..00000000000 --- a/src/Simulation/QSharpCore/Diagnostics/DeprecatedDiagnostics.qs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Extensions.Diagnostics { - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.dumpmachine". - @Deprecated("Microsoft.Quantum.Diagnostics.DumpMachine") - function DumpMachine<'T> (location : 'T) : Unit { - return Microsoft.Quantum.Diagnostics.DumpMachine(location); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.dumpregister". - @Deprecated("Microsoft.Quantum.Diagnostics.DumpRegister") - function DumpRegister<'T> (location : 'T, qubits : Qubit[]) : Unit { - return Microsoft.Quantum.Diagnostics.DumpRegister(location, qubits); - } - -} diff --git a/src/Simulation/QSharpCore/Diagnostics/DeprecatedTesting.qs b/src/Simulation/QSharpCore/Diagnostics/DeprecatedTesting.qs deleted file mode 100644 index 22886674a90..00000000000 --- a/src/Simulation/QSharpCore/Diagnostics/DeprecatedTesting.qs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Extensions.Testing { - open Microsoft.Quantum.Math; - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertqubit". - @Deprecated("Microsoft.Quantum.Diagnostics.AssertQubit") - operation AssertQubit(expected : Result, q : Qubit) : Unit { - Microsoft.Quantum.Diagnostics.AssertQubit(expected, q); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertqubitwithintolerance". - @Deprecated("Microsoft.Quantum.Diagnostics.AssertQubitWithinTolerance") - operation AssertQubitTol(expected : Result, q : Qubit, tolerance : Double) : Unit { - Microsoft.Quantum.Diagnostics.AssertQubitWithinTolerance(expected, q, tolerance); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertqubitisinstatewithintolerance". - @Deprecated("Microsoft.Quantum.Diagnostics.AssertQubitIsInStateWithinTolerance") - operation AssertQubitState(expected : (Complex, Complex), register : Qubit, tolerance : Double) : Unit { - Microsoft.Quantum.Diagnostics.AssertQubitIsInStateWithinTolerance(expected, register, tolerance); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertoperationsequalreferenced". - /// Note that the order of the arguments to this operation has changed. - @Deprecated("Microsoft.Quantum.Diagnostics.AssertOperationsEqualReferenced") - operation AssertOperationsEqualReferenced(actual : (Qubit[] => Unit), expected : (Qubit[] => Unit is Adj), nQubits : Int) : Unit { - Microsoft.Quantum.Diagnostics.AssertOperationsEqualReferenced(nQubits, actual, expected); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertoperationsequalinplace". - /// Note that the order of the arguments to this operation has changed. - @Deprecated("Microsoft.Quantum.Diagnostics.AssertOperationsEqualInPlace") - operation AssertOperationsEqualInPlace(actual : (Qubit[] => Unit), expected : (Qubit[] => Unit is Adj), nQubits : Int) : Unit { - Microsoft.Quantum.Diagnostics.AssertOperationsEqualInPlace(nQubits, actual, expected); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertoperationsequalinplaceCompBasis". - /// Note that the order of the arguments to this operation has changed. - @Deprecated("Microsoft.Quantum.Diagnostics.AssertOperationsEqualInPlaceCompBasis") - operation AssertOperationsEqualInPlaceCompBasis(actual : (Qubit[] => Unit), expected : (Qubit[] => Unit is Adj), nQubits : Int) : Unit { - Microsoft.Quantum.Diagnostics.AssertOperationsEqualInPlaceCompBasis(nQubits, actual, expected); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertallzero". - @Deprecated("Microsoft.Quantum.Diagnostics.AssertAllZero") - operation AssertAllZero(qubits : Qubit[]) : Unit is Adj + Ctl { - Microsoft.Quantum.Diagnostics.AssertAllZero(qubits); - } - - /// # Deprecated - /// Please use @"microsoft.quantum.diagnostics.assertallzerowithintolerance". - @Deprecated("Microsoft.Quantum.Diagnostics.AssertAllZeroWithinTolerance") - operation AssertAllZeroTol(qubits : Qubit[], tolerance : Double) : Unit is Adj + Ctl { - Microsoft.Quantum.Diagnostics.AssertAllZeroWithinTolerance(qubits, tolerance); - } - -} diff --git a/src/Simulation/QSharpCore/Intrinsic.cs b/src/Simulation/QSharpCore/Intrinsic.cs index f7bbd4d953b..9433518163b 100644 --- a/src/Simulation/QSharpCore/Intrinsic.cs +++ b/src/Simulation/QSharpCore/Intrinsic.cs @@ -88,4 +88,113 @@ public partial class ResetAll return metadata; } } + + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimExp : Exp + { + public QSimExp(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimExpFrac : ExpFrac + { + public QSimExpFrac(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimH : H + { + public QSimH(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimM : M + { + public QSimM(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimMeasure : Measure + { + public QSimMeasure(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimR : R + { + public QSimR(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimRFrac : RFrac + { + public QSimRFrac(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimS : S + { + public QSimS(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimT : T + { + public QSimT(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimX : X + { + public QSimX(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimY : Y + { + public QSimY(IOperationFactory factory) : base(factory) + { + + } + } + + [Obsolete("This class is deprecated and will be removed in a future release. Considering using the corresponding callable class from 'Microsoft.Quantum.Intrinsic' directly.")] + public class QSimZ : Z + { + public QSimZ(IOperationFactory factory) : base(factory) + { + + } + } } diff --git a/src/Simulation/QSharpCore/Intrinsic.qs b/src/Simulation/QSharpCore/Intrinsic.qs deleted file mode 100644 index b2949e3ca96..00000000000 --- a/src/Simulation/QSharpCore/Intrinsic.qs +++ /dev/null @@ -1,695 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Intrinsic { - open Microsoft.Quantum.Math; - open Microsoft.Quantum.Convert; - open Microsoft.Quantum.Targeting; - - @Deprecated("Microsoft.Quantum.Random.DrawCategorical") - operation Random (probs : Double[]) : Int { - body intrinsic; - } - - @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurement") - operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit - is Adj + Ctl { - Microsoft.Quantum.Diagnostics.AssertMeasurement(bases, qubits, result, msg); - } - - @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurementProbability") - operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit - is Adj + Ctl { - Microsoft.Quantum.Diagnostics.AssertMeasurementProbability(bases, qubits, result, prob, msg, tol); - } - - - /// # 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 - //------------------------------------------------- - - /// # Summary - /// Performs the identity operation (no-op) on a single qubit. - /// - /// # Remarks - /// This is a no-op. It is provided for completeness and because - /// sometimes it is useful to call the identity in an algorithm or to pass it as a parameter. - operation I (target : Qubit) : Unit - is Adj + Ctl { - body (...) { } - adjoint self; - } - - - /// # Summary - /// Applies the Pauli $X$ gate. - /// - /// \begin{align} - /// \sigma_x \mathrel{:=} - /// \begin{bmatrix} - /// 0 & 1 \\\\ - /// 1 & 0 - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation X (qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - adjoint self; - } - - /// # Summary - /// Applies the Pauli $Y$ gate. - /// - /// \begin{align} - /// \sigma_y \mathrel{:=} - /// \begin{bmatrix} - /// 0 & -i \\\\ - /// i & 0 - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation Y (qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - adjoint self; - } - - - /// # Summary - /// Applies the Pauli $Z$ gate. - /// - /// \begin{align} - /// \sigma_z \mathrel{:=} - /// \begin{bmatrix} - /// 1 & 0 \\\\ - /// 0 & -1 - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation Z (qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - adjoint self; - } - - - /// # Summary - /// Applies the Hadamard transformation to a single qubit. - /// - /// \begin{align} - /// H \mathrel{:=} - /// \frac{1}{\sqrt{2}} - /// \begin{bmatrix} - /// 1 & 1 \\\\ - /// 1 & -1 - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation H (qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - adjoint self; - } - - - /// # Summary - /// Applies the S gate to a single qubit. - /// - /// # Description - /// This operation can be simulated by the unitary matrix - /// \begin{align} - /// S \mathrel{:=} - /// \begin{bmatrix} - /// 1 & 0 \\\\ - /// 0 & i - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation S(qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Applies the T gate to a single qubit. - /// - /// # Description - /// This operation can be simulated by the unitary matrix - /// \begin{align} - /// T \mathrel{:=} - /// \begin{bmatrix} - /// 1 & 0 \\\\ - /// 0 & e^{i \pi / 4} - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to which the gate should be applied. - operation T(qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Applies the controlled-NOT (CNOT) gate to a pair of qubits. - /// - /// \begin{align} - /// \operatorname{CNOT} \mathrel{:=} - /// \begin{bmatrix} - /// 1 & 0 & 0 & 0 \\\\ - /// 0 & 1 & 0 & 0 \\\\ - /// 0 & 0 & 0 & 1 \\\\ - /// 0 & 0 & 1 & 0 - /// \end{bmatrix}, - /// \end{align} - /// - /// where rows and columns are ordered as in the quantum concepts guide. - /// - /// # Input - /// ## control - /// Control qubit for the CNOT gate. - /// ## target - /// Target qubit for the CNOT gate. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// Controlled X([control], target); - /// ``` - operation CNOT (control : Qubit, target : Qubit) : Unit - is Adj + Ctl { - - body (...) { - Controlled X([control], target); - } - - adjoint self; - } - - - /// # Summary - /// Applies the doubly controlled–NOT (CCNOT) gate to three qubits. - /// - /// # Input - /// ## control1 - /// First control qubit for the CCNOT gate. - /// ## control2 - /// Second control qubit for the CCNOT gate. - /// ## target - /// Target qubit for the CCNOT gate. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// Controlled X([control1, control2], target); - /// ``` - operation CCNOT (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit - is Adj + Ctl { - body (...) { - Controlled X([control1, control2], target); - } - - adjoint self; - } - - - /// # Summary - /// Applies the SWAP gate to a pair of qubits. - /// - /// \begin{align} - /// \operatorname{SWAP} \mathrel{:=} - /// \begin{bmatrix} - /// 1 & 0 & 0 & 0 \\\\ - /// 0 & 0 & 1 & 0 \\\\ - /// 0 & 1 & 0 & 0 \\\\ - /// 0 & 0 & 0 & 1 - /// \end{bmatrix}, - /// \end{align} - /// - /// where rows and columns are ordered as in the quantum concepts guide. - /// - /// # Input - /// ## qubit1 - /// First qubit to be swapped. - /// ## qubit2 - /// Second qubit to be swapped. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// CNOT(qubit1, qubit2); - /// CNOT(qubit2, qubit1); - /// CNOT(qubit1, qubit2); - /// ``` - operation SWAP (qubit1 : Qubit, qubit2 : Qubit) : Unit - is Adj + Ctl { - body (...) - { - within { - CNOT(qubit1, qubit2); - } apply { - CNOT(qubit2, qubit1); - } - } - - adjoint self; - } - - //------------------------------------------------- - // Rotations - //------------------------------------------------- - - /// # Summary - /// Applies a rotation about the given Pauli axis. - /// - /// \begin{align} - /// R_{\mu}(\theta) \mathrel{:=} - /// e^{-i \theta \sigma_{\mu} / 2}, - /// \end{align} - /// where $\mu \in \{I, X, Y, Z\}$. - /// - /// # Input - /// ## pauli - /// Pauli operator ($\mu$) to be exponentiated to form the rotation. - /// ## theta - /// Angle about which the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// When called with `pauli = PauliI`, this operation applies - /// a *global phase*. This phase can be significant - /// when used with the `Controlled` functor. - operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Applies a rotation about the given Pauli axis by an angle specified - /// as a dyadic fraction. - /// - /// \begin{align} - /// R_{\mu}(n, k) \mathrel{:=} - /// e^{i \pi n \sigma_{\mu} / 2^k}, - /// \end{align} - /// where $\mu \in \{I, X, Y, Z\}$. - /// - /// > [!WARNING] - /// > This operation uses the **opposite** sign convention from - /// > @"microsoft.quantum.intrinsic.r". - /// - /// # Input - /// ## pauli - /// Pauli operator to be exponentiated to form the rotation. - /// ## numerator - /// Numerator in the dyadic fraction representation of the angle - /// by which the qubit is to be rotated. - /// ## power - /// Power of two specifying the denominator of the angle by which - /// the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// // PI() is a Q# function that returns an approximation of π. - /// R(pauli, -PI() * IntAsDouble(numerator) / IntAsDouble(2 ^ (power - 1)), qubit); - /// ``` - operation RFrac (pauli : Pauli, numerator : Int, power : Int, qubit : Qubit) : Unit - is Adj + Ctl { - - let angle = ((-2.0 * PI()) * IntAsDouble(numerator)) / IntAsDouble(2 ^ power); - R(pauli, angle, qubit); - } - - - /// # Summary - /// Applies a rotation about the $x$-axis by a given angle. - /// - /// \begin{align} - /// R_x(\theta) \mathrel{:=} - /// e^{-i \theta \sigma_x / 2} = - /// \begin{bmatrix} - /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ - /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## theta - /// Angle about which the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// R(PauliX, theta, qubit); - /// ``` - operation Rx (theta : Double, qubit : Qubit) : Unit - is Adj + Ctl { - body (...) - { - R(PauliX, theta, qubit); - } - - adjoint (...) - { - R(PauliX, -theta, qubit); - } - } - - - /// # Summary - /// Applies a rotation about the $y$-axis by a given angle. - /// - /// \begin{align} - /// R_y(\theta) \mathrel{:=} - /// e^{-i \theta \sigma_y / 2} = - /// \begin{bmatrix} - /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ - /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## theta - /// Angle about which the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// R(PauliY, theta, qubit); - /// ``` - operation Ry (theta : Double, qubit : Qubit) : Unit - is Adj + Ctl { - body (...) - { - R(PauliY, theta, qubit); - } - - adjoint (...) - { - R(PauliY, -theta, qubit); - } - } - - - /// # Summary - /// Applies a rotation about the $z$-axis by a given angle. - /// - /// \begin{align} - /// R_z(\theta) \mathrel{:=} - /// e^{-i \theta \sigma_z / 2} = - /// \begin{bmatrix} - /// e^{-i \theta / 2} & 0 \\\\ - /// 0 & e^{i \theta / 2} - /// \end{bmatrix}. - /// \end{align} - /// - /// # Input - /// ## theta - /// Angle about which the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// R(PauliZ, theta, qubit); - /// ``` - operation Rz (theta : Double, qubit : Qubit) : Unit - is Adj + Ctl { - body (...) - { - R(PauliZ, theta, qubit); - } - - adjoint (...) - { - R(PauliZ, -theta, qubit); - } - } - - - /// # Summary - /// Applies a rotation about the $\ket{1}$ state by a given angle. - /// - /// \begin{align} - /// R_1(\theta) \mathrel{:=} - /// \operatorname{diag}(1, e^{i\theta}). - /// \end{align} - /// - /// # Input - /// ## theta - /// Angle about which the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// R(PauliZ, theta, qubit); - /// R(PauliI, -theta, qubit); - /// ``` - operation R1 (theta : Double, qubit : Qubit) : Unit - is Adj + Ctl { - - R(PauliZ, theta, qubit); - R(PauliI, -theta, qubit); - } - - - /// # Summary - /// Applies a rotation about the $\ket{1}$ state by an angle specified - /// as a dyadic fraction. - /// - /// \begin{align} - /// R_1(n, k) \mathrel{:=} - /// \operatorname{diag}(1, e^{i \pi k / 2^n}). - /// \end{align} - /// - /// > [!WARNING] - /// > This operation uses the **opposite** sign convention from - /// > @"microsoft.quantum.intrinsic.r", and does not include the - /// > factor of $1/ 2$ included by @"microsoft.quantum.intrinsic.r1". - /// - /// # Input - /// ## numerator - /// Numerator in the dyadic fraction representation of the angle - /// by which the qubit is to be rotated. - /// ## power - /// Power of two specifying the denominator of the angle by which - /// the qubit is to be rotated. - /// ## qubit - /// Qubit to which the gate should be applied. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// RFrac(PauliZ, -numerator, denominator + 1, qubit); - /// RFrac(PauliI, numerator, denominator + 1, qubit); - /// ``` - operation R1Frac (numerator : Int, power : Int, qubit : Qubit) : Unit - is Adj + Ctl { - - RFrac(PauliZ, -numerator, power + 1, qubit); - RFrac(PauliI, numerator, power + 1, qubit); - } - - - /// # Summary - /// Applies the exponential of a multi-qubit Pauli operator. - /// - /// \begin{align} - /// e^{i \theta [P_0 \otimes P_1 \cdots P_{N-1}]}, - /// \end{align} - /// where $P_i$ is the $i$th element of `paulis`, and where - /// $N = $`Length(paulis)`. - /// - /// # Input - /// ## paulis - /// Array of single-qubit Pauli values indicating the tensor product - /// factors on each qubit. - /// ## theta - /// Angle about the given multi-qubit Pauli operator by which the - /// target register is to be rotated. - /// ## qubits - /// Register to apply the given rotation to. - operation Exp (paulis : Pauli[], theta : Double, qubits : Qubit[]) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Applies the exponential of a multi-qubit Pauli operator - /// with an argument given by a dyadic fraction. - /// - /// \begin{align} - /// e^{i \pi k [P_0 \otimes P_1 \cdots P_{N-1}] / 2^n}, - /// \end{align} - /// where $P_i$ is the $i$th element of `paulis`, and where - /// $N = $`Length(paulis)`. - /// - /// # Input - /// ## paulis - /// Array of single-qubit Pauli values indicating the tensor product - /// factors on each qubit. - /// ## numerator - /// Numerator ($k$) in the dyadic fraction representation of the angle - /// by which the qubit register is to be rotated. - /// ## power - /// Power of two ($n$) specifying the denominator of the angle by which - /// the qubit register is to be rotated. - /// ## qubits - /// Register to apply the given rotation to. - operation ExpFrac (paulis : Pauli[], numerator : Int, power : Int, qubits : Qubit[]) : Unit - is Adj + Ctl { - let angle = (PI() * IntAsDouble(numerator)) / IntAsDouble(2 ^ power); - Exp(paulis, angle, qubits); - } - - - //------------------------------------------------- - // Measurements - //------------------------------------------------- - - /// # Summary - /// Performs a joint measurement of one or more qubits in the - /// specified Pauli bases. - /// - /// The output result is given by the distribution: - /// \begin{align} - /// \Pr(\texttt{Zero} | \ket{\psi}) = - /// \frac12 \braket{ - /// \psi \mid| - /// \left( - /// \boldone + P_0 \otimes P_1 \otimes \cdots \otimes P_{N-1} - /// \right) \mid| - /// \psi - /// }, - /// \end{align} - /// where $P_i$ is the $i$th element of `bases`, and where - /// $N = \texttt{Length}(\texttt{bases})$. - /// That is, measurement returns a `Result` $d$ such that the eigenvalue of the - /// observed measurement effect is $(-1)^d$. - /// - /// # Input - /// ## bases - /// Array of single-qubit Pauli values indicating the tensor product - /// factors on each qubit. - /// ## qubits - /// Register of qubits to be measured. - /// - /// # Output - /// `Zero` if the $+1$ eigenvalue is observed, and `One` if - /// the $-1$ eigenvalue is observed. - /// - /// # Remarks - /// If the basis array and qubit array are different lengths, then the - /// operation will fail. - operation Measure (bases : Pauli[], qubits : Qubit[]) : Result { - body intrinsic; - } - - - /// # Summary - /// Performs a measurement of a single qubit in the - /// Pauli $Z$ basis. - /// - /// The output result is given by - /// the distribution - /// \begin{align} - /// \Pr(\texttt{Zero} | \ket{\psi}) = - /// \braket{\psi | 0} \braket{0 | \psi}. - /// \end{align} - /// - /// # Input - /// ## qubit - /// Qubit to be measured. - /// - /// # Output - /// `Zero` if the $+1$ eigenvalue is observed, and `One` if - /// the $-1$ eigenvalue is observed. - /// - /// # Remarks - /// Equivalent to: - /// ```qsharp - /// Measure([PauliZ], [qubit]); - /// ``` - operation M (qubit : Qubit) : Result { - return Measure([PauliZ], [qubit]); - } - - - /// # Summary - /// Given a single qubit, measures it and ensures it is in the |0⟩ state - /// such that it can be safely released. - /// - /// # Input - /// ## target - /// The qubit whose state is to be reset to $\ket{0}$. - @RequiresCapability( - "BasicQuantumFunctionality", - "Reset is replaced by a supported implementation on all execution targets." - ) - operation Reset (target : Qubit) : Unit { - if (M(target) == One) { - X(target); - } - } - - - /// # Summary - /// Given an array of qubits, measure them and ensure they are in the |0⟩ state - /// such that they can be safely released. - /// - /// # Input - /// ## qubits - /// An array of qubits whose states are to be reset to $\ket{0}$. - operation ResetAll (qubits : Qubit[]) : Unit { - for (qubit in qubits) { - Reset(qubit); - } - } -} diff --git a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj index 3077b66fa29..a16d65c78a0 100644 --- a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -1,44 +1,13 @@ - + - - + - netstandard2.1 - true - false - false - detailed - - - - Microsoft Core support for the Q# programming language. - See: https://docs.microsoft.com/en-us/quantum/relnotes/ - MIT - https://github.com/microsoft/qsharp-runtime - qdk-nuget-icon.png - Quantum Q# QSharp - true - + true + - - - - - - - - - - + - - - - - - - diff --git a/src/Simulation/QSharpCore/Properties/AssemblyInfo.cs b/src/Simulation/QSharpCore/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..109c9a91f80 --- /dev/null +++ b/src/Simulation/QSharpCore/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allow the simulator assembly to use our internal methods +[assembly: InternalsVisibleTo("Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)] \ No newline at end of file diff --git a/src/Simulation/Simulators/QuantumProcessor/Allocate.cs b/src/Simulation/QSharpCore/QuantumProcessor/Allocate.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Allocate.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Allocate.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Assert.cs b/src/Simulation/QSharpCore/QuantumProcessor/Assert.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Assert.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Assert.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/AssertProb.cs b/src/Simulation/QSharpCore/QuantumProcessor/AssertProb.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/AssertProb.cs rename to src/Simulation/QSharpCore/QuantumProcessor/AssertProb.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Borrow.cs b/src/Simulation/QSharpCore/QuantumProcessor/Borrow.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Borrow.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Borrow.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/ClassicalControl.cs b/src/Simulation/QSharpCore/QuantumProcessor/ClassicalControl.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/ClassicalControl.cs rename to src/Simulation/QSharpCore/QuantumProcessor/ClassicalControl.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Dump.cs b/src/Simulation/QSharpCore/QuantumProcessor/Dump.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Dump.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Dump.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Exp.cs b/src/Simulation/QSharpCore/QuantumProcessor/Exp.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Exp.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Exp.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/ExpFrac.cs b/src/Simulation/QSharpCore/QuantumProcessor/ExpFrac.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/ExpFrac.cs rename to src/Simulation/QSharpCore/QuantumProcessor/ExpFrac.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/H.cs b/src/Simulation/QSharpCore/QuantumProcessor/H.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/H.cs rename to src/Simulation/QSharpCore/QuantumProcessor/H.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/M.cs b/src/Simulation/QSharpCore/QuantumProcessor/M.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/M.cs rename to src/Simulation/QSharpCore/QuantumProcessor/M.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Measure.cs b/src/Simulation/QSharpCore/QuantumProcessor/Measure.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Measure.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Measure.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/QuantumProcessorDispatcher.cs b/src/Simulation/QSharpCore/QuantumProcessor/QuantumProcessorDispatcher.cs similarity index 82% rename from src/Simulation/Simulators/QuantumProcessor/QuantumProcessorDispatcher.cs rename to src/Simulation/QSharpCore/QuantumProcessor/QuantumProcessorDispatcher.cs index 0865e201a4e..fddf8466ff0 100644 --- a/src/Simulation/Simulators/QuantumProcessor/QuantumProcessorDispatcher.cs +++ b/src/Simulation/QSharpCore/QuantumProcessor/QuantumProcessorDispatcher.cs @@ -29,7 +29,8 @@ public IQuantumProcessor QuantumProcessor /// An instance of a class implementing interface to be wrapped. /// An instance of a class implementing interface. If the parameter is null is used. /// A seed to be used by Q# Microsoft.Quantum.Intrinsic.Random operation. - public QuantumProcessorDispatcher(IQuantumProcessor quantumProcessor, IQubitManager? qubitManager = null, int? randomSeed = null) + /// A boolean that indicates whether only Q# callables that are defined as body intrinsic should be overridden. If false, the C# implementation will always override any Q# implementation. If true, the C# will only override Q# that does not have an implementation and is marked as body intrinsic. The value is false by default. + public QuantumProcessorDispatcher(IQuantumProcessor quantumProcessor, IQubitManager? qubitManager = null, int? randomSeed = null, bool onlyOverrideBodyIntrinsic = false) : base( qubitManager ?? new QubitManager( PreallocatedQubitCount, diff --git a/src/Simulation/Simulators/QuantumProcessor/R.cs b/src/Simulation/QSharpCore/QuantumProcessor/R.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/R.cs rename to src/Simulation/QSharpCore/QuantumProcessor/R.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/R1.cs b/src/Simulation/QSharpCore/QuantumProcessor/R1.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/R1.cs rename to src/Simulation/QSharpCore/QuantumProcessor/R1.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/R1Frac.cs b/src/Simulation/QSharpCore/QuantumProcessor/R1Frac.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/R1Frac.cs rename to src/Simulation/QSharpCore/QuantumProcessor/R1Frac.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/RFrac.cs b/src/Simulation/QSharpCore/QuantumProcessor/RFrac.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/RFrac.cs rename to src/Simulation/QSharpCore/QuantumProcessor/RFrac.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/random.cs b/src/Simulation/QSharpCore/QuantumProcessor/Random.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/random.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Random.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Release.cs b/src/Simulation/QSharpCore/QuantumProcessor/Release.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Release.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Release.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Reset.cs b/src/Simulation/QSharpCore/QuantumProcessor/Reset.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Reset.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Reset.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Return.cs b/src/Simulation/QSharpCore/QuantumProcessor/Return.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Return.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Return.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/S.cs b/src/Simulation/QSharpCore/QuantumProcessor/S.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/S.cs rename to src/Simulation/QSharpCore/QuantumProcessor/S.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/SWAP.cs b/src/Simulation/QSharpCore/QuantumProcessor/SWAP.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/SWAP.cs rename to src/Simulation/QSharpCore/QuantumProcessor/SWAP.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/T.cs b/src/Simulation/QSharpCore/QuantumProcessor/T.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/T.cs rename to src/Simulation/QSharpCore/QuantumProcessor/T.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/X.cs b/src/Simulation/QSharpCore/QuantumProcessor/X.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/X.cs rename to src/Simulation/QSharpCore/QuantumProcessor/X.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Y.cs b/src/Simulation/QSharpCore/QuantumProcessor/Y.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Y.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Y.cs diff --git a/src/Simulation/Simulators/QuantumProcessor/Z.cs b/src/Simulation/QSharpCore/QuantumProcessor/Z.cs similarity index 100% rename from src/Simulation/Simulators/QuantumProcessor/Z.cs rename to src/Simulation/QSharpCore/QuantumProcessor/Z.cs diff --git a/src/Simulation/QSharpCore/Reset.qs b/src/Simulation/QSharpCore/Reset.qs deleted file mode 100644 index f69ef1a6785..00000000000 --- a/src/Simulation/QSharpCore/Reset.qs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Measurement { - open Microsoft.Quantum.Intrinsic; - open Microsoft.Quantum.Targeting; - - internal operation BasisChangeZtoY(target : Qubit) : Unit is Adj + Ctl { - H(target); - S(target); - } - - - /// # Summary - /// Sets a qubit to a given computational basis state by measuring the - /// qubit and applying a bit flip if needed. - /// - /// # Input - /// ## desired - /// The basis state that the qubit should be set to. - /// ## target - /// The qubit whose state is to be set. - /// - /// # Remarks - /// As an invariant of this operation, calling `M(q)` immediately - /// after `SetToBasisState(result, q)` will return `result`. - operation SetToBasisState(desired : Result, target : Qubit) : Unit { - if (desired != M(target)) { - X(target); - } - } - - /// # Summary - /// Measures a single qubit in the Z basis, - /// and resets it to a fixed initial state - /// following the measurement. - /// - /// # Description - /// Performs a single-qubit measurement in the $Z$-basis, - /// and ensures that the qubit is returned to $\ket{0}$ - /// following the measurement. - /// - /// # Input - /// ## target - /// A single qubit to be measured. - /// - /// # Output - /// The result of measuring `target` in the Pauli $Z$ basis. - @RequiresCapability( - "BasicQuantumFunctionality", - "MResetZ is replaced by a supported implementation on all execution targets." - ) - operation MResetZ (target : Qubit) : Result { - let result = M(target); - - if (result == One) { - // Recall that the +1 eigenspace of a measurement operator corresponds to - // the Result case Zero. Thus, if we see a One case, we must reset the state - // have +1 eigenvalue. - X(target); - } - - return result; - } - - - /// # Summary - /// Measures a single qubit in the X basis, - /// and resets it to a fixed initial state - /// following the measurement. - /// - /// # Description - /// Performs a single-qubit measurement in the $X$-basis, - /// and ensures that the qubit is returned to $\ket{0}$ - /// following the measurement. - /// - /// # Input - /// ## target - /// A single qubit to be measured. - /// - /// # Output - /// The result of measuring `target` in the Pauli $X$ basis. - @RequiresCapability( - "BasicQuantumFunctionality", - "MResetX is replaced by a supported implementation on all execution targets." - ) - operation MResetX (target : Qubit) : Result { - let result = Measure([PauliX], [target]); - - // We must return the qubit to the Z basis as well. - H(target); - - if (result == One) { - // Recall that the +1 eigenspace of a measurement operator corresponds to - // the Result case Zero. Thus, if we see a One case, we must reset the state - // have +1 eigenvalue. - X(target); - } - - return result; - } - - - /// # Summary - /// Measures a single qubit in the Y basis, - /// and resets it to a fixed initial state - /// following the measurement. - /// - /// # Description - /// Performs a single-qubit measurement in the $Y$-basis, - /// and ensures that the qubit is returned to $\ket{0}$ - /// following the measurement. - /// - /// # Input - /// ## target - /// A single qubit to be measured. - /// - /// # Output - /// The result of measuring `target` in the Pauli $Y$ basis. - @RequiresCapability( - "BasicQuantumFunctionality", - "MResetY is replaced by a supported implementation on all execution targets." - ) - operation MResetY (target : Qubit) : Result { - let result = Measure([PauliY], [target]); - - // We must return the qubit to the Z basis as well. - Adjoint BasisChangeZtoY(target); - - if (result == One) { - // Recall that the +1 eigenspace of a measurement operator corresponds to - // the Result case Zero. Thus, if we see a One case, we must reset the state - // have +1 eigenvalue. - X(target); - } - - return result; - } - -} diff --git a/src/Simulation/QSharpCore/Arrays/Empty.cs b/src/Simulation/QSharpFoundation/Arrays/Empty.cs similarity index 100% rename from src/Simulation/QSharpCore/Arrays/Empty.cs rename to src/Simulation/QSharpFoundation/Arrays/Empty.cs diff --git a/src/Simulation/QSharpCore/Arrays/Empty.qs b/src/Simulation/QSharpFoundation/Arrays/Empty.qs similarity index 100% rename from src/Simulation/QSharpCore/Arrays/Empty.qs rename to src/Simulation/QSharpFoundation/Arrays/Empty.qs diff --git a/src/Simulation/QSharpCore/Arrays/Enumeration.qs b/src/Simulation/QSharpFoundation/Arrays/Enumeration.qs similarity index 91% rename from src/Simulation/QSharpCore/Arrays/Enumeration.qs rename to src/Simulation/QSharpFoundation/Arrays/Enumeration.qs index 2b271c2a7cb..ee6a459d21f 100644 --- a/src/Simulation/QSharpCore/Arrays/Enumeration.qs +++ b/src/Simulation/QSharpFoundation/Arrays/Enumeration.qs @@ -2,9 +2,6 @@ // Licensed under the MIT License. namespace Microsoft.Quantum.Arrays { - open Microsoft.Quantum.Intrinsic; - open Microsoft.Quantum.Canon; - /// # Summary /// Given an array, returns a range over the indices of that array, suitable /// for use in a for loop. @@ -29,5 +26,4 @@ namespace Microsoft.Quantum.Arrays { function IndexRange<'TElement>(array : 'TElement[]) : Range { return 0..(Length(array) - 1); } - } diff --git a/src/Simulation/QSharpFoundation/Assert.qs b/src/Simulation/QSharpFoundation/Assert.qs new file mode 100644 index 00000000000..30832b83767 --- /dev/null +++ b/src/Simulation/QSharpFoundation/Assert.qs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurement") + operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit + is Adj + Ctl { + Microsoft.Quantum.Diagnostics.AssertMeasurement(bases, qubits, result, msg); + } + + @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurementProbability") + operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit + is Adj + Ctl { + Microsoft.Quantum.Diagnostics.AssertMeasurementProbability(bases, qubits, result, prob, msg, tol); + } +} \ No newline at end of file diff --git a/src/Simulation/QSharpCore/Bitwise/Bitwise.cs b/src/Simulation/QSharpFoundation/Bitwise/Bitwise.cs similarity index 100% rename from src/Simulation/QSharpCore/Bitwise/Bitwise.cs rename to src/Simulation/QSharpFoundation/Bitwise/Bitwise.cs diff --git a/src/Simulation/QSharpCore/Bitwise/Bitwise.qs b/src/Simulation/QSharpFoundation/Bitwise/Bitwise.qs similarity index 100% rename from src/Simulation/QSharpCore/Bitwise/Bitwise.qs rename to src/Simulation/QSharpFoundation/Bitwise/Bitwise.qs diff --git a/src/Simulation/QSharpCore/Bitwise/Deprecated.qs b/src/Simulation/QSharpFoundation/Bitwise/Deprecated.qs similarity index 100% rename from src/Simulation/QSharpCore/Bitwise/Deprecated.qs rename to src/Simulation/QSharpFoundation/Bitwise/Deprecated.qs diff --git a/src/Simulation/QSharpCore/Canon/NoOp.qs b/src/Simulation/QSharpFoundation/Canon/NoOp.qs similarity index 100% rename from src/Simulation/QSharpCore/Canon/NoOp.qs rename to src/Simulation/QSharpFoundation/Canon/NoOp.qs diff --git a/src/Simulation/QSharpCore/ClassicalControl.qs b/src/Simulation/QSharpFoundation/ClassicalControl.qs similarity index 99% rename from src/Simulation/QSharpCore/ClassicalControl.qs rename to src/Simulation/QSharpFoundation/ClassicalControl.qs index f26320286bc..05ea7392569 100644 --- a/src/Simulation/QSharpCore/ClassicalControl.qs +++ b/src/Simulation/QSharpFoundation/ClassicalControl.qs @@ -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. diff --git a/src/Simulation/QSharpCore/Convert/Convert.cs b/src/Simulation/QSharpFoundation/Convert/Convert.cs similarity index 100% rename from src/Simulation/QSharpCore/Convert/Convert.cs rename to src/Simulation/QSharpFoundation/Convert/Convert.cs diff --git a/src/Simulation/QSharpCore/Convert/Convert.qs b/src/Simulation/QSharpFoundation/Convert/Convert.qs similarity index 100% rename from src/Simulation/QSharpCore/Convert/Convert.qs rename to src/Simulation/QSharpFoundation/Convert/Convert.qs diff --git a/src/Simulation/QSharpCore/Convert/Deprecated.qs b/src/Simulation/QSharpFoundation/Convert/Deprecated.qs similarity index 100% rename from src/Simulation/QSharpCore/Convert/Deprecated.qs rename to src/Simulation/QSharpFoundation/Convert/Deprecated.qs diff --git a/src/Simulation/QSharpCore/Core.cs b/src/Simulation/QSharpFoundation/Core.cs similarity index 100% rename from src/Simulation/QSharpCore/Core.cs rename to src/Simulation/QSharpFoundation/Core.cs diff --git a/src/Simulation/QSharpCore/Core.qs b/src/Simulation/QSharpFoundation/Core.qs similarity index 96% rename from src/Simulation/QSharpCore/Core.qs rename to src/Simulation/QSharpFoundation/Core.qs index fe4a5d02e50..efcb9fceb1d 100644 --- a/src/Simulation/QSharpCore/Core.qs +++ b/src/Simulation/QSharpFoundation/Core.qs @@ -61,6 +61,10 @@ namespace Microsoft.Quantum.Core { /// # Summary /// Returns the defined start value of the given range. /// + /// # Input + /// ## range + /// Input range. + /// /// # Output /// The defined start value of the given range. /// @@ -81,7 +85,7 @@ namespace Microsoft.Quantum.Core { /// which is not necessarily the last element in the sequence. /// /// # Input - /// ## r + /// ## range /// Input range. /// /// # Output @@ -103,7 +107,7 @@ namespace Microsoft.Quantum.Core { /// Returns the integer that specifies how the next value of a range is calculated. /// /// # Input - /// ## r + /// ## range /// Input range. /// /// # Output @@ -121,7 +125,7 @@ namespace Microsoft.Quantum.Core { /// Returns a new range which is the reverse of the input range. /// /// # Input - /// ## r + /// ## range /// Input range. /// /// # Output @@ -130,7 +134,7 @@ namespace Microsoft.Quantum.Core { /// # Remarks /// Note that the reverse of a range is not simply `end`..`-step`..`start`, because /// the actual last element of a range may not be the same as `end`. - function RangeReverse(r : Range) : Range { + function RangeReverse(range : Range) : Range { body intrinsic; } diff --git a/src/Simulation/QSharpCore/Diagnostics/Assert.qs b/src/Simulation/QSharpFoundation/Diagnostics/Assert.qs similarity index 95% rename from src/Simulation/QSharpCore/Diagnostics/Assert.qs rename to src/Simulation/QSharpFoundation/Diagnostics/Assert.qs index 6f5cb339633..9b0635279a9 100644 --- a/src/Simulation/QSharpCore/Diagnostics/Assert.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/Assert.qs @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -namespace Microsoft.Quantum.Diagnostics { - open Microsoft.Quantum.Intrinsic; - open Microsoft.Quantum.Canon; - +namespace Microsoft.Quantum.Diagnostics { /// # Summary /// Asserts that measuring the given qubits in the given Pauli basis will /// always have the given result. diff --git a/src/Simulation/QSharpCore/Diagnostics/AssertAllZero.qs b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs similarity index 98% rename from src/Simulation/QSharpCore/Diagnostics/AssertAllZero.qs rename to src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs index c8c850a650f..52470a92f13 100644 --- a/src/Simulation/QSharpCore/Diagnostics/AssertAllZero.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs @@ -9,7 +9,7 @@ namespace Microsoft.Quantum.Diagnostics { /// Assert that given qubits are all in $\ket{0}$ state. /// /// # Input - /// ## target + /// ## qubits /// Qubits that are asserted to be in $\ket{0}$ state. /// /// # See Also diff --git a/src/Simulation/QSharpCore/Diagnostics/AssertQubit.qs b/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs similarity index 87% rename from src/Simulation/QSharpCore/Diagnostics/AssertQubit.qs rename to src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs index 73515859c7e..04934d1d988 100644 --- a/src/Simulation/QSharpCore/Diagnostics/AssertQubit.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs @@ -22,7 +22,7 @@ namespace Microsoft.Quantum.Diagnostics { /// allows for asserting /// arbitrary qubit states rather than only $Z$ eigenstates. operation AssertQubit (expected : Result, q : Qubit) : Unit { - Assert([PauliZ], [q], expected, $"Qubit in invalid state. Expecting: {expected}"); + AssertMeasurement([PauliZ], [q], expected, $"Qubit in invalid state. Expecting: {expected}"); } /// # Summary @@ -47,7 +47,7 @@ namespace Microsoft.Quantum.Diagnostics { /// allows for asserting /// arbitrary qubit states rather than only $Z$ eigenstates. operation AssertQubitWithinTolerance(expected : Result, q : Qubit, tolerance : Double) : Unit { - AssertProb([PauliZ], [q], expected, 1.0, $"Qubit in invalid state. Expecting: {expected} with tolerance {tolerance}", tolerance); + AssertMeasurementProbability([PauliZ], [q], expected, 1.0, $"Qubit in invalid state. Expecting: {expected} with tolerance {tolerance}", tolerance); } /// # Summary @@ -126,10 +126,10 @@ namespace Microsoft.Quantum.Diagnostics { // Probability of getting outcome One in measuring PauliZ is Tr(M(I-Z)/2) = (mi-mz)/2.0 // similarly, we find the probabilities for measuring PauliX,PauliY let tol = tolerance / 2.0; - AssertProb([PauliX], [register], Zero, (mi + mx) / 2.0, $"Qubit Zero probability on X basis failed", tol); - AssertProb([PauliY], [register], Zero, (mi + my) / 2.0, $"Qubit Zero probability on Y basis failed", tol); - AssertProb([PauliZ], [register], Zero, (mi + mz) / 2.0, $"Qubit Zero probability on Z basis failed", tol); - AssertProb([PauliZ], [register], One, (mi - mz) / 2.0, $"Qubit One probability on Z basis failed", tol); + AssertMeasurementProbability([PauliX], [register], Zero, (mi + mx) / 2.0, $"Qubit Zero probability on X basis failed", tol); + AssertMeasurementProbability([PauliY], [register], Zero, (mi + my) / 2.0, $"Qubit Zero probability on Y basis failed", tol); + AssertMeasurementProbability([PauliZ], [register], Zero, (mi + mz) / 2.0, $"Qubit Zero probability on Z basis failed", tol); + AssertMeasurementProbability([PauliZ], [register], One, (mi - mz) / 2.0, $"Qubit One probability on Z basis failed", tol); } } diff --git a/src/Simulation/QSharpCore/Diagnostics/Dump.qs b/src/Simulation/QSharpFoundation/Diagnostics/Dump.qs similarity index 98% rename from src/Simulation/QSharpCore/Diagnostics/Dump.qs rename to src/Simulation/QSharpFoundation/Diagnostics/Dump.qs index 6484a93cc35..316b3305290 100644 --- a/src/Simulation/QSharpCore/Diagnostics/Dump.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/Dump.qs @@ -26,6 +26,7 @@ namespace Microsoft.Quantum.Diagnostics { /// one-dimensional array of complex numbers, in which each element represents /// the amplitudes of the probability of measuring the corresponding state. function DumpMachine<'T> (location : 'T) : Unit { + body intrinsic; } /// # Summary @@ -56,6 +57,7 @@ namespace Microsoft.Quantum.Diagnostics { /// If the given qubits are entangled with some other qubit and their /// state can't be separated, it just reports that the qubits are entangled. function DumpRegister<'T> (location : 'T, qubits : Qubit[]) : Unit { + body intrinsic; } } diff --git a/src/Simulation/QSharpCore/Diagnostics/Facts.qs b/src/Simulation/QSharpFoundation/Diagnostics/Facts.qs similarity index 100% rename from src/Simulation/QSharpCore/Diagnostics/Facts.qs rename to src/Simulation/QSharpFoundation/Diagnostics/Facts.qs diff --git a/src/Simulation/QSharpCore/Diagnostics/Properties/NamespaceInfo.qs b/src/Simulation/QSharpFoundation/Diagnostics/Properties/NamespaceInfo.qs similarity index 100% rename from src/Simulation/QSharpCore/Diagnostics/Properties/NamespaceInfo.qs rename to src/Simulation/QSharpFoundation/Diagnostics/Properties/NamespaceInfo.qs diff --git a/src/Simulation/QSharpCore/Diagnostics/UnitTests.qs b/src/Simulation/QSharpFoundation/Diagnostics/UnitTests.qs similarity index 100% rename from src/Simulation/QSharpCore/Diagnostics/UnitTests.qs rename to src/Simulation/QSharpFoundation/Diagnostics/UnitTests.qs diff --git a/src/Simulation/QSharpCore/Environment.qs b/src/Simulation/QSharpFoundation/Environment.qs similarity index 95% rename from src/Simulation/QSharpCore/Environment.qs rename to src/Simulation/QSharpFoundation/Environment.qs index 145a9f0d645..9f5018d1fc4 100644 --- a/src/Simulation/QSharpCore/Environment.qs +++ b/src/Simulation/QSharpFoundation/Environment.qs @@ -15,7 +15,7 @@ namespace Microsoft.Quantum.Environment { /// # See Also /// - GetQubitsAvailableToBorrow operation GetQubitsAvailableToUse () : Int { - return -1; + body intrinsic; } /// # Summary @@ -30,7 +30,7 @@ namespace Microsoft.Quantum.Environment { /// # See Also /// - GetQubitsAvailableToUse operation GetQubitsAvailableToBorrow () : Int { - return -1; + body intrinsic; } } diff --git a/src/Simulation/QSharpCore/Math/Constants.qs b/src/Simulation/QSharpFoundation/Math/Constants.qs similarity index 100% rename from src/Simulation/QSharpCore/Math/Constants.qs rename to src/Simulation/QSharpFoundation/Math/Constants.qs diff --git a/src/Simulation/QSharpCore/Math/Deprecated.qs b/src/Simulation/QSharpFoundation/Math/Deprecated.qs similarity index 100% rename from src/Simulation/QSharpCore/Math/Deprecated.qs rename to src/Simulation/QSharpFoundation/Math/Deprecated.qs diff --git a/src/Simulation/QSharpCore/Math/Math.cs b/src/Simulation/QSharpFoundation/Math/Math.cs similarity index 100% rename from src/Simulation/QSharpCore/Math/Math.cs rename to src/Simulation/QSharpFoundation/Math/Math.cs diff --git a/src/Simulation/QSharpCore/Math/Math.qs b/src/Simulation/QSharpFoundation/Math/Math.qs similarity index 100% rename from src/Simulation/QSharpCore/Math/Math.qs rename to src/Simulation/QSharpFoundation/Math/Math.qs diff --git a/src/Simulation/QSharpCore/Math/Trig.qs b/src/Simulation/QSharpFoundation/Math/Trig.qs similarity index 100% rename from src/Simulation/QSharpCore/Math/Trig.qs rename to src/Simulation/QSharpFoundation/Math/Trig.qs diff --git a/src/Simulation/QSharpCore/Math/Types.qs b/src/Simulation/QSharpFoundation/Math/Types.qs similarity index 100% rename from src/Simulation/QSharpCore/Math/Types.qs rename to src/Simulation/QSharpFoundation/Math/Types.qs diff --git a/src/Simulation/QSharpFoundation/Message.qs b/src/Simulation/QSharpFoundation/Message.qs new file mode 100644 index 00000000000..2a5a920491b --- /dev/null +++ b/src/Simulation/QSharpFoundation/Message.qs @@ -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; + } +} \ No newline at end of file diff --git a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj new file mode 100644 index 00000000000..7f1e17b0cc9 --- /dev/null +++ b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -0,0 +1,38 @@ + + + + + + + netstandard2.1 + true + false + false + + + + Foundation implementation for the Q# programming language. + Quantum Q# QSharp + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/QSharpFoundation/Random.qs b/src/Simulation/QSharpFoundation/Random.qs new file mode 100644 index 00000000000..c32e1fc731a --- /dev/null +++ b/src/Simulation/QSharpFoundation/Random.qs @@ -0,0 +1,26 @@ +// 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`. + @Deprecated("Microsoft.Quantum.Random.DrawCategorical") + operation Random (probs : Double[]) : Int { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/QSharpCore/Random/Convienence.qs b/src/Simulation/QSharpFoundation/Random/Convienence.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Convienence.qs rename to src/Simulation/QSharpFoundation/Random/Convienence.qs diff --git a/src/Simulation/QSharpCore/Random/Internal.qs b/src/Simulation/QSharpFoundation/Random/Internal.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Internal.qs rename to src/Simulation/QSharpFoundation/Random/Internal.qs diff --git a/src/Simulation/QSharpCore/Random/Intrinsic.qs b/src/Simulation/QSharpFoundation/Random/Intrinsic.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Intrinsic.qs rename to src/Simulation/QSharpFoundation/Random/Intrinsic.qs diff --git a/src/Simulation/QSharpCore/Random/Normal.qs b/src/Simulation/QSharpFoundation/Random/Normal.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Normal.qs rename to src/Simulation/QSharpFoundation/Random/Normal.qs diff --git a/src/Simulation/QSharpCore/Random/Types.qs b/src/Simulation/QSharpFoundation/Random/Types.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Types.qs rename to src/Simulation/QSharpFoundation/Random/Types.qs diff --git a/src/Simulation/QSharpCore/Random/Uniform.qs b/src/Simulation/QSharpFoundation/Random/Uniform.qs similarity index 100% rename from src/Simulation/QSharpCore/Random/Uniform.qs rename to src/Simulation/QSharpFoundation/Random/Uniform.qs diff --git a/src/Simulation/QSharpCore/Statements/Allocate.cs b/src/Simulation/QSharpFoundation/Statements/Allocate.cs similarity index 100% rename from src/Simulation/QSharpCore/Statements/Allocate.cs rename to src/Simulation/QSharpFoundation/Statements/Allocate.cs diff --git a/src/Simulation/QSharpCore/Statements/Borrow.cs b/src/Simulation/QSharpFoundation/Statements/Borrow.cs similarity index 100% rename from src/Simulation/QSharpCore/Statements/Borrow.cs rename to src/Simulation/QSharpFoundation/Statements/Borrow.cs diff --git a/src/Simulation/QSharpCore/Statements/Release.cs b/src/Simulation/QSharpFoundation/Statements/Release.cs similarity index 100% rename from src/Simulation/QSharpCore/Statements/Release.cs rename to src/Simulation/QSharpFoundation/Statements/Release.cs diff --git a/src/Simulation/QSharpCore/Statements/Return.cs b/src/Simulation/QSharpFoundation/Statements/Return.cs similarity index 100% rename from src/Simulation/QSharpCore/Statements/Return.cs rename to src/Simulation/QSharpFoundation/Statements/Return.cs diff --git a/src/Simulation/QSharpCore/Targeting.qs b/src/Simulation/QSharpFoundation/Targeting.qs similarity index 100% rename from src/Simulation/QSharpCore/Targeting.qs rename to src/Simulation/QSharpFoundation/Targeting.qs diff --git a/src/Simulation/Simulators.Tests/App.config b/src/Simulation/Simulators.Tests/App.config index 94ce1a2b94f..afca86583e1 100644 --- a/src/Simulation/Simulators.Tests/App.config +++ b/src/Simulation/Simulators.Tests/App.config @@ -3,4 +3,4 @@ - + diff --git a/src/Simulation/Simulators.Tests/Circuits/VerifyUnitary.qs b/src/Simulation/Simulators.Tests/Circuits/VerifyUnitary.qs index 2388633631b..afde45b0c3b 100644 --- a/src/Simulation/Simulators.Tests/Circuits/VerifyUnitary.qs +++ b/src/Simulation/Simulators.Tests/Circuits/VerifyUnitary.qs @@ -6,7 +6,7 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { open Microsoft.Quantum.Intrinsic; open Microsoft.Quantum.Math; open Microsoft.Quantum.Diagnostics; - open Microsoft.Quantum.Simulation.TestSuite; + open Microsoft.Quantum.Measurement; /// @@ -28,14 +28,14 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { let q1 = qubits[0]; let (a, b) = expected; let (p, r) = start; - SetQubit(r, q1); + SetToBasisState(r, q1); if (p == PauliX) { H(q1); } // Make sure we start in correct state. - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); // Apply the gate, make sure it's in the right state gate(q1); @@ -43,7 +43,7 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { // Apply Adjoint, back to Zero: Adjoint gate(q1); - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); // When no control qubits, it should be equivalent to just calling the gate: Controlled gate(new Qubit[0], q1); @@ -51,7 +51,7 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { // Apply Adjoint, back to Zero: Controlled (Adjoint gate)(new Qubit[0], q1); - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); // Now test control... We'll have 3 control qubits. // We will run the test with 1..3 controls at a time. @@ -62,18 +62,18 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { for (i in 0 .. ctrlsCount - 1) { // We're starting fresh - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); // Get a subset for control and initialize them to zero: let c = ctrls[0 .. i]; for (j in 0 .. i) { - SetQubit(Zero, c[j]); + SetToBasisState(Zero, c[j]); } // Noop when ctrls are all zero. Controlled gate(c, q1); - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); // turn on each of the controls one by one for (j in 1 .. Length(c)) { @@ -85,7 +85,7 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { AssertQubitIsInStateWithinTolerance(expected, q1, tolerance); } else { - Assert([p], [q1], r, $"Qubit in invalid state."); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); } Adjoint Controlled gate(c, q1); @@ -96,8 +96,8 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits { } // We're back where we started. - Assert([p], [q1], r, $"Qubit in invalid state."); - SetQubit(r, q1); + AssertMeasurement([p], [q1], r, $"Qubit in invalid state."); + SetToBasisState(r, q1); ResetAll(qubits); } } diff --git a/src/Simulation/Simulators.Tests/DebuggingToolsTests.cs b/src/Simulation/Simulators.Tests/DebuggingToolsTests.cs index 279a6185f00..0ef42022ab6 100644 --- a/src/Simulation/Simulators.Tests/DebuggingToolsTests.cs +++ b/src/Simulation/Simulators.Tests/DebuggingToolsTests.cs @@ -23,7 +23,7 @@ public void ToStringTests() => Helper.RunWithMultipleSimulators(qsim => { var _ = AbstractCallable._; - var dump = qsim.Get(typeof(Microsoft.Quantum.Extensions.Diagnostics.DumpMachine<>)); + var dump = qsim.Get(typeof(Microsoft.Quantum.Diagnostics.DumpMachine<>)); var trace = qsim.Get(typeof(Circuits.Generics.Trace<>)); var x = qsim.Get(); var q2 = new FreeQubit(2) as Qubit; @@ -223,7 +223,7 @@ public void GenericDebuggerProxy() { Helper.RunWithMultipleSimulators((qsim) => { - var dump = qsim.Get(typeof(Microsoft.Quantum.Extensions.Diagnostics.DumpMachine<>)) as GenericCallable; + var dump = qsim.Get(typeof(Microsoft.Quantum.Diagnostics.DumpMachine<>)) as GenericCallable; var trace = qsim.Get(typeof(Circuits.Generics.Trace<>)) as GenericCallable; var gen3 = qsim.Get(typeof(Circuits.Generics.Gen3<,,>)) as GenericCallable; @@ -231,7 +231,7 @@ public void GenericDebuggerProxy() TestOneProxy("Trace", "Microsoft.Quantum.Simulation.Simulators.Tests.Circuits.Generics.Trace", OperationFunctor.Adjoint, "T => () : Adjoint, Controlled", trace.Adjoint); TestOneProxy("Trace", "Microsoft.Quantum.Simulation.Simulators.Tests.Circuits.Generics.Trace", OperationFunctor.Controlled, "(Qubit[],T) => () : Adjoint, Controlled", trace.Controlled); TestOneProxy("Trace", "Microsoft.Quantum.Simulation.Simulators.Tests.Circuits.Generics.Trace", OperationFunctor.ControlledAdjoint, "(Qubit[],T) => () : Adjoint, Controlled", trace.Adjoint.Controlled); - TestOneProxy("DumpMachine", "Microsoft.Quantum.Extensions.Diagnostics.DumpMachine", OperationFunctor.Body, "T => ()", dump); + TestOneProxy("DumpMachine", "Microsoft.Quantum.Diagnostics.DumpMachine", OperationFunctor.Body, "T => ()", dump); TestOneProxy("Gen3", "Microsoft.Quantum.Simulation.Simulators.Tests.Circuits.Generics.Gen3", OperationFunctor.Body, "(__T1,(__T2,__T3),Result) => () : Controlled", gen3); TestOneProxy("Gen3", "Microsoft.Quantum.Simulation.Simulators.Tests.Circuits.Generics.Gen3", OperationFunctor.Controlled, "(Qubit[],(__T1,(__T2,__T3),Result)) => () : Controlled", gen3.Controlled); }); @@ -252,7 +252,7 @@ public void GenericPartialDebuggerProxy() { var _ = AbstractCallable._; - var dump = qsim.Get(typeof(Microsoft.Quantum.Extensions.Diagnostics.DumpMachine<>)) as GenericCallable; + var dump = qsim.Get(typeof(Microsoft.Quantum.Diagnostics.DumpMachine<>)) as GenericCallable; var trace = qsim.Get(typeof(Circuits.Generics.Trace<>)) as GenericCallable; var gen3 = qsim.Get(typeof(Circuits.Generics.Gen3<,,>)) as GenericCallable; diff --git a/src/Simulation/Simulators.Tests/OperationsTestHelper.cs b/src/Simulation/Simulators.Tests/OperationsTestHelper.cs index bde77e602d8..b8ae21270e9 100644 --- a/src/Simulation/Simulators.Tests/OperationsTestHelper.cs +++ b/src/Simulation/Simulators.Tests/OperationsTestHelper.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using Microsoft.Quantum.Simulation.Common; using Microsoft.Quantum.Simulation.Core; @@ -14,6 +13,18 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests { + public static class Extensions + { + /// + /// This method is a wrapper to let the tests keep using a one Type parameter + /// method to fetch for Gates. + /// + public static T Get(this SimulatorBase sim) where T : AbstractCallable + { + return sim.Get(); + } + } + public class Log { public Dictionary _log = new Dictionary(); @@ -88,75 +99,8 @@ private void OnStart(ICallable arg1, IApplyData arg2) } } - static class OperationsTestHelper + static partial class OperationsTestHelper { - public static TraceImpl GetTracer(this SimulatorBase s) - { - return s.Get(typeof(Tests.Circuits.Generics.Trace<>)).FindCallable(typeof(T), typeof(QVoid)) as TraceImpl; - } - - - public class TracerImpl : Tests.Circuits.ClosedType.Trace - { - public TracerImpl(IOperationFactory m) : base(m) - { - this.Log = new Log(); - } - - public override Func __Body__ => (tag) => this.Log.Record(OperationFunctor.Body, tag); - public override Func __AdjointBody__ => (tag) => this.Log.Record(OperationFunctor.Adjoint, tag); - public override Func<(IQArray, string), QVoid> __ControlledBody__ => (args) => this.Log.Record(OperationFunctor.Controlled, args.Item2); - public override Func<(IQArray, string), QVoid> __ControlledAdjointBody__ => (args) => this.Log.Record(OperationFunctor.ControlledAdjoint, args.Item2); - - public Log Log { get; } - } - - public class TraceImpl : Tests.Circuits.Generics.Trace - { - public TraceImpl(IOperationFactory m) : base(m) - { - this.Log = new Log(); - } - - public override Func __Body__ => (tag) => this.Log.Record(OperationFunctor.Body, tag); - public override Func __AdjointBody__ => (tag) => this.Log.Record(OperationFunctor.Adjoint, tag); - public override Func<(IQArray, T), QVoid> __ControlledBody__ => (args) => this.Log.Record(OperationFunctor.Controlled, args.Item2); - public override Func<(IQArray, T), QVoid> __ControlledAdjointBody__ => (args) => this.Log.Record(OperationFunctor.ControlledAdjoint, args.Item2); - - public int GetNumberOfCalls(OperationFunctor functor, T tag) => this.Log.GetNumberOfCalls(functor, tag); - - public Log Log { get; } - } - - private static void InitSimulator(SimulatorBase sim) - { - sim.InitBuiltinOperations(typeof(OperationsTestHelper)); - sim.Register(typeof(Tests.Circuits.Generics.Trace<>), typeof(TraceImpl<>), typeof(IUnitary)); - - // For Toffoli, replace H with I. - if (sim is ToffoliSimulator) - { - sim.Register(typeof(Intrinsic.H), typeof(Intrinsic.I), typeof(IUnitary)); - } - } - - public static void RunWithMultipleSimulators(Action test) - { - var simulators = new SimulatorBase[] { new QuantumSimulator(), new ToffoliSimulator() }; - - foreach (var s in simulators) - { - InitSimulator(s); - - test(s); - - if (s is IDisposable sim) - { - sim.Dispose(); - } - } - } - /// /// A shell for simple Apply tests. /// @@ -189,13 +133,13 @@ internal static void ctrlErrorConditionsTests(SimulatorBase sim, Action<(IQArray /// /// A shell for simple Controlled tests. It calls the controlled operation with 0..4 control qubits - /// set to all possible combination of 1 & 0. + /// set to all possible combination of 1 and 0. /// internal static void ctrlTestShell(SimulatorBase sim, Action<(IQArray, Qubit)> operationControlled, Action, Qubit> test) { var allocate = sim.Get(); var release = sim.Get(); - var set = sim.Get(); + var set = sim.Get(); // Number of control bits to use for (int n = 0; n < 4; n++) diff --git a/src/Simulation/Simulators.Tests/OperationsTestHelperSimSupport.cs b/src/Simulation/Simulators.Tests/OperationsTestHelperSimSupport.cs new file mode 100644 index 00000000000..bef48e8bf27 --- /dev/null +++ b/src/Simulation/Simulators.Tests/OperationsTestHelperSimSupport.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Common; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators.Tests +{ + static partial class OperationsTestHelper + { + public static bool ShouldPerformQubitUniquenessTest = true; + + private static void InitSimulator(SimulatorBase sim) + { + sim.InitBuiltinOperations(typeof(OperationsTestHelper)); + sim.Register(typeof(Tests.Circuits.Generics.Trace<>), typeof(TraceImpl<>), typeof(IUnitary)); + + // For Toffoli, replace H with I. + if (sim is ToffoliSimulator) + { + sim.Register(typeof(Intrinsic.H), typeof(Intrinsic.I), typeof(IUnitary)); + } + } + + public static void RunWithMultipleSimulators(Action test) + { + var simulators = new SimulatorBase[] { new QuantumSimulator(), new ToffoliSimulator() }; + + foreach (var s in simulators) + { + try + { + InitSimulator(s); + + test(s); + } + finally + { + if (s is IDisposable sim) + { + sim.Dispose(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators.Tests/QuantumSimulatorTests/BasicTests.cs b/src/Simulation/Simulators.Tests/QuantumSimulatorTests/BasicTests.cs index 682e35e7630..fbc2fcd5fbd 100644 --- a/src/Simulation/Simulators.Tests/QuantumSimulatorTests/BasicTests.cs +++ b/src/Simulation/Simulators.Tests/QuantumSimulatorTests/BasicTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators.Exceptions; -using Microsoft.Quantum.Simulation.Simulators.Tests.Circuits; using Xunit; namespace Microsoft.Quantum.Simulation.Simulators.Tests @@ -60,7 +59,7 @@ public void QSimX() { var x = sim.Get(); var measure = sim.Get(); - var set = sim.Get(); + var set = sim.Get(); var ctrlX = x.__ControlledBody__.AsAction(); OperationsTestHelper.ctrlTestShell(sim, ctrlX, (enabled, ctrls, q) => @@ -220,9 +219,14 @@ private static void TestControllable(IControllable gate, IQArray c TestCallable(gate.Controlled.Partial(nullTarget), target); TestCallable(gate.Controlled.Partial(nullCtrl), ctrls[0]); - Assert.Throws(() => gate.Controlled.Apply((dupeTarget, target))); - Assert.Throws(() => gate.Controlled.Apply((dupeCtrls1, target))); - Assert.Throws(() => gate.Controlled.Apply((dupeCtrls2, target))); + // Some decompositions actually allow for duplications in controls, so these tests + // should be skipped for those packages. + if (OperationsTestHelper.ShouldPerformQubitUniquenessTest) + { + Assert.Throws(() => gate.Controlled.Apply((dupeTarget, target))); + Assert.Throws(() => gate.Controlled.Apply((dupeCtrls1, target))); + Assert.Throws(() => gate.Controlled.Apply((dupeCtrls2, target))); + } } private static void TestUnitary(IUnitary gate, IQArray ctrls, IQArray target) @@ -238,8 +242,10 @@ private static void TestMultiCallable(ICallable, O> gate, IQAr var mapper = new Func>(q => new QArray(q, targets[1], targets[2])); var dupTargets = new QArray(targets[0], targets[1], targets[0]); - Assert.Throws(() => gate.Apply(null)); - Assert.Throws(() => gate.Apply(dupTargets)); + if (OperationsTestHelper.ShouldPerformQubitUniquenessTest) + { + Assert.Throws(() => gate.Apply(dupTargets)); + } TestCallable(gate.Partial(mapper), targets[0]); } @@ -280,22 +286,21 @@ private void TestOne(QuantumSimulator qsim, T gate, Action, [Fact] public void TestSimpleGateCheckQubits() { - using (var qsim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: false)) + // Single Qubit gates: { + var gateTypes = new Type[] + { + typeof(Intrinsic.H), + typeof(Intrinsic.S), + typeof(Intrinsic.T), + typeof(Intrinsic.X), + typeof(Intrinsic.Y), + typeof(Intrinsic.Z) + }; - // Single Qubit gates: + foreach (var t in gateTypes) { - var gateTypes = new Type[] - { - typeof(Intrinsic.H), - typeof(Intrinsic.S), - typeof(Intrinsic.T), - typeof(Intrinsic.X), - typeof(Intrinsic.Y), - typeof(Intrinsic.Z) - }; - - foreach (var t in gateTypes) + using (var qsim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: false)) { var gate = qsim.Get>(t); TestOne(qsim, gate, TestUnitary); @@ -324,7 +329,7 @@ public void TestExpCheckQubits() { // Exp { - var mapper = new Func, (IQArray, Double, IQArray)>(qubits => (new QArray(Pauli.PauliZ, Pauli.PauliI, Pauli.PauliI), 1.0, qubits)); + var mapper = new Func, (IQArray, Double, IQArray)>(qubits => (new QArray(Pauli.PauliZ, Pauli.PauliX, Pauli.PauliY), 1.0, qubits)); var gate = qsim.Get(); var p = gate.Partial(mapper); TestOne(qsim, p, TestMultiUnitary); @@ -332,7 +337,7 @@ public void TestExpCheckQubits() // ExpFrac { - var mapper = new Func, (IQArray, long, long, IQArray)>(qubits => (new QArray(Pauli.PauliZ, Pauli.PauliI, Pauli.PauliI), 1, 2, qubits)); + var mapper = new Func, (IQArray, long, long, IQArray)>(qubits => (new QArray(Pauli.PauliZ, Pauli.PauliX, Pauli.PauliY), 1, 2, qubits)); var gate = qsim.Get(); var p = gate.Partial(mapper); TestOne(qsim, p, TestMultiUnitary); @@ -357,6 +362,9 @@ public void TestMeasureCheckQubits() var gate = qsim.Get(); var mapper = new Func, (IQArray, IQArray)>(qubits => (new QArray(Pauli.PauliZ, Pauli.PauliI, Pauli.PauliI), qubits)); var p = gate.Partial(mapper); + + // On systems that decompose joint measurement a qubit can actually be duplictated in + // the targets, so skip the duplicate qubit check. TestOne(qsim, p, (g, ctrls, t) => TestMultiCallable(p, t)); } } diff --git a/src/Simulation/Simulators.Tests/QuantumSimulatorTests/VerifyGates.cs b/src/Simulation/Simulators.Tests/QuantumSimulatorTests/VerifyGates.cs index 0cc32328fdf..170b19ad508 100644 --- a/src/Simulation/Simulators.Tests/QuantumSimulatorTests/VerifyGates.cs +++ b/src/Simulation/Simulators.Tests/QuantumSimulatorTests/VerifyGates.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Threading.Tasks; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators.Tests.Circuits; using Xunit; @@ -324,7 +323,7 @@ public void QSimVerifyR() Func mapper = (q) => (Pauli.PauliI, angle, q); Func<(double, Qubit), (Pauli, double, Qubit)> needsAngle = (__arg) - => (Pauli.PauliI, __arg.Item1, __arg.Item2); + => (Pauli.PauliX, __arg.Item1, __arg.Item2); using (var sim = new QuantumSimulator()) { @@ -374,8 +373,10 @@ private void VerifyExp(Pauli pauli) Func<(double, Qubit), (IQArray, double, IQArray)> needsAngle = (__arg) => (new QArray (pauli), __arg.Item1, new QArray (__arg.Item2)); var angleGate = sim.Get().Partial(needsAngle); - - VerifyInvalidAngles(sim, angleGate); + if (pauli != Pauli.PauliI) + { + VerifyInvalidAngles(sim, angleGate); + } } } diff --git a/src/Simulation/Simulators.Tests/QuantumTestSuite.cs b/src/Simulation/Simulators.Tests/QuantumTestSuite.cs index 03864b46fd6..e4f06be7dab 100644 --- a/src/Simulation/Simulators.Tests/QuantumTestSuite.cs +++ b/src/Simulation/Simulators.Tests/QuantumTestSuite.cs @@ -21,7 +21,7 @@ public QuantumTestSuite(ITestOutputHelper output) [OperationDriver(TestCasePrefix = "QSim:", TestNamespace = "Microsoft.Quantum.Simulation.TestSuite")] public void QSimTestTarget(TestOperation op) { - using (var sim = new QuantumSimulator( throwOnReleasingQubitsNotInZeroState: true )) + using (var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true )) { sim.OnLog += (msg) => { output.WriteLine(msg); }; op.TestOperationRunner(sim); @@ -31,7 +31,7 @@ public void QSimTestTarget(TestOperation op) //[OperationDriver(TestCasePrefix = "QSim:", TestNamespace = "Microsoft.Quantum.Simulation.TestSuite.VeryLong")] private void QSimTestTargetVeryLong(TestOperation op) { - using (var sim = new QuantumSimulator( throwOnReleasingQubitsNotInZeroState: true )) + using (var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true )) { sim.OnLog += (msg) => { output.WriteLine(msg); }; op.TestOperationRunner(sim); @@ -42,7 +42,7 @@ private void QSimTestTargetVeryLong(TestOperation op) [OperationDriver(TestCasePrefix = "⊗ Fail QSim:", TestNamespace = "Microsoft.Quantum.Simulation.TestSuite", Suffix = "QSimFail", Skip = "These tests are known to fail" )] public void QSimTestTargetFailures(TestOperation op) { - using (var sim = new QuantumSimulator( throwOnReleasingQubitsNotInZeroState: true )) + using (var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true )) { sim.OnLog += (msg) => { output.WriteLine(msg); }; Action action = () => op.TestOperationRunner(sim); diff --git a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertProbMultiQubit.qs b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertProbMultiQubit.qs index 49392e3aa0c..e16b4ca64aa 100644 --- a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertProbMultiQubit.qs +++ b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertProbMultiQubit.qs @@ -8,6 +8,41 @@ namespace Microsoft.Quantum.Simulation.TestSuite { open Microsoft.Quantum.Simulation.TestSuite.Math; + internal operation FlipToBasis (basis : Int[], qubits : Qubit[]) : Unit is Adj + Ctl { + if (Length(qubits) != Length(basis)) + { + fail "qubits and stateIds must have the same length"; + } + + for (i in 0 .. Length(qubits) - 1) + { + let id = basis[i]; + let qubit = qubits[i]; + + if (id < 0 or id > 3) { + fail $"Invalid basis. Must be between 0 and 3, it was {basis}"; + } + + if (id == 0) + { + I(qubit); + } + elif (id == 1) + { + X(qubit); + } + elif (id == 2) + { + H(qubit); + } + else + { + H(qubit); + S(qubit); + } + } + } + operation AssertProbMultiQubitTest () : Unit { @@ -51,15 +86,14 @@ namespace Microsoft.Quantum.Simulation.TestSuite { } using (qubits = Qubit[l]) { - _flipToBasis(stateId, qubits); + FlipToBasis(stateId, qubits); let expectedZeroProbability = 0.5 + 0.5 * ExpectedValueForMultiPauliByStateId(observable, stateId); let expectedOneProbability = 1.0 - expectedZeroProbability; - AssertProb(observable, qubits, Zero, expectedZeroProbability, $"", Accuracy()); - AssertProb(observable, qubits, One, expectedOneProbability, $"", Accuracy()); - Adjoint _flipToBasis(stateId, qubits); + AssertMeasurementProbability(observable, qubits, Zero, expectedZeroProbability, $"", Accuracy()); + AssertMeasurementProbability(observable, qubits, One, expectedOneProbability, $"", Accuracy()); + Adjoint FlipToBasis(stateId, qubits); } } } - diff --git a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertQubitUnitary.qs b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertQubitUnitary.qs index 395783226e6..54b94557474 100644 --- a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertQubitUnitary.qs +++ b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertQubitUnitary.qs @@ -15,7 +15,7 @@ namespace Microsoft.Quantum.Simulation.TestSuite { for (stateId in 0 .. maxId) { let expectedState = ApplyMatrix(unitaryMatrix, StateIdToVector(stateId)); - _flipToBasis([stateId], [qubit]); + FlipToBasis([stateId], [qubit]); unitaryOp(qubit); let alpha = Microsoft.Quantum.Math.Complex((expectedState![0])!); let beta = Microsoft.Quantum.Math.Complex((expectedState![1])!); diff --git a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertUnitary.qs b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertUnitary.qs index fa6c510155d..11f38f78444 100644 --- a/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertUnitary.qs +++ b/src/Simulation/Simulators.Tests/QuantumTestSuite/AssertUnitary.qs @@ -10,7 +10,7 @@ namespace Microsoft.Quantum.Simulation.TestSuite { operation AssertUnitaryHelper (stateIds : Int[], unitaryMatrix : RowMajorMatrix, unitaryOp : (Qubit[] => Unit), qubits : Qubit[]) : Unit { let expectedState = ApplyMatrix(unitaryMatrix, StateById(stateIds)); - _flipToBasis(stateIds, qubits); + FlipToBasis(stateIds, qubits); unitaryOp(qubits); AssertState(expectedState, qubits); ResetAll(qubits); diff --git a/src/Simulation/Simulators.Tests/QuantumTestSuite/JointOneQubitTests.qs b/src/Simulation/Simulators.Tests/QuantumTestSuite/JointOneQubitTests.qs index 137ea806f31..6c29af44a74 100644 --- a/src/Simulation/Simulators.Tests/QuantumTestSuite/JointOneQubitTests.qs +++ b/src/Simulation/Simulators.Tests/QuantumTestSuite/JointOneQubitTests.qs @@ -23,7 +23,7 @@ namespace Microsoft.Quantum.Simulation.TestSuite { } mutable states = new Vector[numQubits]; - _flipToBasis(inputStateId, qubits); + FlipToBasis(inputStateId, qubits); for (i in 0 .. numQubits - 1) { let (op, matrix) = operationsToTest[i]!; diff --git a/src/Simulation/Simulators.Tests/ResourcesEstimatorTests.cs b/src/Simulation/Simulators.Tests/ResourcesEstimatorTests.cs index 1b131d8290c..24d29bca230 100644 --- a/src/Simulation/Simulators.Tests/ResourcesEstimatorTests.cs +++ b/src/Simulation/Simulators.Tests/ResourcesEstimatorTests.cs @@ -1,236 +1,236 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Linq; -using System.Data; -using Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime; -using Xunit; - -namespace Microsoft.Quantum.Simulation.Simulators.Tests -{ - public class ResourcesEstimatorTests - { - /// - /// Check the parameters of the suggested config, just to track changes. - /// - [Fact] - public void RecommendedConfigTest() - { - var actual = ResourcesEstimator.RecommendedConfig(); - - Assert.Equal(1u, actual.CallStackDepthLimit); - - // This disabled by default: - Assert.False(actual.ThrowOnUnconstrainedMeasurement); - Assert.False(actual.UseDistinctInputsChecker); - Assert.False(actual.UseInvalidatedQubitsUseChecker); - - // Counters that we're expecting: - Assert.True(actual.UsePrimitiveOperationsCounter); - Assert.True(actual.UseDepthCounter); - Assert.True(actual.UseWidthCounter); - } - - /// - /// Verifies that the statistics configured in the ResourcesEstimator - /// matches what the Results method expects. - /// - [Fact] - public void VerifyCollectorsTest() - { - var sim = new ResourcesEstimator(); - - foreach(var l in sim.CoreConfig.Listeners) - { - // All listeners we expected are ICallGraphStatistics - var collector = l as ICallGraphStatistics; - Assert.NotNull(collector); - - // We expect all of them to have the Moment (with Sum) - var stats = collector.Results.GetStatisticsNamesCopy(); - var expected = new MomentsStatistic().GetStatisticsNames(); - foreach (var n in expected) - { - Assert.Contains(n, stats); - } - } - } - - /// - /// Verifies that the statistics configured in the ResourcesEstimator - /// matches what the Results method expects. - /// - [Fact] - public void VerifyDataTest() - { - var sim = new ResourcesEstimator(); - - VerySimpleEstimate.Run(sim).Wait(); - var data = sim.Data; - - Assert.Equal(1.0, data.Rows.Find("CNOT")["Sum"]); - Assert.Equal(0.0, data.Rows.Find("R")["Sum"]); - Assert.Equal(2.0, data.Rows.Find("QubitClifford")["Sum"]); - Assert.Equal(3.0, data.Rows.Find("Width")["Sum"]); - } - - /// - /// Verifies the calls ToCSV returns a non-empty string. - /// - [Fact] - public void ToTSVTest() - { - var sim = new ResourcesEstimator(); - - VerySimpleEstimate.Run(sim).Wait(); - var data = sim.ToTSV(); - Console.WriteLine(data); - - Assert.NotNull(data); - var rows = data.Split('\n'); - Assert.Equal(10, rows.Length); - - var cols = rows[0].Split('\t'); - Assert.Equal("Metric", cols[0].Trim()); - Assert.Equal(3, cols.Length); - - var cliffords = rows.First(r => r.StartsWith("QubitClifford")).Split('\t'); - Assert.Equal(3, cliffords.Length); - Assert.Equal("2", cliffords[1]); - } - - /// - /// Shows that T gates on different qubits are counted for depth purposes as - /// executing in parallel. - /// - [Fact] - public void DepthDifferentQubitsTest() - { - var sim = new ResourcesEstimator(); - - // using(q = Qubit[3]) { T(q[0]); T(q[1]); T(q[3]); T(q[0]); } - DepthDifferentQubits.Run(sim).Wait(); - var data = sim.Data; - - Assert.Equal(4.0, data.Rows.Find("T")["Sum"]); - Assert.Equal(3.0, data.Rows.Find("Width")["Sum"]); - Assert.Equal(2.0, data.Rows.Find("Depth")["Sum"]); - } - - [Fact] - public void QubitReuseWithOptimizedDepthTest() { - QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); - config.OptimizeDepth = true; - var sim = new ResourcesEstimator(config); - - QubitReuseWithOptimizedDepth.Run(sim).Wait(); - - Assert.Equal(2.0, sim.Data.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(2.0, sim.Data.Rows.Find("Width")["Sum"]); - Assert.Equal(1.0, sim.Data.Rows.Find("Depth")["Sum"]); - } - - [Fact] - public void QubitReuseSimultaneousTest() { - QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); - config.OptimizeDepth = true; - var sim = new ResourcesEstimator(config); - - SimultaneousUse.Run(sim).Wait(); - - Assert.Equal(11.0, sim.Data.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(20.0, sim.Data.Rows.Find("Width")["Sum"]); - // Note that in RecommendedConfig only T gates are depth 1, the rest are depth 0. - Assert.Equal(1.0, sim.Data.Rows.Find("Depth")["Sum"]); - } - - [Fact] - public void QubitReuseSequentialTest() { - QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); - config.OptimizeDepth = true; - var sim = new ResourcesEstimator(config); - - SequentialUse.Run(sim).Wait(); - - Assert.Equal(11.0, sim.Data.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(20.0, sim.Data.Rows.Find("Width")["Sum"]); - Assert.Equal(11.0, sim.Data.Rows.Find("Depth")["Sum"]); - } - - - /// - /// Documents that the QubitCount and Depth statistics reflect independent lower - /// bounds for each (two T gates cannot be combined into a circuit of depth - /// one and width one). Width on the other hand is compatible with Depth. - /// - [Fact] - public void DepthVersusWidthTest() - { - // Operation to execute: - // using(q = Qubit()) { T(q); } using(q = Qubit()) { T(q); } (yes, twice) - - // First run with width optimization - DataTable data = RunDepthVersusWidthTest(optimizeDepth: false); - Assert.Equal(2.0, data.Rows.Find("T")["Sum"]); - Assert.Equal(1.0, data.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(1.0, data.Rows.Find("Width")["Sum"]); - Assert.Equal(2.0, data.Rows.Find("Depth")["Sum"]); - - // Now run with depth optimization - data = RunDepthVersusWidthTest(optimizeDepth: true); - Assert.Equal(2.0, data.Rows.Find("T")["Sum"]); - Assert.Equal(1.0, data.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(2.0, data.Rows.Find("Width")["Sum"]); - Assert.Equal(1.0, data.Rows.Find("Depth")["Sum"]); - } - - private DataTable RunDepthVersusWidthTest(bool optimizeDepth) - { - QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); - config.OptimizeDepth = optimizeDepth; - var sim = new ResourcesEstimator(config); - - DepthVersusWidth.Run(sim).Wait(); - return sim.Data; - } - - /// - /// Verifies that for multiple separately traced operations, the final - /// statistics are cumulative. - /// - [Fact] - public void VerifyTracingMultipleOperationsTest() - { - ResourcesEstimator sim = new ResourcesEstimator(); - - Operation_1_of_2.Run(sim).Wait(); - DataTable data1 = sim.Data; - - Assert.Equal(1.0, data1.Rows.Find("CNOT")["Sum"]); - Assert.Equal(1.0, data1.Rows.Find("QubitClifford")["Sum"]); - Assert.Equal(1.0, data1.Rows.Find("T")["Sum"]); - Assert.Equal(0.0, data1.Rows.Find("R")["Sum"]); - Assert.Equal(0.0, data1.Rows.Find("Measure")["Sum"]); - Assert.Equal(2.0, data1.Rows.Find("QubitCount")["Sum"]); - - Operation_2_of_2.Run(sim).Wait(); - DataTable data2 = sim.Data; - - // Aggregated stats for both operations. - Assert.Equal(1.0 + 2.0, data2.Rows.Find("CNOT")["Sum"]); - Assert.Equal(1.0 + 1.0, data2.Rows.Find("QubitClifford")["Sum"]); - Assert.Equal(1.0 + 0.0, data2.Rows.Find("T")["Sum"]); - Assert.Equal(0.0 + 1.0, data2.Rows.Find("R")["Sum"]); - Assert.Equal(0.0 + 1.0, data2.Rows.Find("Measure")["Sum"]); - Assert.Equal(2.0 + 3.0, data2.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(System.Math.Max(2.0, 3.0), data2.Rows.Find("QubitCount")["Max"]); - - // Run again to confirm two operations isn't the limit! - VerySimpleEstimate.Run(sim).Wait(); - DataTable data3 = sim.Data; - Assert.Equal(2.0 + 3.0 + 3.0, data3.Rows.Find("QubitCount")["Sum"]); - Assert.Equal(3.0, data3.Rows.Find("QubitCount")["Max"]); - } - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Data; +using Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime; +using Xunit; + +namespace Microsoft.Quantum.Simulation.Simulators.Tests +{ + public class ResourcesEstimatorTests + { + /// + /// Check the parameters of the suggested config, just to track changes. + /// + [Fact] + public void RecommendedConfigTest() + { + var actual = ResourcesEstimator.RecommendedConfig(); + + Assert.Equal(1u, actual.CallStackDepthLimit); + + // This disabled by default: + Assert.False(actual.ThrowOnUnconstrainedMeasurement); + Assert.False(actual.UseDistinctInputsChecker); + Assert.False(actual.UseInvalidatedQubitsUseChecker); + + // Counters that we're expecting: + Assert.True(actual.UsePrimitiveOperationsCounter); + Assert.True(actual.UseDepthCounter); + Assert.True(actual.UseWidthCounter); + } + + /// + /// Verifies that the statistics configured in the ResourcesEstimator + /// matches what the Results method expects. + /// + [Fact] + public void VerifyCollectorsTest() + { + var sim = new ResourcesEstimator(); + + foreach(var l in sim.CoreConfig.Listeners) + { + // All listeners we expected are ICallGraphStatistics + var collector = l as ICallGraphStatistics; + Assert.NotNull(collector); + + // We expect all of them to have the Moment (with Sum) + var stats = collector.Results.GetStatisticsNamesCopy(); + var expected = new MomentsStatistic().GetStatisticsNames(); + foreach (var n in expected) + { + Assert.Contains(n, stats); + } + } + } + + /// + /// Verifies that the statistics configured in the ResourcesEstimator + /// matches what the Results method expects. + /// + [Fact] + public void VerifyDataTest() + { + var sim = new ResourcesEstimator(); + + VerySimpleEstimate.Run(sim).Wait(); + var data = sim.Data; + + Assert.Equal(1.0, data.Rows.Find("CNOT")["Sum"]); + Assert.Equal(0.0, data.Rows.Find("R")["Sum"]); + Assert.Equal(2.0, data.Rows.Find("QubitClifford")["Sum"]); + Assert.Equal(3.0, data.Rows.Find("Width")["Sum"]); + } + + /// + /// Verifies the calls ToCSV returns a non-empty string. + /// + [Fact] + public void ToTSVTest() + { + var sim = new ResourcesEstimator(); + + VerySimpleEstimate.Run(sim).Wait(); + var data = sim.ToTSV(); + Console.WriteLine(data); + + Assert.NotNull(data); + var rows = data.Split('\n'); + Assert.Equal(10, rows.Length); + + var cols = rows[0].Split('\t'); + Assert.Equal("Metric", cols[0].Trim()); + Assert.Equal(3, cols.Length); + + var cliffords = rows.First(r => r.StartsWith("QubitClifford")).Split('\t'); + Assert.Equal(3, cliffords.Length); + Assert.Equal("2", cliffords[1]); + } + + /// + /// Shows that T gates on different qubits are counted for depth purposes as + /// executing in parallel. + /// + [Fact] + public void DepthDifferentQubitsTest() + { + var sim = new ResourcesEstimator(); + + // using(q = Qubit[3]) { T(q[0]); T(q[1]); T(q[3]); T(q[0]); } + DepthDifferentQubits.Run(sim).Wait(); + var data = sim.Data; + + Assert.Equal(4.0, data.Rows.Find("T")["Sum"]); + Assert.Equal(3.0, data.Rows.Find("Width")["Sum"]); + Assert.Equal(2.0, data.Rows.Find("Depth")["Sum"]); + } + + [Fact] + public void QubitReuseWithOptimizedDepthTest() { + QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); + config.OptimizeDepth = true; + var sim = new ResourcesEstimator(config); + + QubitReuseWithOptimizedDepth.Run(sim).Wait(); + + Assert.Equal(2.0, sim.Data.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(2.0, sim.Data.Rows.Find("Width")["Sum"]); + Assert.Equal(1.0, sim.Data.Rows.Find("Depth")["Sum"]); + } + + [Fact] + public void QubitReuseSimultaneousTest() { + QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); + config.OptimizeDepth = true; + var sim = new ResourcesEstimator(config); + + SimultaneousUse.Run(sim).Wait(); + + Assert.Equal(11.0, sim.Data.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(20.0, sim.Data.Rows.Find("Width")["Sum"]); + // Note that in RecommendedConfig only T gates are depth 1, the rest are depth 0. + Assert.Equal(1.0, sim.Data.Rows.Find("Depth")["Sum"]); + } + + [Fact] + public void QubitReuseSequentialTest() { + QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); + config.OptimizeDepth = true; + var sim = new ResourcesEstimator(config); + + SequentialUse.Run(sim).Wait(); + + Assert.Equal(11.0, sim.Data.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(20.0, sim.Data.Rows.Find("Width")["Sum"]); + Assert.Equal(11.0, sim.Data.Rows.Find("Depth")["Sum"]); + } + + + /// + /// Documents that the QubitCount and Depth statistics reflect independent lower + /// bounds for each (two T gates cannot be combined into a circuit of depth + /// one and width one). Width on the other hand is compatible with Depth. + /// + [Fact] + public void DepthVersusWidthTest() + { + // Operation to execute: + // using(q = Qubit()) { T(q); } using(q = Qubit()) { T(q); } (yes, twice) + + // First run with width optimization + DataTable data = RunDepthVersusWidthTest(optimizeDepth: false); + Assert.Equal(2.0, data.Rows.Find("T")["Sum"]); + Assert.Equal(1.0, data.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(1.0, data.Rows.Find("Width")["Sum"]); + Assert.Equal(2.0, data.Rows.Find("Depth")["Sum"]); + + // Now run with depth optimization + data = RunDepthVersusWidthTest(optimizeDepth: true); + Assert.Equal(2.0, data.Rows.Find("T")["Sum"]); + Assert.Equal(1.0, data.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(2.0, data.Rows.Find("Width")["Sum"]); + Assert.Equal(1.0, data.Rows.Find("Depth")["Sum"]); + } + + private DataTable RunDepthVersusWidthTest(bool optimizeDepth) + { + QCTraceSimulators.QCTraceSimulatorConfiguration config = ResourcesEstimator.RecommendedConfig(); + config.OptimizeDepth = optimizeDepth; + var sim = new ResourcesEstimator(config); + + DepthVersusWidth.Run(sim).Wait(); + return sim.Data; + } + + /// + /// Verifies that for multiple separately traced operations, the final + /// statistics are cumulative. + /// + [Fact] + public void VerifyTracingMultipleOperationsTest() + { + ResourcesEstimator sim = new ResourcesEstimator(); + + Operation_1_of_2.Run(sim).Wait(); + DataTable data1 = sim.Data; + + Assert.Equal(1.0, data1.Rows.Find("CNOT")["Sum"]); + Assert.Equal(1.0, data1.Rows.Find("QubitClifford")["Sum"]); + Assert.Equal(1.0, data1.Rows.Find("T")["Sum"]); + Assert.Equal(0.0, data1.Rows.Find("R")["Sum"]); + Assert.Equal(0.0, data1.Rows.Find("Measure")["Sum"]); + Assert.Equal(2.0, data1.Rows.Find("QubitCount")["Sum"]); + + Operation_2_of_2.Run(sim).Wait(); + DataTable data2 = sim.Data; + + // Aggregated stats for both operations. + Assert.Equal(1.0 + 2.0, data2.Rows.Find("CNOT")["Sum"]); + Assert.Equal(1.0 + 1.0, data2.Rows.Find("QubitClifford")["Sum"]); + Assert.Equal(1.0 + 0.0, data2.Rows.Find("T")["Sum"]); + Assert.Equal(0.0 + 1.0, data2.Rows.Find("R")["Sum"]); + Assert.Equal(0.0 + 1.0, data2.Rows.Find("Measure")["Sum"]); + Assert.Equal(2.0 + 3.0, data2.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(System.Math.Max(2.0, 3.0), data2.Rows.Find("QubitCount")["Max"]); + + // Run again to confirm two operations isn't the limit! + VerySimpleEstimate.Run(sim).Wait(); + DataTable data3 = sim.Data; + Assert.Equal(2.0 + 3.0 + 3.0, data3.Rows.Find("QubitCount")["Sum"]); + Assert.Equal(3.0, data3.Rows.Find("QubitCount")["Max"]); + } + } +} diff --git a/src/Simulation/Simulators.Tests/SimulatorBaseTests.cs b/src/Simulation/Simulators.Tests/SimulatorBaseTests.cs index da983d1e352..295c2032040 100644 --- a/src/Simulation/Simulators.Tests/SimulatorBaseTests.cs +++ b/src/Simulation/Simulators.Tests/SimulatorBaseTests.cs @@ -10,18 +10,6 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests { - public static class Extensions - { - /// - /// This method is a wrapper to let the tests keep using a one Type parameter - /// method to fetch for Gates. - /// - public static T Get(this SimulatorBase sim) where T : AbstractCallable - { - return sim.Get(); - } - } - public class SimulatorBaseTests { private readonly ITestOutputHelper output; @@ -83,7 +71,7 @@ public void OperationWithNoBody() Assert.Throws(() => { - subject.Get(); + subject.Get(); }); } @@ -98,7 +86,7 @@ public void OperationWithNotImplementedDependency() Assert.Throws(() => { - subject.Get(); + subject.Get(); }); } @@ -135,11 +123,6 @@ public void UserDefinedOperations() var subject = new TrivialSimulator(); Assert.Equal(typeof(TrivialSimulator).Name, subject.Name); - Assert.Throws(() => - { - subject.Get(); - }); - try { subject.Register(null, typeof(DummyX)); @@ -229,19 +212,19 @@ public void GenericDependencies() { var subject = new TrivialSimulator(); - // Can't get Gen because it depends on X + // Can't get Gen because it depends on AssertMeasurement Assert.Throws(() => { subject.Get>(); }); // TODO: because we can't check dependencies, this - // is not throwing an Exception, even though Gen depends on X: + // is not throwing an Exception, even though Gen depends on AssertMeasurement: var gen1 = subject.Get(); Assert.NotNull(gen1); // Add an implementation of X: - subject.Register(typeof(Intrinsic.X), typeof(LikeX), typeof(IUnitary)); + subject.Register(typeof(Diagnostics.AssertMeasurement), typeof(DummyAssertMeasurement)); var gen2 = subject.Get>(); Assert.NotNull(gen1); @@ -350,22 +333,39 @@ public override void __Init__() } } + /// + /// This class has no implementation, it's just ther eto make sure + /// a user can register their own Operation overrides. + /// + public class DummyAssertMeasurement : Diagnostics.AssertMeasurement + { + public DummyAssertMeasurement(IOperationFactory m) : base(m) + { + } + + public override Func<(IQArray, IQArray, Result, String), QVoid> __Body__ => throw new NotImplementedException(); + + public override void __Init__() + { + } + } + /// - /// This class is not abstract, but depends on X, which is. + /// This class is not abstract, but depends on AssertMeasurement, which is. /// - public class DependsOnX : Operation, ICallable + public class DependsOnAssertMeasurement : Operation, ICallable { - public DependsOnX(IOperationFactory m) : base(m) + public DependsOnAssertMeasurement(IOperationFactory m) : base(m) { } - string ICallable.FullName => "DependsOnX"; + string ICallable.FullName => "DependsOnAssertMeasurement"; - public IUnitary X { get; set; } + public IUnitary<(IQArray, IQArray, Result, String)> AssertMeasurement { get; set; } public override void __Init__() { - this.X = this.__Factory__.Get, Intrinsic.X>(); + this.AssertMeasurement = this.__Factory__.Get, IQArray, Result, String)>, Diagnostics.AssertMeasurement>(); } public override Func __Body__ => throw new NotImplementedException(); @@ -450,12 +450,12 @@ public Gen(IOperationFactory m) : base(m) public ICallable A { get; set; } - public IUnitary X { get; set; } + public IUnitary<(IQArray, IQArray, Result, String)> AssertMeasurement { get; set; } public override void __Init__() { this.A = this.__Factory__.Get(); - this.X = this.__Factory__.Get, Intrinsic.X>(); + this.AssertMeasurement = this.__Factory__.Get, IQArray, Result, String)>, Diagnostics.AssertMeasurement>(); } } diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj index 2e2aaa2419d..28e304414be 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj index 0c26fcc91ab..799d358d556 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj @@ -1,9 +1,8 @@ - + netcoreapp3.1 false - true false false @@ -11,8 +10,8 @@ - + diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index 823feef39e8..94d7405b7b1 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj index 5579f6e7271..4f2ef463018 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 false diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj index 8f491550555..9f630a00e09 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj index 8f491550555..9f630a00e09 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj index e7eae4c72d5..cffa1db49f8 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj index 5dd519483e3..20a6fe41b7d 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj @@ -1,4 +1,4 @@ - + Exe @@ -12,6 +12,7 @@ + diff --git a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj index 2085a1032e2..d447ab9426a 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/Hello.qs b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/Hello.qs index 8e5d87f77a8..4d8cd71c3b1 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/Hello.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/Hello.qs @@ -1,16 +1,16 @@ -// Used for a unit test; -// do not change the name of this namespace! -namespace Microsoft.Quantum.Library { - - open Microsoft.Quantum.Intrinsic; - - // Used for a unit test; - // do not change the name or namespace of this type! - newtype Token = Unit; - - // Used for a unit test; - // do not change the name or namespace of this callable! - operation Hello(dummy : Token) : Unit { - Message("Hello!"); - } +// Used for a unit test; +// do not change the name of this namespace! +namespace Microsoft.Quantum.Library { + + open Microsoft.Quantum.Intrinsic; + + // Used for a unit test; + // do not change the name or namespace of this type! + newtype Token = Unit; + + // Used for a unit test; + // do not change the name or namespace of this callable! + operation Hello(dummy : Token) : Unit { + Message("Hello!"); + } } \ No newline at end of file diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index d494173e271..ea3817022c4 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -11,7 +11,6 @@ - diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj index f827fddd63d..0db807e3577 100644 --- a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj @@ -1,15 +1,6 @@ - + - - - - - - netcoreapp3.1 - false - false - false - + @@ -18,8 +9,8 @@ - - + + false @@ -28,16 +19,6 @@ - - - - - - - - - - <_ExeDir>$(MSBuildThisFileDirectory)TestProjects\QSharpExe\built\ diff --git a/src/Simulation/Simulators.Tests/TracerHelper.cs b/src/Simulation/Simulators.Tests/TracerHelper.cs new file mode 100644 index 00000000000..96520317852 --- /dev/null +++ b/src/Simulation/Simulators.Tests/TracerHelper.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Common; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators.Tests +{ + static partial class OperationsTestHelper + { + public static TraceImpl GetTracer(this SimulatorBase s) + { + return s.Get(typeof(Tests.Circuits.Generics.Trace<>)).FindCallable(typeof(T), typeof(QVoid)) as TraceImpl; + } + + + public class TracerImpl : Tests.Circuits.ClosedType.Trace + { + public TracerImpl(IOperationFactory m) : base(m) + { + this.Log = new Log(); + } + + public override Func __Body__ => (tag) => this.Log.Record(OperationFunctor.Body, tag); + public override Func __AdjointBody__ => (tag) => this.Log.Record(OperationFunctor.Adjoint, tag); + public override Func<(IQArray, string), QVoid> __ControlledBody__ => (args) => this.Log.Record(OperationFunctor.Controlled, args.Item2); + public override Func<(IQArray, string), QVoid> __ControlledAdjointBody__ => (args) => this.Log.Record(OperationFunctor.ControlledAdjoint, args.Item2); + + public Log Log { get; } + } + + public class TraceImpl : Tests.Circuits.Generics.Trace + { + public TraceImpl(IOperationFactory m) : base(m) + { + this.Log = new Log(); + } + + public override Func __Body__ => (tag) => this.Log.Record(OperationFunctor.Body, tag); + public override Func __AdjointBody__ => (tag) => this.Log.Record(OperationFunctor.Adjoint, tag); + public override Func<(IQArray, T), QVoid> __ControlledBody__ => (args) => this.Log.Record(OperationFunctor.Controlled, args.Item2); + public override Func<(IQArray, T), QVoid> __ControlledAdjointBody__ => (args) => this.Log.Record(OperationFunctor.ControlledAdjoint, args.Item2); + + public int GetNumberOfCalls(OperationFunctor functor, T tag) => this.Log.GetNumberOfCalls(functor, tag); + + public Log Log { get; } + } + + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators.Type1.Tests/App.config b/src/Simulation/Simulators.Type1.Tests/App.config new file mode 100644 index 00000000000..afca86583e1 --- /dev/null +++ b/src/Simulation/Simulators.Type1.Tests/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Simulation/Simulators.Type1.Tests/OperationsTestHelperSimSupport.cs b/src/Simulation/Simulators.Type1.Tests/OperationsTestHelperSimSupport.cs new file mode 100644 index 00000000000..418ccdc8176 --- /dev/null +++ b/src/Simulation/Simulators.Type1.Tests/OperationsTestHelperSimSupport.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Common; + +namespace Microsoft.Quantum.Simulation.Simulators.Tests +{ + static partial class OperationsTestHelper + { + public static bool ShouldPerformQubitUniquenessTest = false; + + private static void InitSimulator(SimulatorBase sim) + { + sim.InitBuiltinOperations(typeof(OperationsTestHelper)); + } + + public static void RunWithMultipleSimulators(Action test) + { + var simulators = new SimulatorBase[] { new QuantumSimulator() }; + + foreach (var s in simulators) + { + try + { + InitSimulator(s); + + test(s); + } + finally + { + if (s is IDisposable sim) + { + sim.Dispose(); + } + } + } + } + } +} diff --git a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj new file mode 100644 index 00000000000..56ec206e682 --- /dev/null +++ b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/Simulators.Type2.Tests/App.config b/src/Simulation/Simulators.Type2.Tests/App.config new file mode 100644 index 00000000000..afca86583e1 --- /dev/null +++ b/src/Simulation/Simulators.Type2.Tests/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Simulation/Simulators.Type2.Tests/OperationsTestHelperSimSupport.cs b/src/Simulation/Simulators.Type2.Tests/OperationsTestHelperSimSupport.cs new file mode 100644 index 00000000000..47fd980d979 --- /dev/null +++ b/src/Simulation/Simulators.Type2.Tests/OperationsTestHelperSimSupport.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Common; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators.Tests +{ + static partial class OperationsTestHelper + { + public static bool ShouldPerformQubitUniquenessTest = false; + + private static void InitSimulator(SimulatorBase sim) + { + sim.InitBuiltinOperations(typeof(OperationsTestHelper)); + } + + public static void RunWithMultipleSimulators(Action test) + { + var simulators = new SimulatorBase[] { new QuantumSimulator() }; + + foreach (var s in simulators) + { + try + { + InitSimulator(s); + + test(s); + } + finally + { + if (s is IDisposable sim) + { + sim.Dispose(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj new file mode 100644 index 00000000000..094f95bf64b --- /dev/null +++ b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/Simulators/FindNuspecReferences.ps1 b/src/Simulation/Simulators/FindNuspecReferences.ps1 index 993f4b0948e..fecd108c923 100644 --- a/src/Simulation/Simulators/FindNuspecReferences.ps1 +++ b/src/Simulation/Simulators/FindNuspecReferences.ps1 @@ -7,7 +7,7 @@ # This is problematic because we currently don't want to create a package for every dll. # # On the other hand, when creating a package using nuget pack, nuget does not -# identifies PackageReferences defined in the csproj, so all the dependencies +# identify PackageReferences defined in the csproj, so all the dependencies # are not listed and the package doesn't work. # # We don't want to hardcode the list of dependencies on the .nuspec, as they can @@ -97,7 +97,7 @@ function Add-NuGetDependencyFromCsprojToNuspec($PathToCsproj) # Find all dependencies packaged as part of Microsoft.Quantum.Simulators Add-NuGetDependencyFromCsprojToNuspec "../QCTraceSimulator/Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj" # has a dependency on Common, need to list this because it is listed only in an imported props file ... -Add-NuGetDependencyFromCsprojToNuspec "../Simulators/Microsoft.Quantum.Simulators.csproj" +Add-NuGetDependencyFromCsprojToNuspec "Microsoft.Quantum.Simulators.csproj" # Save into .nuspec file: $nuspec.package.metadata.AppendChild($dep) diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index 46bf637dc8e..ea6204631f3 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,27 +1,25 @@ - - + + 8.0 + enable netstandard2.1 false false - - 8.0 - enable - - - + + + diff --git a/src/Simulation/Simulators/QCTraceSimulator/Circuits/Interface.qs b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Interface.qs index b3a4884303c..bccc4e6a815 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/Circuits/Interface.qs +++ b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Interface.qs @@ -1,80 +1,80 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Implementation { - - /// # Summary - /// Controlled-X gate natively supported by the machine - /// - /// # Input - /// ## control - /// the qubit used to control the application of X gate - /// ## target - /// the qubit to which Pauli X is applied when control qubit is in state |1⟩ - /// - /// # Remarks - /// Controlled-X gate with target on qubit 2 and control on qubit 1 - /// is C₁X₂ = [ [1,0,0,0], [0,1,0,0], [0,0,0,1], [0,0,1,0] ] - operation Interface_CX (control : Qubit, target : Qubit) : Unit { - body intrinsic; - } - - /// # Summary - /// R gate natively supported by the machine. It is exp(-iφP/2) where P is the Pauli matrix - /// - /// # Input - /// ## axis - /// Pauli matrix, P - /// ## angle - /// Rotation angle, φ - /// ## target - /// the qubit operation is acting on - operation Interface_R (axis : Pauli, angle : Double, target : Qubit) : Unit { - body intrinsic; - } - - /// # Summary - /// RzFrac gate natively supported by the machine. It is exp(iπkP/2ⁿ) where P is the Pauli matrix - /// - /// # Input - /// ## axis - /// Pauli matrix, P - /// ## numerator - /// k - /// ## power - /// n - /// ## target - /// the qubit operation is acting on - /// - /// # Remarks - /// When power is 3 or less the operation is guaranteed to use S and T and Z gates to perform rotation - operation Interface_RFrac (axis : Pauli, numerator : Int, power : Int, target : Qubit) : Unit { - body intrinsic; - } - - /// # Summary - /// Applies Clifford multiplied by a pauli matrix - /// given by 'pauli' to the qubit given by 'target' - /// - /// # Input - /// ## cliffordId - /// Id of the single qubit unitary to apply. See remarks - /// - /// # Remarks - /// The list of id's corresponding to Cliffords is given by: - /// Identity - 0 - /// H - 1 - /// S - 2 - /// H followed by S ( as circuit ) - 3 - /// S followed by H ( as circuit ) - 4 - /// H S H - 5 - operation Interface_Clifford (cliffordId : Int, pauli : Pauli, target : Qubit) : Unit { - body intrinsic; - } - - - /// Forces the future measurement of a given observable to give specified result - operation ForceMeasure (observable : Pauli[], target : Qubit[], result : Result) : Unit { - body intrinsic; - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Implementation { + + /// # Summary + /// Controlled-X gate natively supported by the machine + /// + /// # Input + /// ## control + /// the qubit used to control the application of X gate + /// ## target + /// the qubit to which Pauli X is applied when control qubit is in state |1⟩ + /// + /// # Remarks + /// Controlled-X gate with target on qubit 2 and control on qubit 1 + /// is C₁X₂ = [ [1,0,0,0], [0,1,0,0], [0,0,0,1], [0,0,1,0] ] + operation Interface_CX (control : Qubit, target : Qubit) : Unit { + body intrinsic; + } + + /// # Summary + /// R gate natively supported by the machine. It is exp(-iφP/2) where P is the Pauli matrix + /// + /// # Input + /// ## axis + /// Pauli matrix, P + /// ## angle + /// Rotation angle, φ + /// ## target + /// the qubit operation is acting on + operation Interface_R (axis : Pauli, angle : Double, target : Qubit) : Unit { + body intrinsic; + } + + /// # Summary + /// RzFrac gate natively supported by the machine. It is exp(iπkP/2ⁿ) where P is the Pauli matrix + /// + /// # Input + /// ## axis + /// Pauli matrix, P + /// ## numerator + /// k + /// ## power + /// n + /// ## target + /// the qubit operation is acting on + /// + /// # Remarks + /// When power is 3 or less the operation is guaranteed to use S and T and Z gates to perform rotation + operation Interface_RFrac (axis : Pauli, numerator : Int, power : Int, target : Qubit) : Unit { + body intrinsic; + } + + /// # Summary + /// Applies Clifford multiplied by a pauli matrix + /// given by 'pauli' to the qubit given by 'target' + /// + /// # Input + /// ## cliffordId + /// Id of the single qubit unitary to apply. See remarks + /// + /// # Remarks + /// The list of id's corresponding to Cliffords is given by: + /// Identity - 0 + /// H - 1 + /// S - 2 + /// H followed by S ( as circuit ) - 3 + /// S followed by H ( as circuit ) - 4 + /// H S H - 5 + operation Interface_Clifford (cliffordId : Int, pauli : Pauli, target : Qubit) : Unit { + body intrinsic; + } + + + /// Forces the future measurement of a given observable to give specified result + operation ForceMeasure (observable : Pauli[], target : Qubit[], result : Result) : Unit { + body intrinsic; + } +} diff --git a/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingXX.qs b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingXX.qs new file mode 100644 index 00000000000..3a3a2fb9899 --- /dev/null +++ b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingXX.qs @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits { + internal operation IsingXX (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliX, PauliX], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingYY.qs b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingYY.qs new file mode 100644 index 00000000000..78484a19d3d --- /dev/null +++ b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingYY.qs @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits { + internal operation IsingYY (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliY, PauliY], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingZZ.qs b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingZZ.qs new file mode 100644 index 00000000000..797f7986f71 --- /dev/null +++ b/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingZZ.qs @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits { + internal operation IsingZZ (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliZ, PauliZ], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.Primitive.Measure.cs b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.Primitive.Measure.cs index 963c13b25bd..b13a03116da 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.Primitive.Measure.cs +++ b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.Primitive.Measure.cs @@ -8,21 +8,9 @@ namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Implementati public partial class QCTraceSimulatorImpl { - public class TracerMeasure : Intrinsic.Measure + public virtual Result Measure__Body(IQArray paulis, IQArray targets) { - private readonly QCTraceSimulatorImpl core; - public TracerMeasure(QCTraceSimulatorImpl m) : base(m){ - core = m; - } - - public override Func<(IQArray, IQArray), Result> - __Body__ => (args) => - { - (IQArray observable, IQArray target) = args; - return core.Measure(observable, target); - }; + return this.Measure(paulis, targets); } - - } } diff --git a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.cs b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.cs index 5ba05575fe9..5710381e010 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.cs +++ b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.cs @@ -10,6 +10,7 @@ namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators using System; using System.Collections.Generic; using System.Linq; + using System.Reflection; /// /// Groups of primitive operations counted by . @@ -398,13 +399,14 @@ public string[] GetMetricStatisticNames(string metric) /// Creates a new instance of the simulator with the default /// . /// - public QCTraceSimulator() : this( new QCTraceSimulatorConfiguration() ) { } + public QCTraceSimulator() : this(new QCTraceSimulatorConfiguration() ) { } /// /// Creates a new instance of the simulator with configuration given by /// the parameter. /// - public QCTraceSimulator(QCTraceSimulatorConfiguration config) : base(config) { } + public QCTraceSimulator(QCTraceSimulatorConfiguration config, Assembly? coreAssembly = null) : + base(config, coreAssembly) { } /// /// Array of the names of all of the metrics collected by this instance of the simulator. diff --git a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs index 544be07dde6..4e614f5a524 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs +++ b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs @@ -7,14 +7,16 @@ using Microsoft.Quantum.Simulation.Core; using System.Diagnostics; using System.Linq; +using System.Reflection; using Microsoft.Quantum.Simulation.Common; +using Microsoft.Quantum.Intrinsic.Interfaces; namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Implementation { /// /// Internals of . For internal use only. /// - public partial class QCTraceSimulatorImpl : SimulatorBase + public partial class QCTraceSimulatorImpl : SimulatorBase, IGate_Measure { protected readonly QCTraceSimulatorConfiguration configuration; private readonly QCTraceSimulatorCore tracingCore; @@ -61,10 +63,9 @@ protected string GetOperationName() return this.GetInstance(typeof(T)).GetType().FullName; } - public QCTraceSimulatorImpl() : this(new QCTraceSimulatorConfiguration()) { } - public QCTraceSimulatorImpl(QCTraceSimulatorConfiguration config) + public QCTraceSimulatorImpl(QCTraceSimulatorConfiguration config, Assembly? coreAssembly = null) { configuration = Utils.DeepClone(config); Utils.FillDictionaryForEnumNames(primitiveOperationsIdToNames); @@ -107,7 +108,7 @@ public QCTraceSimulatorImpl(QCTraceSimulatorConfiguration config) OnOperationStart += tracingCore.OnOperationStart; OnOperationEnd += tracingCore.OnOperationEnd; - RegisterPrimitiveOperationsGivenAsCircuits(); + RegisterPrimitiveOperationsGivenAsCircuits(coreAssembly); } /// @@ -146,13 +147,26 @@ protected virtual void InitializeQCTracerCoreListeners(IList primitiveOperationTypes = - from op in typeof(Intrinsic.X).Assembly.GetExportedTypes() + from op in intrinsicAssembly.GetExportedTypes() where op.IsSubclassOf(typeof(AbstractCallable)) select op; + if (primitiveOperationTypes.Count() == 0) + { + throw new Exception("Unable to load intrinsic types. The ResourcesEstimator can only be used with the default execution target."); + } + IEnumerable primitiveOperationAsCircuits = from op in typeof(Circuits.X).Assembly.GetExportedTypes() where op.IsSubclassOf(typeof(AbstractCallable)) diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyControlledX.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyControlledX.cs new file mode 100644 index 00000000000..8e179f2d8a7 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyControlledX.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyControlledX__Body(Qubit control, Qubit target) + { + this.CheckQubits(new QArray(new Qubit[]{ control, target })); + + MCX(this.Id, 1, new uint[]{(uint)control.Id}, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyControlledZ.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyControlledZ.cs new file mode 100644 index 00000000000..1cfbeed2a0e --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyControlledZ.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyControlledZ__Body(Qubit control, Qubit target) + { + this.CheckQubits(new QArray(new Qubit[]{ control, target })); + + MCZ(this.Id, 1, new uint[]{(uint)control.Id}, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledH.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledH.cs new file mode 100644 index 00000000000..453fbe28339 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledH.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledH__Body(Qubit target) + { + this.CheckQubit(target); + + H(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRx.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRx.cs new file mode 100644 index 00000000000..56e7358db96 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRx.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledRx__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliX, angle, (uint)target.Id); + } + + public virtual void ApplyUncontrolledRx__AdjointBody(double angle, Qubit target) + { + ApplyUncontrolledRx__Body(-angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRy.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRy.cs new file mode 100644 index 00000000000..05c811dc667 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRy.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledRy__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliY, angle, (uint)target.Id); + } + + public virtual void ApplyUncontrolledRy__AdjointBody(double angle, Qubit target) + { + ApplyUncontrolledRy__Body(-angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRz.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRz.cs new file mode 100644 index 00000000000..d6343548bca --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledRz.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledRz__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliZ, angle, (uint)target.Id); + } + + public virtual void ApplyUncontrolledRz__AdjointBody(double angle, Qubit target) + { + ApplyUncontrolledRz__Body(-angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledS.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledS.cs new file mode 100644 index 00000000000..e9e08bdb6f3 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledS.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledS__Body(Qubit target) + { + this.CheckQubit(target); + + S(this.Id, (uint)target.Id); + } + + public virtual void ApplyUncontrolledS__AdjointBody(Qubit target) + { + this.CheckQubit(target); + + AdjS(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledT.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledT.cs new file mode 100644 index 00000000000..3f3e4902be5 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledT.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledT__Body(Qubit target) + { + this.CheckQubit(target); + + T(this.Id, (uint)target.Id); + } + + public virtual void ApplyUncontrolledT__AdjointBody(Qubit target) + { + this.CheckQubit(target); + + AdjT(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledX.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledX.cs new file mode 100644 index 00000000000..13aaf95b503 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledX.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledX__Body(Qubit target) + { + this.CheckQubit(target); + + X(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledY.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledY.cs new file mode 100644 index 00000000000..5e409019a40 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledY.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledY__Body(Qubit target) + { + this.CheckQubit(target); + + Y(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledZ.cs b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledZ.cs new file mode 100644 index 00000000000..09eb9f70e9e --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/ApplyUncontrolledZ.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void ApplyUncontrolledZ__Body(Qubit target) + { + this.CheckQubit(target); + + Z(this.Id, (uint)target.Id); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/Assert.cs b/src/Simulation/Simulators/QuantumSimulator/Assert.cs index 917a4c16053..fb7d2ec5952 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Assert.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Assert.cs @@ -14,9 +14,6 @@ public partial class QuantumSimulator { public class QSimAssert : Microsoft.Quantum.Diagnostics.AssertMeasurement { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "JointEnsembleProbability")] - private static extern double JointEnsembleProbability(uint id, uint n, Pauli[] b, uint[] q); - private QuantumSimulator Simulator { get; } public QSimAssert(QuantumSimulator m) : base(m) diff --git a/src/Simulation/Simulators/QuantumSimulator/AssertProb.cs b/src/Simulation/Simulators/QuantumSimulator/AssertProb.cs index 2e3550bfd25..8cc32bb0f9e 100644 --- a/src/Simulation/Simulators/QuantumSimulator/AssertProb.cs +++ b/src/Simulation/Simulators/QuantumSimulator/AssertProb.cs @@ -14,12 +14,8 @@ public partial class QuantumSimulator { public class QSimAssertProb : Microsoft.Quantum.Diagnostics.AssertMeasurementProbability { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "JointEnsembleProbability")] - private static extern double JointEnsembleProbability(uint id, uint n, Pauli[] b, uint[] q); - private QuantumSimulator Simulator { get; } - public QSimAssertProb(QuantumSimulator m) : base(m) { this.Simulator = m; diff --git a/src/Simulation/Simulators/QuantumSimulator/Dump.cs b/src/Simulation/Simulators/QuantumSimulator/Dump.cs index 5cd3a4dd2a3..d57d0b7dd4a 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Dump.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Dump.cs @@ -67,7 +67,6 @@ public class QsimDumpMachine : Quantum.Diagnostics.DumpMachine { private QuantumSimulator Simulator { get; } - public QsimDumpMachine(QuantumSimulator m) : base(m) { this.Simulator = m; @@ -85,7 +84,6 @@ public class QSimDumpRegister : Quantum.Diagnostics.DumpRegister { private QuantumSimulator Simulator { get; } - public QSimDumpRegister(QuantumSimulator m) : base(m) { this.Simulator = m; diff --git a/src/Simulation/Simulators/QuantumSimulator/Exp.cs b/src/Simulation/Simulators/QuantumSimulator/Exp.cs index 00f495f368e..fcab47bc9e8 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Exp.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Exp.cs @@ -10,71 +10,42 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimExp : Quantum.Intrinsic.Exp + public virtual void Exp__Body(IQArray paulis, double angle, IQArray targets) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Exp")] - private static extern void Exp(uint id, uint n, Pauli[] paulis, double angle, uint[] ids); + this.CheckQubits(targets); + CheckAngle(angle); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCExp")] - private static extern void MCExp(uint id, uint n, Pauli[] paulis, double angle, uint nc, uint[] ctrls, uint[] ids); - - private QuantumSimulator Simulator { get; } - - - public QSimExp(QuantumSimulator m) : base(m) + if (paulis.Length != targets.Length) { - this.Simulator = m; + throw new InvalidOperationException($"Both input arrays for Exp (paulis, targets), must be of same size."); } - public override Func<(IQArray, double, IQArray), QVoid> __Body__ => (_args) => - { - var (paulis, theta, qubits) = _args; - - Simulator.CheckQubits(qubits); - CheckAngle(theta); - - if (paulis.Length != qubits.Length) - { - throw new InvalidOperationException($"Both input arrays for {this.GetType().Name} (paulis,qubits), must be of same size."); - } - - Exp(Simulator.Id, (uint)paulis.Length, paulis.ToArray(), theta, qubits.GetIds()); - - return QVoid.Instance; - }; + Exp(this.Id, (uint)paulis.Length, paulis.ToArray(), angle, targets.GetIds()); + } - public override Func<(IQArray, double, IQArray), QVoid> __AdjointBody__ => (_args) => - { - var (paulis, angle, qubits) = _args; + public virtual void Exp__AdjointBody(IQArray paulis, double angle, IQArray targets) + { + Exp__Body(paulis, -angle, targets); + } - return this.__Body__.Invoke((paulis, -angle, qubits)); - }; + public virtual void Exp__ControlledBody(IQArray controls, IQArray paulis, double angle, IQArray targets) + { + this.CheckQubits(controls, targets); + CheckAngle(angle); - public override Func<(IQArray, (IQArray, double, IQArray)), QVoid> __ControlledBody__ => (_args) => + if (paulis.Length != targets.Length) { - var (ctrls, (paulis, angle, qubits)) = _args; - - Simulator.CheckQubits(ctrls, qubits); - CheckAngle(angle); - - if (paulis.Length != qubits.Length) - { - throw new InvalidOperationException($"Both input arrays for {this.GetType().Name} (paulis,qubits), must be of same size."); - } - - SafeControlled(ctrls, - () => this.__Body__.Invoke((paulis, angle, qubits)), - (count, ids) => MCExp(Simulator.Id, (uint)paulis.Length, paulis.ToArray(), angle, count, ids, qubits.GetIds())); - - return QVoid.Instance; - }; + throw new InvalidOperationException($"Both input arrays for Exp (paulis, qubits), must be of same size."); + } - public override Func<(IQArray, (IQArray, double, IQArray)), QVoid> __ControlledAdjointBody__ => (_args) => - { - var (ctrls, (paulis, angle, qubits)) = _args; + SafeControlled(controls, + () => Exp__Body(paulis, angle, targets), + (count, ids) => MCExp(this.Id, (uint)paulis.Length, paulis.ToArray(), angle, count, ids, targets.GetIds())); + } - return this.__ControlledBody__.Invoke((ctrls, (paulis, -angle, qubits))); - }; + public virtual void Exp__ControlledAdjointBody(IQArray controls, IQArray paulis, double angle, IQArray targets) + { + Exp__ControlledBody(controls, paulis, -angle, targets); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/ExpFrac.cs b/src/Simulation/Simulators/QuantumSimulator/ExpFrac.cs deleted file mode 100644 index 83bfd33862b..00000000000 --- a/src/Simulation/Simulators/QuantumSimulator/ExpFrac.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; - -using Microsoft.Quantum.Simulation.Core; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - - public partial class QuantumSimulator - { - public class QSimExpFrac : Intrinsic.ExpFrac - { - public QSimExpFrac(QuantumSimulator m) : base(m) - { - } - - public static double Angle(long numerator, long power) => - (System.Math.PI * numerator) / (1 << (int)power); - - public override Func<(IQArray, long, long, IQArray), QVoid> __Body__ => (args) => - { - var (paulis, numerator, power, qubits) = args; - var angle = Angle(numerator, power); - return Exp__.Apply((paulis, angle, qubits)); - }; - - public override Func<(IQArray, long, long, IQArray), QVoid> __AdjointBody__ => (args) => - { - var (paulis, numerator, power, qubits) = args; - var angle = Angle(numerator, power); - return Exp__.Adjoint.Apply((paulis, angle, qubits)); - }; - - public override Func<(IQArray, (IQArray, long, long, IQArray)), QVoid> __ControlledBody__ => (args) => - { - var (ctrls, (paulis, numerator, power, qubits)) = args; - var angle = Angle(numerator, power); - return Exp__.Controlled.Apply((ctrls, (paulis, angle, qubits))); - }; - - public override Func<(IQArray, (IQArray, long, long, IQArray)), QVoid> __ControlledAdjointBody__ => (args) => - { - var (ctrls, (paulis, numerator, power, qubits)) = args; - var angle = Angle(numerator, power); - return Exp__.Adjoint.Controlled.Apply((ctrls, (paulis, angle, qubits))); - }; - } - } -} diff --git a/src/Simulation/Common/Extensions.cs b/src/Simulation/Simulators/QuantumSimulator/Extensions.cs similarity index 93% rename from src/Simulation/Common/Extensions.cs rename to src/Simulation/Simulators/QuantumSimulator/Extensions.cs index 22b14c4f7c3..9f073e6c6bd 100644 --- a/src/Simulation/Common/Extensions.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Extensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Reflection; using System.Diagnostics; using System.Linq; @@ -39,8 +40,12 @@ public static void InitBuiltinOperations(this Factory factory, Type t) InitBuiltinOperations(factory, t.BaseType); + var overrideTypes = t.GetNestedTypes( + System.Reflection.BindingFlags.Public | + System.Reflection.BindingFlags.NonPublic); + var ops = - from op in t.GetNestedTypes() + from op in overrideTypes where op.IsSubclassOf(typeof(T)) select op; diff --git a/src/Simulation/Simulators/QuantumSimulator/H.cs b/src/Simulation/Simulators/QuantumSimulator/H.cs index fc2b0a89d4d..57b9aed9169 100644 --- a/src/Simulation/Simulators/QuantumSimulator/H.cs +++ b/src/Simulation/Simulators/QuantumSimulator/H.cs @@ -9,44 +9,20 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimH : Intrinsic.H + public virtual void H__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "H")] - private static extern void H(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCH")] - private static extern void MCH(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimH(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); - - H(Simulator.Id, (uint)q1.Id); - - return QVoid.Instance; - }; - - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (args) => - { - var (ctrls, q1) = args; - - Simulator.CheckQubits(ctrls, q1); + H(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCH(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void H__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => H__Body(target), + (count, ids) => MCH(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/IsingXX.cs b/src/Simulation/Simulators/QuantumSimulator/IsingXX.cs new file mode 100644 index 00000000000..e36cdf6c602 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/IsingXX.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void IsingXX__Body(double angle, Qubit target1, Qubit target2) + { + var paulis = new Pauli[]{ Pauli.PauliX, Pauli.PauliX }; + var targets = new QArray(new Qubit[]{ target1, target2 }); + CheckAngle(angle); + this.CheckQubits(targets); + + Exp(this.Id, (uint)targets.Length, paulis, angle * 2.0, targets.GetIds()); + } + + public virtual void IsingXX__AdjointBody(double angle, Qubit target1, Qubit target2) + { + IsingXX__Body(-angle, target1, target2); + } + + public virtual void IsingXX__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + if (controls == null || controls.Length == 0) + { + IsingXX__Body(angle, target1, target2); + } + else + { + var targets = new QArray(new Qubit[]{ target1, target2 }); + var paulis = new Pauli[]{ Pauli.PauliX, Pauli.PauliX }; + CheckAngle(angle); + this.CheckQubits(QArray.Add(controls, targets)); + + MCExp(this.Id, (uint)targets.Length, paulis, angle * 2.0, (uint)controls.Length, controls.GetIds(), targets.GetIds()); + } + } + + public virtual void IsingXX__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + IsingXX__ControlledBody(controls, -angle, target1, target2); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/IsingYY.cs b/src/Simulation/Simulators/QuantumSimulator/IsingYY.cs new file mode 100644 index 00000000000..924a7903981 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/IsingYY.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void IsingYY__Body(double angle, Qubit target1, Qubit target2) + { + var paulis = new Pauli[]{ Pauli.PauliY, Pauli.PauliY }; + var targets = new QArray(new Qubit[]{ target1, target2 }); + CheckAngle(angle); + this.CheckQubits(targets); + + Exp(this.Id, (uint)targets.Length, paulis, angle * 2.0, targets.GetIds()); + } + + public virtual void IsingYY__AdjointBody(double angle, Qubit target1, Qubit target2) + { + IsingYY__Body(-angle, target1, target2); + } + + public virtual void IsingYY__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + if (controls == null || controls.Length == 0) + { + IsingYY__Body(angle, target1, target2); + } + else + { + var targets = new QArray(new Qubit[]{ target1, target2 }); + var paulis = new Pauli[]{ Pauli.PauliY, Pauli.PauliY }; + CheckAngle(angle); + this.CheckQubits(QArray.Add(controls, targets)); + + MCExp(this.Id, (uint)targets.Length, paulis, angle * 2.0, (uint)controls.Length, controls.GetIds(), targets.GetIds()); + } + } + + public virtual void IsingYY__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + IsingYY__ControlledBody(controls, -angle, target1, target2); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/IsingZZ.cs b/src/Simulation/Simulators/QuantumSimulator/IsingZZ.cs new file mode 100644 index 00000000000..6265db3967d --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/IsingZZ.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void IsingZZ__Body(double angle, Qubit target1, Qubit target2) + { + var paulis = new Pauli[]{ Pauli.PauliZ, Pauli.PauliZ }; + var targets = new QArray(new Qubit[]{ target1, target2 }); + CheckAngle(angle); + this.CheckQubits(targets); + + Exp(this.Id, (uint)targets.Length, paulis, angle * 2.0, targets.GetIds()); + } + + public virtual void IsingZZ__AdjointBody(double angle, Qubit target1, Qubit target2) + { + IsingZZ__Body(-angle, target1, target2); + } + + public virtual void IsingZZ__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + if (controls == null || controls.Length == 0) + { + IsingZZ__Body(angle, target1, target2); + } + else + { + var targets = new QArray(new Qubit[]{ target1, target2 }); + var paulis = new Pauli[]{ Pauli.PauliZ, Pauli.PauliZ }; + CheckAngle(angle); + this.CheckQubits(QArray.Add(controls, targets)); + + MCExp(this.Id, (uint)targets.Length, paulis, angle * 2.0, (uint)controls.Length, controls.GetIds(), targets.GetIds()); + } + } + + public virtual void IsingZZ__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2) + { + IsingZZ__ControlledBody(controls, -angle, target1, target2); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/M.cs b/src/Simulation/Simulators/QuantumSimulator/M.cs index 2b4fee0874d..860daa5643e 100644 --- a/src/Simulation/Simulators/QuantumSimulator/M.cs +++ b/src/Simulation/Simulators/QuantumSimulator/M.cs @@ -11,26 +11,12 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimM : Quantum.Intrinsic.M + public virtual Result M__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "M")] - private static extern uint M(uint id, uint q); - - private QuantumSimulator Simulator { get; } - - - public QSimM(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q) => - { - Simulator.CheckQubit(q); - //setting qubit as measured to allow for release - q.IsMeasured = true; - return M(Simulator.Id, (uint)q.Id).ToResult(); - }; + this.CheckQubit(target); + //setting qubit as measured to allow for release + target.IsMeasured = true; + return M(this.Id, (uint)target.Id).ToResult(); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/Measure.cs b/src/Simulation/Simulators/QuantumSimulator/Measure.cs index 6931709f194..56b0dfaf6fb 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Measure.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Measure.cs @@ -9,36 +9,20 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimMeasure : Intrinsic.Measure + public virtual Result Measure__Body(IQArray paulis, IQArray targets) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Measure")] - private static extern uint Measure(uint id, uint n, Pauli[] b, uint[] ids); - - private QuantumSimulator Simulator { get; } - - - public QSimMeasure(QuantumSimulator m) : base(m) + this.CheckQubits(targets); + if (paulis.Length != targets.Length) { - this.Simulator = m; + throw new InvalidOperationException($"Both input arrays for Measure (paulis, targets), must be of same size"); } - - public override Func<(IQArray, IQArray), Result> __Body__ => (_args) => + if (targets.Length == 1) { - var (paulis, qubits) = _args; - - Simulator.CheckQubits(qubits); - if (paulis.Length != qubits.Length) - { - throw new InvalidOperationException($"Both input arrays for {this.GetType().Name} (paulis,qubits), must be of same size"); - } - if (qubits.Length == 1) - { - // When we are operating on a single qubit we will collapse the state, so mark - // that qubit as measured. - qubits[0].IsMeasured = true; - } - return Measure(Simulator.Id, (uint)paulis.Length, paulis.ToArray(), qubits.GetIds()).ToResult(); - }; + // When we are operating on a single qubit we will collapse the state, so mark + // that qubit as measured. + targets[0].IsMeasured = true; + } + return Measure(this.Id, (uint)paulis.Length, paulis.ToArray(), targets.GetIds()).ToResult(); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/NativeImports.cs b/src/Simulation/Simulators/QuantumSimulator/NativeImports.cs new file mode 100644 index 00000000000..30b84a41e8d --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/NativeImports.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "allocateQubit")] + private static extern void AllocateOne(uint id, uint qubit_id); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")] + private static extern bool ReleaseOne(uint id, uint qubit_id); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Exp")] + private static extern void Exp(uint id, uint n, Pauli[] paulis, double angle, uint[] ids); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCExp")] + private static extern void MCExp(uint id, uint n, Pauli[] paulis, double angle, uint nc, uint[] ctrls, uint[] ids); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "H")] + private static extern void H(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCH")] + private static extern void MCH(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "M")] + private static extern uint M(uint id, uint q); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Measure")] + private static extern uint Measure(uint id, uint n, Pauli[] b, uint[] ids); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "R")] + private static extern void R(uint id, Pauli basis, double angle, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCR")] + private static extern void MCR(uint id, Pauli basis, double angle, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "S")] + private static extern void S(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "AdjS")] + private static extern void AdjS(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCS")] + private static extern void MCS(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCAdjS")] + private static extern void MCAdjS(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "T")] + private static extern void T(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "AdjT")] + private static extern void AdjT(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCT")] + private static extern void MCT(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCAdjT")] + private static extern void MCAdjT(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "X")] + private static extern void X(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCX")] + private static extern void MCX(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Y")] + private static extern void Y(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCY")] + private static extern void MCY(uint id, uint count, uint[] ctrls, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Z")] + private static extern void Z(uint id, uint qubit); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCZ")] + private static extern void MCZ(uint id, uint count, uint[] ctrls, uint qubit); + + private delegate bool DumpCallback(uint idx, double real, double img); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Dump")] + private static extern void sim_Dump(uint id, DumpCallback callback); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DumpQubits")] + private static extern bool sim_DumpQubits(uint id, uint cout, uint[] ids, DumpCallback callback); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "JointEnsembleProbability")] + private static extern double JointEnsembleProbability(uint id, uint n, Pauli[] b, uint[] q); + + [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "random_choice")] + private static extern Int64 random_choice(uint id, Int64 size, double[] p); + } +} \ No newline at end of file diff --git a/src/Simulation/Simulators/QuantumSimulator/QuantumSimulator.cs b/src/Simulation/Simulators/QuantumSimulator/QuantumSimulator.cs index acf8fdf29b5..fdaafab5c9c 100644 --- a/src/Simulation/Simulators/QuantumSimulator/QuantumSimulator.cs +++ b/src/Simulation/Simulators/QuantumSimulator/QuantumSimulator.cs @@ -8,12 +8,13 @@ using System.Runtime.InteropServices; using System.Threading; using Microsoft.Quantum.Simulation.Simulators.Exceptions; +using Microsoft.Quantum.Intrinsic.Interfaces; using System.Collections.Generic; using System.Diagnostics; namespace Microsoft.Quantum.Simulation.Simulators { - public partial class QuantumSimulator : SimulatorBase, IDisposable + public partial class QuantumSimulator : SimulatorBase, IQSharpCore, IType1Core, IType2Core, IDisposable { public const string QSIM_DLL_NAME = "Microsoft.Quantum.Simulator.Runtime.dll"; @@ -213,7 +214,7 @@ static void SafeControlled(IQArray ctrls, Action noControlsAction, Action } else { - uint count = (uint)ctrls.Length; + uint count = (uint)ctrls.Length; controlledAction(count, ctrls.GetIds()); } } diff --git a/src/Simulation/Simulators/QuantumSimulator/Qubit.cs b/src/Simulation/Simulators/QuantumSimulator/Qubit.cs index 4a9f98c8760..010ccab7bf7 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Qubit.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Qubit.cs @@ -16,9 +16,6 @@ class QSimQubit : Qubit [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static Pauli[] PAULI_Z = new Pauli[] { Pauli.PauliZ }; - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "JointEnsembleProbability")] - private static extern double JointEnsembleProbability(uint id, uint n, Pauli[] b, uint[] q); - public QSimQubit(int id, uint simulatorId) : base(id) { this.SimulatorId = simulatorId; diff --git a/src/Simulation/Simulators/QuantumSimulator/QubitManager.cs b/src/Simulation/Simulators/QuantumSimulator/QubitManager.cs index 06fc6f64697..da2ac62b7cb 100644 --- a/src/Simulation/Simulators/QuantumSimulator/QubitManager.cs +++ b/src/Simulation/Simulators/QuantumSimulator/QubitManager.cs @@ -15,12 +15,6 @@ class QSimQubitManager : QubitManager { readonly bool throwOnReleasingQubitsNotInZeroState; - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "allocateQubit")] - private static extern void AllocateOne(uint id, uint qubit_id); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "release")] - private static extern bool ReleaseOne(uint id, uint qubit_id); - public uint SimulatorId { get; private set; } public QSimQubitManager(bool throwOnReleasingQubitsNotInZeroState = true, long qubitCapacity = 32, bool mayExtendCapacity = true, bool disableBorrowing = false) diff --git a/src/Simulation/Simulators/QuantumSimulator/R.cs b/src/Simulation/Simulators/QuantumSimulator/R.cs index 0d8e395f730..fb3d85ab9ea 100644 --- a/src/Simulation/Simulators/QuantumSimulator/R.cs +++ b/src/Simulation/Simulators/QuantumSimulator/R.cs @@ -7,65 +7,35 @@ namespace Microsoft.Quantum.Simulation.Simulators { - public partial class QuantumSimulator { - public class QSimR : Intrinsic.R + public virtual void R__Body(Pauli pauli, double angle, Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "R")] - private static extern void R(uint id, Pauli basis, double angle, uint qubit); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCR")] - private static extern void MCR(uint id, Pauli basis, double angle, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimR(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func<(Pauli, double, Qubit), QVoid> __Body__ => (_args) => - { - var (basis, angle, q1) = _args; - - Simulator.CheckQubit(q1); - CheckAngle(angle); - - R(Simulator.Id, basis, angle, (uint)q1.Id); - - return QVoid.Instance; - }; + this.CheckQubit(target); + CheckAngle(angle); - public override Func<(Pauli, double, Qubit), QVoid> __AdjointBody__ => (_args) => - { - var (basis, angle, q1) = _args; - - return this.__Body__.Invoke((basis, -angle, q1)); - }; - - public override Func<(IQArray, (Pauli, double, Qubit)), QVoid> __ControlledBody__ => (_args) => - { - var (ctrls, (basis, angle, q1)) = _args; - - Simulator.CheckQubits(ctrls, q1); - CheckAngle(angle); + R(this.Id, pauli, angle, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.__Body__.Invoke((basis, angle, q1)), - (count, ids) => MCR(Simulator.Id, basis, angle, count, ids, (uint)q1.Id)); + public virtual void R__AdjointBody(Pauli pauli, double angle, Qubit target) + { + R__Body(pauli, -angle, target); + } - return QVoid.Instance; - }; + public virtual void R__ControlledBody(IQArray controls, Pauli pauli, double angle, Qubit target) + { + this.CheckQubits(controls, target); + CheckAngle(angle); + SafeControlled(controls, + () => R__Body(pauli, angle, target), + (count, ids) => MCR(this.Id, pauli, angle, count, ids, (uint)target.Id)); + } - public override Func<(IQArray, (Pauli, double, Qubit)), QVoid> __ControlledAdjointBody__ => (_args) => - { - var (ctrls, (basis, angle, q1)) = _args; - return this.__ControlledBody__.Invoke((ctrls, (basis, -angle, q1))); - }; + public virtual void R__ControlledAdjointBody(IQArray controls, Pauli pauli, double angle, Qubit target) + { + R__ControlledBody(controls, pauli, -angle, target); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/RFrac.cs b/src/Simulation/Simulators/QuantumSimulator/RFrac.cs deleted file mode 100644 index 7e09e5a6b5a..00000000000 --- a/src/Simulation/Simulators/QuantumSimulator/RFrac.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; - -using Microsoft.Quantum.Simulation.Core; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - - public partial class QuantumSimulator - { - public class QSimRFrac : Intrinsic.RFrac - { - public QSimRFrac(QuantumSimulator m) : base(m) - { - } - - public static double Angle(long numerator, long power) => - (-2.0 * System.Math.PI * numerator) / (1 << (int)power); - - public override Func<(Pauli, long, long, Qubit), QVoid> __Body__ => (args) => - { - var (pauli, numerator, power, qubit) = args; - var angle = Angle(numerator, power); - return R__.Apply((pauli, angle, qubit)); - }; - - public override Func<(Pauli, long, long, Qubit), QVoid> __AdjointBody__ => (args) => - { - var (pauli, numerator, power, qubit) = args; - var angle = Angle(numerator, power); - return R__.Adjoint.Apply((pauli, angle, qubit)); - }; - - public override Func<(IQArray, (Pauli, long, long, Qubit)), QVoid> __ControlledBody__ => (args) => - { - var (ctrls, (pauli, numerator, power, qubit)) = args; - var angle = Angle(numerator, power); - return R__.Controlled.Apply((ctrls, (pauli, angle, qubit))); - }; - - public override Func<(IQArray, (Pauli, long, long, Qubit)), QVoid> __ControlledAdjointBody__ => (args) => - { - var (ctrls, (pauli, numerator, power, qubit)) = args; - var angle = Angle(numerator, power); - return R__.Adjoint.Controlled.Apply((ctrls, (pauli, angle, qubit))); - }; - } - } -} diff --git a/src/Simulation/Simulators/QuantumSimulator/random.cs b/src/Simulation/Simulators/QuantumSimulator/Random.cs similarity index 74% rename from src/Simulation/Simulators/QuantumSimulator/random.cs rename to src/Simulation/Simulators/QuantumSimulator/Random.cs index d1bc39e27a9..419bf425112 100644 --- a/src/Simulation/Simulators/QuantumSimulator/random.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Random.cs @@ -11,12 +11,8 @@ public partial class QuantumSimulator { public class QSimrandom : Quantum.Intrinsic.Random { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "random_choice")] - private static extern Int64 random_choice(uint id, Int64 size, double[] p); - private uint SimulatorId { get; } - public QSimrandom(QuantumSimulator m) : base(m) { this.SimulatorId = m.Id; @@ -25,7 +21,7 @@ public QSimrandom(QuantumSimulator m) : base(m) public override Func, Int64> __Body__ => (p) => { return random_choice(this.SimulatorId, p.Length, p.ToArray()); - }; + }; } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/Reset.cs b/src/Simulation/Simulators/QuantumSimulator/Reset.cs new file mode 100644 index 00000000000..16f0ff3e39c --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/Reset.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public void Reset__Body(Qubit target) + { + // The native simulator doesn't have a reset operation, so simulate + // it via an M follow by a conditional X. + this.CheckQubit(target); + var res = M(this.Id, (uint)target.Id); + if (res == 1) + { + X(this.Id, (uint)target.Id); + } + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/Rx.cs b/src/Simulation/Simulators/QuantumSimulator/Rx.cs new file mode 100644 index 00000000000..ec092af18d9 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/Rx.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void Rx__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliX, angle, (uint)target.Id); + } + + public virtual void Rx__AdjointBody(double angle, Qubit target) + { + Rx__Body(-angle, target); + } + + public virtual void Rx__ControlledBody(IQArray controls, double angle, Qubit target) + { + this.CheckQubits(controls, target); + CheckAngle(angle); + MCR(this.Id, Pauli.PauliX, angle, (uint)controls.Length, controls.GetIds(), (uint)target.Id); + } + + public virtual void Rx__ControlledAdjointBody(IQArray controls, double angle, Qubit target) + { + Rx__ControlledBody(controls, -angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/Ry.cs b/src/Simulation/Simulators/QuantumSimulator/Ry.cs new file mode 100644 index 00000000000..81962a986de --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/Ry.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void Ry__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliY, angle, (uint)target.Id); + } + + public virtual void Ry__AdjointBody(double angle, Qubit target) + { + Ry__Body(-angle, target); + } + + public virtual void Ry__ControlledBody(IQArray controls, double angle, Qubit target) + { + this.CheckQubits(controls, target); + CheckAngle(angle); + MCR(this.Id, Pauli.PauliY, angle, (uint)controls.Length, controls.GetIds(), (uint)target.Id); + } + + public virtual void Ry__ControlledAdjointBody(IQArray controls, double angle, Qubit target) + { + Ry__ControlledBody(controls, -angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/Rz.cs b/src/Simulation/Simulators/QuantumSimulator/Rz.cs new file mode 100644 index 00000000000..6784d7eb149 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/Rz.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + public partial class QuantumSimulator + { + public virtual void Rz__Body(double angle, Qubit target) + { + this.CheckQubit(target, nameof(target)); + CheckAngle(angle); + R(this.Id, Pauli.PauliZ, angle, (uint)target.Id); + } + + public virtual void Rz__AdjointBody(double angle, Qubit target) + { + Rz__Body(-angle, target); + } + + public virtual void Rz__ControlledBody(IQArray controls, double angle, Qubit target) + { + this.CheckQubits(controls, target); + CheckAngle(angle); + MCR(this.Id, Pauli.PauliZ, angle, (uint)controls.Length, controls.GetIds(), (uint)target.Id); + } + + public virtual void Rz__ControlledAdjointBody(IQArray controls, double angle, Qubit target) + { + Rz__ControlledBody(controls, -angle, target); + } + } +} diff --git a/src/Simulation/Simulators/QuantumSimulator/S.cs b/src/Simulation/Simulators/QuantumSimulator/S.cs index a77f5bc6b0e..c1e265bba3d 100644 --- a/src/Simulation/Simulators/QuantumSimulator/S.cs +++ b/src/Simulation/Simulators/QuantumSimulator/S.cs @@ -9,71 +9,36 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimS : Intrinsic.S + public virtual void S__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "S")] - private static extern void S(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "AdjS")] - private static extern void AdjS(uint id, uint qubit); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCS")] - private static extern void MCS(uint id, uint count, uint[] ctrls, uint qubit); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCAdjS")] - private static extern void MCAdjS(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimS(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); - - S(Simulator.Id, (uint)q1.Id); - - return QVoid.Instance; - }; - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; - - Simulator.CheckQubits(ctrls, q1); - - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCS(Simulator.Id, count, ids, (uint)q1.Id)); - - return QVoid.Instance; - }; - - public override Func __AdjointBody__ => (q1) => - { - Simulator.CheckQubit(q1); + S(this.Id, (uint)target.Id); + } - AdjS(Simulator.Id, (uint)q1.Id); + public virtual void S__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => S__Body(target), + (count, ids) => MCS(this.Id, count, ids, (uint)target.Id)); + } - public override Func<(IQArray, Qubit), QVoid> __ControlledAdjointBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; + public virtual void S__AdjointBody(Qubit target) + { + this.CheckQubit(target); - Simulator.CheckQubits(ctrls, q1); + AdjS(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.__AdjointBody__(q1), - (count, ids) => MCAdjS(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void S__ControlledAdjointBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => S__AdjointBody(target), + (count, ids) => MCAdjS(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/SWAP.cs b/src/Simulation/Simulators/QuantumSimulator/SWAP.cs new file mode 100644 index 00000000000..88f967a5bc3 --- /dev/null +++ b/src/Simulation/Simulators/QuantumSimulator/SWAP.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Simulation.Simulators +{ + + public partial class QuantumSimulator + { + public virtual void SWAP__Body(Qubit target1, Qubit target2) + { + var ctrls1 = new QArray(target1); + var ctrls2 = new QArray(target2); + this.CheckQubits(ctrls1, target2); + + MCX(this.Id, (uint)ctrls1.Length, ctrls1.GetIds(), (uint)target2.Id); + MCX(this.Id, (uint)ctrls2.Length, ctrls2.GetIds(), (uint)target1.Id); + MCX(this.Id, (uint)ctrls1.Length, ctrls1.GetIds(), (uint)target2.Id); + } + + public virtual void SWAP__ControlledBody(IQArray controls, Qubit target1, Qubit target2) + { + if ((controls == null) || (controls.Count == 0)) + { + SWAP__Body(target1, target2); + } + else + { + var ctrls_1 = QArray.Add(controls, new QArray(target1)); + var ctrls_2 = QArray.Add(controls, new QArray(target2)); + this.CheckQubits(ctrls_1, target2); + + MCX(this.Id, (uint)ctrls_1.Length, ctrls_1.GetIds(), (uint)target2.Id); + MCX(this.Id, (uint)ctrls_2.Length, ctrls_2.GetIds(), (uint)target1.Id); + MCX(this.Id, (uint)ctrls_1.Length, ctrls_1.GetIds(), (uint)target2.Id); + } + } + } +} diff --git a/src/Simulation/Common/SimulatorBase.cs b/src/Simulation/Simulators/QuantumSimulator/SimulatorBase.cs similarity index 98% rename from src/Simulation/Common/SimulatorBase.cs rename to src/Simulation/Simulators/QuantumSimulator/SimulatorBase.cs index 4b7d4e25945..0d5d5b53824 100644 --- a/src/Simulation/Common/SimulatorBase.cs +++ b/src/Simulation/Simulators/QuantumSimulator/SimulatorBase.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.Quantum.Simulation.Core; @@ -14,20 +13,6 @@ namespace Microsoft.Quantum.Simulation.Common { - /// - /// A class that implements exception to be thrown when Operation is not supported. - /// - public class UnsupportedOperationException : PlatformNotSupportedException - { - public UnsupportedOperationException(string text = "", - [CallerFilePath] string file = "", - [CallerMemberName] string member = "", - [CallerLineNumber] int line = 0) - : base($"{file}::{line}::[{member}]:{text}") - { - } - } - /// /// A Base class for Simulators. /// It provides the infrastructure that makes it easy for a Simulator diff --git a/src/Simulation/Common/StackTrace.cs b/src/Simulation/Simulators/QuantumSimulator/StackTrace.cs similarity index 100% rename from src/Simulation/Common/StackTrace.cs rename to src/Simulation/Simulators/QuantumSimulator/StackTrace.cs diff --git a/src/Simulation/Simulators/QuantumSimulator/StateDumper.cs b/src/Simulation/Simulators/QuantumSimulator/StateDumper.cs index f074b6ed8ea..9198616d9cd 100644 --- a/src/Simulation/Simulators/QuantumSimulator/StateDumper.cs +++ b/src/Simulation/Simulators/QuantumSimulator/StateDumper.cs @@ -9,14 +9,6 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - private delegate bool DumpCallback(uint idx, double real, double img); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Dump")] - private static extern void sim_Dump(uint id, DumpCallback callback); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DumpQubits")] - private static extern bool sim_DumpQubits(uint id, uint cout, uint[] ids, DumpCallback callback); - /// /// This class allows you to dump the state (wave function) /// of the QuantumSimulator into a callback function. diff --git a/src/Simulation/Simulators/QuantumSimulator/T.cs b/src/Simulation/Simulators/QuantumSimulator/T.cs index 201c8112b51..c95dde4528d 100644 --- a/src/Simulation/Simulators/QuantumSimulator/T.cs +++ b/src/Simulation/Simulators/QuantumSimulator/T.cs @@ -9,69 +9,36 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimT : Intrinsic.T + public virtual void T__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "T")] - private static extern void T(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "AdjT")] - private static extern void AdjT(uint id, uint qubit); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCT")] - private static extern void MCT(uint id, uint count, uint[] ctrls, uint qubit); - - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCAdjT")] - private static extern void MCAdjT(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimT(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); - - T(Simulator.Id, (uint)q1.Id); - return QVoid.Instance; - }; - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; - - Simulator.CheckQubits(ctrls, q1); - - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCT(Simulator.Id, count, ids, (uint)q1.Id)); + T(this.Id, (uint)target.Id); + } - return QVoid.Instance; - }; + public virtual void T__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - public override Func __AdjointBody__ => (q1) => - { - Simulator.CheckQubit(q1); - - AdjT(this.Simulator.Id, (uint)q1.Id); - return QVoid.Instance; - }; + SafeControlled(controls, + () => T__Body(target), + (count, ids) => MCT(this.Id, count, ids, (uint)target.Id)); + } - public override Func<(IQArray, Qubit), QVoid> __ControlledAdjointBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; + public virtual void T__AdjointBody(Qubit target) + { + this.CheckQubit(target); - Simulator.CheckQubits(ctrls, q1); + AdjT(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.__AdjointBody__(q1), - (count, ids) => MCAdjT(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void T__ControlledAdjointBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => T__AdjointBody(target), + (count, ids) => MCAdjT(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/X.cs b/src/Simulation/Simulators/QuantumSimulator/X.cs index 9b23f4c6372..c01f5b65535 100644 --- a/src/Simulation/Simulators/QuantumSimulator/X.cs +++ b/src/Simulation/Simulators/QuantumSimulator/X.cs @@ -9,43 +9,20 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimX : Intrinsic.X + public virtual void X__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "X")] - private static extern void X(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCX")] - private static extern void MCX(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimX(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); - - X(Simulator.Id, (uint)q1.Id); - - return QVoid.Instance; - }; - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (args) => - { - var (ctrls, q1) = args; - - Simulator.CheckQubits(ctrls, q1); + X(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCX(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void X__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => X__Body(target), + (count, ids) => MCX(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/Y.cs b/src/Simulation/Simulators/QuantumSimulator/Y.cs index 1144f966db8..42fda7e38e7 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Y.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Y.cs @@ -9,43 +9,20 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimY : Intrinsic.Y + public virtual void Y__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Y")] - private static extern void Y(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCY")] - private static extern void MCY(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimY(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); - - Y(Simulator.Id, (uint)q1.Id); - - return QVoid.Instance; - }; - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; - - Simulator.CheckQubits(ctrls, q1); + Y(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCY(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void Y__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => Y__Body(target), + (count, ids) => MCY(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/QuantumSimulator/Z.cs b/src/Simulation/Simulators/QuantumSimulator/Z.cs index e046c233a5c..ef8a174c2a6 100644 --- a/src/Simulation/Simulators/QuantumSimulator/Z.cs +++ b/src/Simulation/Simulators/QuantumSimulator/Z.cs @@ -9,43 +9,20 @@ namespace Microsoft.Quantum.Simulation.Simulators { public partial class QuantumSimulator { - public class QSimZ : Intrinsic.Z + public virtual void Z__Body(Qubit target) { - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Z")] - private static extern void Z(uint id, uint qubit); + this.CheckQubit(target); - [DllImport(QSIM_DLL_NAME, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MCZ")] - private static extern void MCZ(uint id, uint count, uint[] ctrls, uint qubit); - - private QuantumSimulator Simulator { get; } - - - public QSimZ(QuantumSimulator m) : base(m) - { - this.Simulator = m; - } - - public override Func __Body__ => (q1) => - { - Simulator.CheckQubit(q1); ; - - Z(Simulator.Id, (uint)q1.Id); - - return QVoid.Instance; - }; - - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (_args) => - { - (IQArray ctrls, Qubit q1) = _args; - - Simulator.CheckQubits(ctrls, q1); + Z(this.Id, (uint)target.Id); + } - SafeControlled(ctrls, - () => this.Apply(q1), - (count, ids) => MCZ(Simulator.Id, count, ids, (uint)q1.Id)); + public virtual void Z__ControlledBody(IQArray controls, Qubit target) + { + this.CheckQubits(controls, target); - return QVoid.Instance; - }; + SafeControlled(controls, + () => Z__Body(target), + (count, ids) => MCZ(this.Id, count, ids, (uint)target.Id)); } } } diff --git a/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs b/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs index 84fc8ca8f2d..a821fd37663 100644 --- a/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs +++ b/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs @@ -5,6 +5,7 @@ using System.Data; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Text; using Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime; using Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators; @@ -43,6 +44,14 @@ public static QCTraceSimulatorConfiguration RecommendedConfig() => UseWidthCounter = true }; + /// + /// Constructor used by entry point driver to provide the assembly for core types that + /// need to be overriden. + /// + public ResourcesEstimator(Assembly coreAssembly) : base(RecommendedConfig(), coreAssembly) + { + } + /// /// Parameter-less constructor. It initializes the ResourceEstimator /// with a QCTraceSimulatorConfiguration as returned by . @@ -75,9 +84,9 @@ public ResourcesEstimator(QCTraceSimulatorConfiguration config) : base(config) { return null; } - else if (name == MetricsNames.WidthCounter.ExtraWidth) - { - return "QubitCount"; + else if (name == MetricsNames.WidthCounter.ExtraWidth) + { + return "QubitCount"; } else { @@ -123,7 +132,7 @@ public virtual DataTable Data var results = collector.Results.ToTable(); Debug.Assert(results.keyColumnNames.Length > 2 && results.keyColumnNames[2] == "Caller"); - var roots = results.rows.Where(r => r.KeyRow[2] == CallGraphEdge.CallGraphRootHashed); + var roots = results.rows.Where(r => r.KeyRow[2] == CallGraphEdge.CallGraphRootHashed); var s_idx = Array.FindIndex(results.statisticsNames, n => n == "Sum"); for (var m_idx = 0; m_idx < results.metricNames.Length; m_idx++) @@ -135,14 +144,14 @@ public virtual DataTable Data row["Metric"] = label; if (m_idx >= 0 && s_idx >= 0) - { - Double sum = 0; - Double max = 0; // all our metrics are positive + { + Double sum = 0; + Double max = 0; // all our metrics are positive foreach (var r in roots) - { - Double metric_value = r.DataRow[m_idx, s_idx]; - sum += metric_value; - max = System.Math.Max(max, metric_value); + { + Double metric_value = r.DataRow[m_idx, s_idx]; + sum += metric_value; + max = System.Math.Max(max, metric_value); } row["Sum"] = sum; row["Max"] = max; diff --git a/src/Simulation/Simulators/ToffoliSimulator/Exp.cs b/src/Simulation/Simulators/ToffoliSimulator/Exp.cs index 4b6cdd4dd6e..5bd117c287e 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/Exp.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/Exp.cs @@ -9,94 +9,69 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the Exp operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation flips a target qubit + /// if the respective rotation is effectively an X gate. /// - public class Exp : Intrinsic.Exp + public void Exp__Body(IQArray paulis, double angle, IQArray targets) { - private ToffoliSimulator simulator { get; } + if (targets == null) return; - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public Exp(ToffoliSimulator m) : base(m) + this.CheckQubits(targets, "targets"); + + if (targets.Length != paulis.Length) { - simulator = m; + throw new InvalidOperationException($"Both input arrays for Exp (paulis,targets), must be of same size"); } - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation flips a target qubit - /// if the respective rotation is effectively an X gate. - /// - public override Func<(IQArray, double, IQArray), QVoid> __Body__ => (_args) => + for (var i = 0; i < targets.Length; i++) { - var (bases, angle, qubits) = _args; - - if (qubits == null) return QVoid.Instance; - - simulator.CheckQubits(qubits, "qubits"); - - if (qubits.Length != bases.Length) + var (isX, safe) = CheckRotation(paulis[i], angle); + if (isX) { - throw new InvalidOperationException($"Both input arrays for {GetType().Name} (paulis,qubits), must be of same size"); + this.State[targets[i].Id] = !this.State[targets[i].Id]; } + } + } - for (var i = 0; i < qubits.Length; i++) - { - var (isX, safe) = CheckRotation(bases[i], angle); - if (isX) - { - simulator.State[qubits[i].Id] = !simulator.State[qubits[i].Id]; - } - } + /// + /// The implementation of the adjoint specialization of the operation. + /// For the Toffoli simulator *only*, this operation is self-adjoint. + /// + public void Exp__AdjointBody(IQArray paulis, double angle, IQArray targets) => Exp__Body(paulis, angle, targets); - return QVoid.Instance; - }; + /// + /// The implementation of the controlled specialization of the operation. + /// For the Toffoli simulator, the implementation flips the target qubit + /// if the rotation is effectively an X gate and all of the control qubits + /// are in the One state. + /// + public void Exp__ControlledBody(IQArray controls, IQArray paulis, double angle, IQArray targets) + { + if (targets == null) return; - /// - /// The implementation of the adjoint specialization of the operation. - /// For the Toffoli simulator *only*, this operation is self-adjoint. - /// - public override Func<(IQArray, double, IQArray), QVoid> __AdjointBody__ => __Body__; + this.CheckControlQubits(controls, targets); - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate and all of the control qubits - /// are in the One state. - /// - public override Func<(IQArray, (IQArray, double, IQArray)), QVoid> __ControlledBody__ => (_args) => + if (targets.Length != paulis.Length) { - var (ctrls, (bases, angle, qubits)) = _args; - - if (qubits == null) return QVoid.Instance; - - simulator.CheckControlQubits(ctrls, qubits); - - if (qubits.Length != bases.Length) - { - throw new InvalidOperationException($"Both input arrays for {GetType().Name} (paulis,qubits), must be of same size"); - } + throw new InvalidOperationException($"Both input arrays for Exp (paulis,qubits), must be of same size"); + } - for (var i = 0; i < qubits.Length; i++) + for (var i = 0; i < targets.Length; i++) + { + var (id, safe) = CheckRotation(paulis[i], angle); + if (!safe) { - var (id, safe) = CheckRotation(bases[i], angle); - if (!safe) - { - throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); - } - // We never need to do anything since only the identity is safe to control + throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); } - - return QVoid.Instance; - }; - - /// - /// The implementation of the controlled adjoint specialization of the operation. - /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. - /// - public override Func<(IQArray, (IQArray, double, IQArray)), QVoid> __ControlledAdjointBody__ => __ControlledBody__; + // We never need to do anything since only the identity is safe to control + } } + + /// + /// The implementation of the controlled adjoint specialization of the operation. + /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. + /// + public void Exp__ControlledAdjointBody(IQArray controls, IQArray paulis, double angle, IQArray targets) => Exp__ControlledBody(controls, paulis, angle, targets); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/ExpFrac.cs b/src/Simulation/Simulators/ToffoliSimulator/ExpFrac.cs deleted file mode 100644 index 0d14f2fb29e..00000000000 --- a/src/Simulation/Simulators/ToffoliSimulator/ExpFrac.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Runtime.InteropServices; -using Microsoft.Quantum.Simulation.Core; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - public partial class ToffoliSimulator - { - /// - /// Implementation of the ExpFrac operation for the Toffoli simulator. - /// - public class ExpFrac : Intrinsic.ExpFrac - { - private ToffoliSimulator simulator { get; } - - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public ExpFrac(ToffoliSimulator m) : base(m) - { - simulator = m; - } - - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation flips a target qubit - /// if the respective rotation is effectively an X gate. - /// - public override Func<(IQArray, long, long, IQArray), QVoid> __Body__ => (_args) => - { - var (bases, num, den, qubits) = _args; - - if (qubits == null) return QVoid.Instance; - - simulator.CheckQubits(qubits, "qubits"); - - if (qubits.Length != bases.Length) - { - throw new InvalidOperationException($"Both input arrays for {GetType().Name} (paulis,qubits), must be of same size"); - } - - for (var i = 0; i < qubits.Length; i++) - { - var (isX, safe) = CheckRotation(bases[i], num, den); - if (isX) - { - simulator.DoX(qubits[i]); - } - } - - return QVoid.Instance; - }; - - /// - /// The implementation of the adjoint specialization of the operation. - /// For the Toffoli simulator *only*, this operation is self-adjoint. - /// - public override Func<(IQArray, long, long, IQArray), QVoid> __AdjointBody__ => __Body__; - - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate and all of the control qubits - /// are in the One state. - /// - public override Func<(IQArray, (IQArray, long, long, IQArray)), QVoid> __ControlledBody__ => (_args) => - { - var (ctrls, (bases, num, den, qubits)) = _args; - - if (qubits == null) return QVoid.Instance; - - simulator.CheckControlQubits(ctrls, qubits); - - if (qubits.Length != bases.Length) - { - throw new InvalidOperationException($"Both input arrays for {GetType().Name} (paulis,qubits), must be of same size"); - } - - for (var i = 0; i < qubits.Length; i++) - { - var (isX, safe) = CheckRotation(bases[i], num, den); - if (!safe) - { - throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); - } - // We never need to do anything since only the identity is safe to control - } - - return QVoid.Instance; - }; - - /// - /// The implementation of the controlled adjoint specialization of the operation. - /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. - /// - public override Func<(IQArray, (IQArray, long, long, IQArray)), QVoid> __ControlledAdjointBody__ => __ControlledBody__; - } - } -} diff --git a/src/Simulation/Simulators/ToffoliSimulator/H.cs b/src/Simulation/Simulators/ToffoliSimulator/H.cs index d4f03a40d73..9b9b3c45be3 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/H.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/H.cs @@ -9,26 +9,11 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the H operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation throws a run-time error. /// - public class H : Quantum.Intrinsic.H - { - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public H(ToffoliSimulator m) : base(m) - { - } + public void H__Body(Qubit target) => throw new NotImplementedException(); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation throws a run-time error. - /// - public override Func __Body__ => (q1) => - { - throw new NotImplementedException(); - }; - } + public void H__ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException(); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/M.cs b/src/Simulation/Simulators/ToffoliSimulator/M.cs deleted file mode 100644 index d17c7dc8ec5..00000000000 --- a/src/Simulation/Simulators/ToffoliSimulator/M.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Microsoft.Quantum.Simulation.Core; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - public partial class ToffoliSimulator - { - /// - /// Implementation of the M operation for the Toffoli simulator. - /// - public class M : Quantum.Intrinsic.M - { - private ToffoliSimulator simulator; - - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public M(ToffoliSimulator m) : base(m) - { - this.simulator = m; - } - - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation returns the state of the measured qubit. - /// That is, Result.One is returned if the measured qubit is in the One state. - /// - public override Func __Body__ => (q1) => - { - if (q1 == null) return Result.Zero; - - this.simulator.CheckQubit(q1, "q1"); - - return (this.simulator.State[q1.Id]).ToResult(); - }; - } - } -} diff --git a/src/Simulation/Simulators/ToffoliSimulator/Measure.cs b/src/Simulation/Simulators/ToffoliSimulator/Measure.cs index 112e622f7b9..5ed771006ff 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/Measure.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/Measure.cs @@ -10,50 +10,31 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the Measure operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation returns the joint parity of the + /// states of the measured qubits. + /// That is, Result.One is returned if an odd number of the measured qubits are + /// in the One state. /// - public class Measure : Intrinsic.Measure + public Result Measure__Body(IQArray paulis, IQArray targets) { - private ToffoliSimulator simulator { get; } - - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public Measure(ToffoliSimulator m) : base(m) + Qubit? f(Pauli p, Qubit q) => + p switch { + Pauli.PauliI => null, + Pauli.PauliZ => q, + _ => throw new InvalidOperationException($"The Toffoli simulator can only Measure in the Z basis.") + }; + + if (paulis.Length != targets.Length) { - this.simulator = m; + throw new InvalidOperationException($"Both input arrays for Measure (paulis, targets), must be of same size"); } - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation returns the joint parity of the - /// states of the measured qubits. - /// That is, Result.One is returned if an odd number of the measured qubits are - /// in the One state. - /// - public override Func<(IQArray, IQArray), Result> __Body__ => (_args) => - { - Qubit? f(Pauli p, Qubit q) => - p switch { - Pauli.PauliI => null, - Pauli.PauliZ => q, - _ => throw new InvalidOperationException($"The Toffoli simulator can only Measure in the Z basis.") - }; - - var (paulis, qubits) = _args; - - if (paulis.Length != qubits.Length) - { - throw new InvalidOperationException($"Both input arrays for {this.GetType().Name} (paulis,qubits), must be of same size"); - } - - var qubitsToMeasure = paulis.Zip(qubits, f).WhereNotNull(); + var qubitsToMeasure = paulis.Zip(targets, f).WhereNotNull(); - var result = simulator.GetParity(qubitsToMeasure); + var result = this.GetParity(qubitsToMeasure); - return result.ToResult(); - }; + return result.ToResult(); } } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/R.cs b/src/Simulation/Simulators/ToffoliSimulator/R.cs index 087eaab6044..7c1fdd33d4e 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/R.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/R.cs @@ -9,78 +9,53 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the R operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation flips the target qubit + /// if the rotation is effectively an X gate. /// - public class R : Intrinsic.R + public void R__Body(Pauli pauli, double angle, Qubit target) { - private ToffoliSimulator simulator { get; } + if (target == null) return; - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public R(ToffoliSimulator m) : base(m) - { - simulator = m; - } + this.CheckQubit(target, "target"); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate. - /// - public override Func<(Pauli, double, Qubit), QVoid> __Body__ => (_args) => + var (isX, safe) = CheckRotation(pauli, angle / 2.0); + if (isX) { - var (basis, angle, q1) = _args; - - if (q1 == null) return QVoid.Instance; - - simulator.CheckQubit(q1, "q1"); + this.DoX(target); + } + } - var (isX, safe) = CheckRotation(basis, angle / 2.0); - if (isX) - { - simulator.DoX(q1); - } + /// + /// The implementation of the adjoint specialization of the operation. + /// For the Toffoli simulator *only*, this operation is self-adjoint. + /// + public void R__AdjointBody(Pauli pauli, double angle, Qubit target) => R__Body(pauli, angle, target); - return QVoid.Instance; - }; + /// + /// The implementation of the controlled specialization of the operation. + /// For the Toffoli simulator, the implementation flips the target qubit + /// if the rotation is effectively an X gate and all of the control qubits + /// are in the One state. + /// + public void R__ControlledBody(IQArray controls, Pauli pauli, double angle, Qubit target) + { + if (target == null) return; - /// - /// The implementation of the adjoint specialization of the operation. - /// For the Toffoli simulator *only*, this operation is self-adjoint. - /// - public override Func<(Pauli, double, Qubit), QVoid> __AdjointBody__ => __Body__; + this.CheckControlQubits(controls, target); - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate and all of the control qubits - /// are in the One state. - /// - public override Func<(IQArray, (Pauli, double, Qubit)), QVoid> __ControlledBody__ => (_args) => + var (isX, safe) = CheckRotation(pauli, angle / 2.0); + if (!safe) { - var (ctrls, (basis, angle, q1)) = _args; - - if (q1 == null) return QVoid.Instance; - - simulator.CheckControlQubits(ctrls, q1); - - var (isX, safe) = CheckRotation(basis, angle / 2.0); - if (!safe) - { - throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); - } - // We never need to do anything since only the identity is safe to control - - return QVoid.Instance; - }; - - /// - /// The implementation of the controlled adjoint specialization of the operation. - /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. - /// - public override Func<(IQArray, (Pauli, double, Qubit)), QVoid> __ControlledAdjointBody__ => __ControlledBody__; + throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); + } + // We never need to do anything since only the identity is safe to control } + + /// + /// The implementation of the controlled adjoint specialization of the operation. + /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. + /// + public void R__ControlledAdjointBody(IQArray controls, Pauli pauli, double angle, Qubit target) => R__ControlledBody(controls, pauli, angle, target); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/RFrac.cs b/src/Simulation/Simulators/ToffoliSimulator/RFrac.cs deleted file mode 100644 index 3cafddc2156..00000000000 --- a/src/Simulation/Simulators/ToffoliSimulator/RFrac.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Microsoft.Quantum.Simulation.Core; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - public partial class ToffoliSimulator - { - /// - /// Implementation of the RFrac operation for the Toffoli simulator. - /// - public class RFrac : Intrinsic.RFrac - { - private ToffoliSimulator simulator { get; } - - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public RFrac(ToffoliSimulator m) : base(m) - { - simulator = m; - } - - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate. - /// - public override Func<(Pauli, long, long, Qubit), QVoid> __Body__ => (_args) => - { - var (basis, num, den, q1) = _args; - - if (q1 == null) return QVoid.Instance; - - simulator.CheckQubit(q1, "q1"); - - var (isX, safe) = CheckRotation(basis, num, den); - if (isX) - { - simulator.DoX(q1); - } - - return QVoid.Instance; - }; - - /// - /// The implementation of the adjoint specialization of the operation. - /// For the Toffoli simulator *only*, this operation is self-adjoint. - /// - public override Func<(Pauli, long, long, Qubit), QVoid> __AdjointBody__ => __Body__; - - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if the rotation is effectively an X gate and all of the control qubits - /// are in the One state. - /// - public override Func<(IQArray, (Pauli, long, long, Qubit)), QVoid> __ControlledBody__ => (_args) => - { - var (ctrls, (basis, num, den, q1)) = _args; - - if (q1 == null) return QVoid.Instance; - - simulator.CheckQubit(q1, "q1"); - - var (isX, safe) = CheckRotation(basis, num, den); - if (!safe) - { - throw new InvalidOperationException($"The Toffoli simulator can only perform controlled rotations of multiples of 2*pi."); - } - // We never need to do anything since only the identity is safe to control - - return QVoid.Instance; - }; - - /// - /// The implementation of the controlled adjoint specialization of the operation. - /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint. - /// - public override Func<(IQArray, (Pauli, long, long, Qubit)), QVoid> __ControlledAdjointBody__ => __ControlledBody__; - } - } -} diff --git a/src/Simulation/Simulators/ToffoliSimulator/S.cs b/src/Simulation/Simulators/ToffoliSimulator/S.cs index 558fed2979c..77c6b2544bb 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/S.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/S.cs @@ -9,26 +9,15 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the S operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation throws a run-time error. /// - public class S : Quantum.Intrinsic.S - { - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public S(ToffoliSimulator m) : base(m) - { - } + public void S__Body(Qubit target) => throw new NotImplementedException(); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation throws a run-time error. - /// - public override Func __Body__ => (q1) => - { - throw new NotImplementedException(); - }; - } + public void S__ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException(); + + public void S__AdjointBody(Qubit target) => throw new NotImplementedException(); + + public void S__ControlledAdjointBody(IQArray controls, Qubit target) => throw new NotImplementedException(); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/SWAP.cs b/src/Simulation/Simulators/ToffoliSimulator/SWAP.cs deleted file mode 100644 index 863dbba83c1..00000000000 --- a/src/Simulation/Simulators/ToffoliSimulator/SWAP.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Microsoft.Quantum.Simulation.Core; -using Microsoft.Quantum.Simulation.Simulators.Exceptions; - -namespace Microsoft.Quantum.Simulation.Simulators -{ - public partial class ToffoliSimulator - { - /// - /// Implementation of the SWAP operation for the Toffoli simulator. - /// - public class SWAP : Intrinsic.SWAP - { - private ToffoliSimulator simulator; - - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public SWAP(ToffoliSimulator m) : base(m) - { - simulator = m; - } - - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation swaps the states of the two qubits. - /// - public override Func<(Qubit, Qubit), QVoid> __Body__ => (args) => - { - var (q1, q2) = args; - - if ((q1 == null) || (q2 == null)) return QVoid.Instance; - - simulator.CheckQubit(q1, "q1"); - simulator.CheckQubit(q2, "q2"); - - if (q1.Id == q2.Id) - { - throw new NotDistinctQubits(q2); - } - - simulator.DoSwap(q1, q2); - - return QVoid.Instance; - }; - - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation swaps the states of the - /// target qubits if all of the control qubits are 1. - /// - public override Func<(IQArray, (Qubit, Qubit)), QVoid> __ControlledBody__ => (args) => - { - var (ctrls, (q1, q2)) = args; - - if ((q1 == null) || (q2 == null)) return QVoid.Instance; - - var targets = new QArray(q1, q2); - simulator.CheckControlQubits(ctrls, targets); - - if (simulator.VerifyControlCondition(ctrls)) - { - simulator.DoSwap(q1, q2); - } - - return QVoid.Instance; - }; - } - } -} diff --git a/src/Simulation/Simulators/ToffoliSimulator/T.cs b/src/Simulation/Simulators/ToffoliSimulator/T.cs index 4445d5fcc17..208009be8b4 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/T.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/T.cs @@ -9,26 +9,15 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the T operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation throws a run-time error. /// - public class T : Quantum.Intrinsic.T - { - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public T(ToffoliSimulator m) : base(m) - { - } + public void T__Body(Qubit target) => throw new NotImplementedException(); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation throws a run-time error. - /// - public override Func __Body__ => (q1) => - { - throw new NotImplementedException(); - }; - } + public void T__ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException(); + + public void T__AdjointBody(Qubit target) => throw new NotImplementedException(); + + public void T__ControlledAdjointBody(IQArray controls, Qubit target) => throw new NotImplementedException(); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/ToffoliSimulator.cs b/src/Simulation/Simulators/ToffoliSimulator/ToffoliSimulator.cs index 3b2fb99be5d..3f5c95fb88b 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/ToffoliSimulator.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/ToffoliSimulator.cs @@ -9,6 +9,7 @@ using Microsoft.Quantum.Simulation.Common; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators.Exceptions; +using Microsoft.Quantum.Intrinsic.Interfaces; using static System.Math; namespace Microsoft.Quantum.Simulation.Simulators @@ -23,7 +24,7 @@ public enum ToffoliDumpFormat /// /// The Toffoli simulator implementation class. /// - public partial class ToffoliSimulator : SimulatorBase + public partial class ToffoliSimulator : SimulatorBase, IQSharpCore { /// /// The default number of qubits to allocate. @@ -46,7 +47,7 @@ public ToffoliSimulator() : this(DEFAULT_QUBIT_COUNT) { } /// There is an overhead of one byte of memory usage per allocated qubit. /// There is no time overhead from allocating more qubits. public ToffoliSimulator(uint qubitCount) - : base(new QubitManager(qubitCapacity: qubitCount, mayExtendCapacity: false, disableBorrowing: false)) + : base(new QubitManager(qubitCapacity: qubitCount, mayExtendCapacity: false, disableBorrowing: false), null) { this.State = new bool[qubitCount]; this.borrowedQubitStates = new Dictionary>(); diff --git a/src/Simulation/Simulators/ToffoliSimulator/X.cs b/src/Simulation/Simulators/ToffoliSimulator/X.cs index e72494d21b0..cf42191160e 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/X.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/X.cs @@ -9,55 +9,33 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the X operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation flips the target qubit. /// - public class X : Intrinsic.X + public void X__Body(Qubit target) { - private ToffoliSimulator simulator; + if (target == null) return; - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public X(ToffoliSimulator m) : base(m) - { - simulator = m; - } - - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit. - /// - public override Func __Body__ => (q1) => - { - if (q1 == null) return QVoid.Instance; + this.CheckQubit(target, "target"); - simulator.CheckQubit(q1, "q1"); + this.DoX(target); + } - simulator.DoX(q1); + /// + /// The implementation of the controlled specialization of the operation. + /// For the Toffoli simulator, the implementation flips the target qubit + /// if all of the control qubits are 1. + /// + public void X__ControlledBody(IQArray controls, Qubit target) + { + if (target == null) return; - return QVoid.Instance; - }; + this.CheckControlQubits(controls, target); - /// - /// The implementation of the controlled specialization of the operation. - /// For the Toffoli simulator, the implementation flips the target qubit - /// if all of the control qubits are 1. - /// - public override Func<(IQArray, Qubit), QVoid> __ControlledBody__ => (args) => + if (this.VerifyControlCondition(controls)) { - var (ctrls, q) = args; - if (q == null) return QVoid.Instance; - - simulator.CheckControlQubits(ctrls, q); - - if (simulator.VerifyControlCondition(ctrls)) - { - simulator.DoX(q); - } - - return QVoid.Instance; - }; + this.DoX(target); + } } } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/Y.cs b/src/Simulation/Simulators/ToffoliSimulator/Y.cs index 61f18ec3090..aee499ba6de 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/Y.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/Y.cs @@ -9,26 +9,11 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the Y operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation throws a run-time error. /// - public class Y : Quantum.Intrinsic.Y - { - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public Y(ToffoliSimulator m) : base(m) - { - } + public void Y__Body(Qubit target) => throw new NotImplementedException(); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation throws a run-time error. - /// - public override Func __Body__ => (q1) => - { - throw new NotImplementedException(); - }; - } + public void Y__ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException(); } } diff --git a/src/Simulation/Simulators/ToffoliSimulator/Z.cs b/src/Simulation/Simulators/ToffoliSimulator/Z.cs index b0101beff19..7044156fe0a 100644 --- a/src/Simulation/Simulators/ToffoliSimulator/Z.cs +++ b/src/Simulation/Simulators/ToffoliSimulator/Z.cs @@ -9,26 +9,11 @@ namespace Microsoft.Quantum.Simulation.Simulators public partial class ToffoliSimulator { /// - /// Implementation of the Z operation for the Toffoli simulator. + /// The implementation of the operation. + /// For the Toffoli simulator, the implementation throws a run-time error. /// - public class Z : Quantum.Intrinsic.Z - { - /// - /// Constructs a new operation instance. - /// - /// The simulator that this operation affects. - public Z(ToffoliSimulator m) : base(m) - { - } + public void Z__Body(Qubit target) => throw new NotImplementedException(); - /// - /// The implementation of the operation. - /// For the Toffoli simulator, the implementation throws a run-time error. - /// - public override Func __Body__ => (q1) => - { - throw new NotImplementedException(); - }; - } + public void Z__ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException(); } } diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledX.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledX.qs new file mode 100644 index 00000000000..4bf60fd83dd --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledX.qs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the controlled-X (or CNOT) gate to a pair of qubits. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// \operatorname{CNOT} \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 0 & 1 \\\\ + /// 0 & 0 & 1 & 0 + /// \end{bmatrix}, + /// \end{align} + /// + /// where rows and columns are ordered as in the quantum concepts guide. + /// + /// # Input + /// ## control + /// Control qubit for the CNOT gate. + /// ## target + /// Target qubit for the CNOT gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// CNOT(control, target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyControlledX") + internal operation ApplyControlledX (control : Qubit, target : Qubit) : Unit is Adj { + CNOT(control, target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledZ.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledZ.qs new file mode 100644 index 00000000000..70cb2a6d068 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyControlledZ.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the controlled-Z (CZ) gate to a pair of qubits. Note that the Controlled + /// functor is not supported. + /// + /// $$ + /// \begin{align} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 1 & 0 \\\\ + /// 0 & 0 & 0 & -1 + /// \end{align}, + /// $$ + /// where rows and columns are organized as in the quantum concepts guide. + /// + /// # Input + /// ## control + /// Control qubit for the CZ gate. + /// ## target + /// Target qubit for the CZ gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Controlled Z([control], target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyControlledZ") + internal operation ApplyControlledZ (control : Qubit, target : Qubit) : Unit is Adj { + Controlled Z([control], target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledH.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledH.qs new file mode 100644 index 00000000000..74a4e5f61fa --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledH.qs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Hadamard transformation to a single qubit. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// H \mathrel{:=} + /// \frac{1}{\sqrt{2}} + /// \begin{bmatrix} + /// 1 & 1 \\\\ + /// 1 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledH") + internal operation ApplyUncontrolledH (qubit : Qubit) : Unit is Adj { + H(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRx.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRx.qs new file mode 100644 index 00000000000..8db8b3733a1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRx.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $x$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_x(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_x / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ + /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliX, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRx") + internal operation ApplyUncontrolledRx (theta : Double, qubit : Qubit) : Unit is Adj { + Rx(theta, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRy.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRy.qs new file mode 100644 index 00000000000..bd72cde1e7e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRy.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $y$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_y(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_y / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ + /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliY, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRy") + internal operation ApplyUncontrolledRy (theta : Double, qubit : Qubit) : Unit is Adj { + Ry(theta, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRz.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRz.qs new file mode 100644 index 00000000000..5c864aae74f --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledRz.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $z$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_z(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_z / 2} = + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 \\\\ + /// 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRz") + internal operation ApplyUncontrolledRz (theta : Double, qubit : Qubit) : Unit is Adj { + Rz(theta, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledS.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledS.qs new file mode 100644 index 00000000000..1b64c5e7839 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledS.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/4 phase gate to a single qubit. Note that the Controlled functor + /// is not supported. + /// + /// # Description + /// \begin{align} + /// S \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & i + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledS") + internal operation ApplyUncontrolledS (qubit : Qubit) : Unit is Adj { + S(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledT.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledT.qs new file mode 100644 index 00000000000..60cf1ecd7b8 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledT.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/8 gate to a single qubit. Note that the Controlled functor is + /// not supported. + /// + /// # Description + /// \begin{align} + /// T \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & e^{i \pi / 4} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledT") + internal operation ApplyUncontrolledT (qubit : Qubit) : Unit is Adj { + T(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledX.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledX.qs new file mode 100644 index 00000000000..08a566bc840 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledX.qs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $X$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_x \mathrel{:=} + /// \begin{bmatrix} + /// 0 & 1 \\\\ + /// 1 & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledX") + internal operation ApplyUncontrolledX (qubit : Qubit) : Unit is Adj { + X(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledY.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledY.qs new file mode 100644 index 00000000000..bee6d1fb7b3 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledY.qs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Y$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_y \mathrel{:=} + /// \begin{bmatrix} + /// 0 & -i \\\\ + /// i & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledY") + internal operation ApplyUncontrolledY (qubit : Qubit) : Unit is Adj { + Y(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledZ.qs b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledZ.qs new file mode 100644 index 00000000000..ffb10e7e364 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledZ.qs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Z$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_z \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledZ") + internal operation ApplyUncontrolledZ (qubit : Qubit) : Unit is Adj { + Z(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualInPlace.qs b/src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualInPlace.qs similarity index 86% rename from src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualInPlace.qs rename to src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualInPlace.qs index 33bfdd67896..427e3c50451 100644 --- a/src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualInPlace.qs +++ b/src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualInPlace.qs @@ -9,7 +9,7 @@ namespace Microsoft.Quantum.Diagnostics { /// Iterates a variable through a Cartesian product /// [ 0, bounds[0]-1 ] × [ 0, bounds[1]-1 ] × [ 0, bounds[Length(bounds)-1]-1 ] /// and calls op(arr) for every element of the Cartesian product - operation _iterateThroughCartesianPower (length : Int, value : Int, op : (Int[] => Unit)) : Unit { + internal operation IterateThroughCartesianPower (length : Int, value : Int, op : (Int[] => Unit)) : Unit { mutable bounds = new Int[length]; for (i in 0 .. length - 1) @@ -67,12 +67,10 @@ namespace Microsoft.Quantum.Diagnostics { /// ## basis /// Array of single-qubit basis state IDs (0 <= id <= 3), one for each element of /// qubits. - operation _flipToBasis (basis : Int[], qubits : Qubit[]) : Unit - is Adj + Ctl { - + internal operation FlipToBasis (basis : Int[], qubits : Qubit[]) : Unit is Adj + Ctl { if (Length(qubits) != Length(basis)) { - fail $"qubits and stateIds must have the same length"; + fail "qubits and stateIds must have the same length"; } for (i in 0 .. Length(qubits) - 1) @@ -108,7 +106,7 @@ namespace Microsoft.Quantum.Diagnostics { /// # Summary /// Checks if the result of applying two operations `givenU` and `expectedU` to /// a basis state is the same. The basis state is described by `basis` parameter. - /// See function for more details on this + /// See function for more details on this /// description. /// /// # Input @@ -119,15 +117,15 @@ namespace Microsoft.Quantum.Diagnostics { /// Operation on $n$ qubits to be checked. /// ## expectedU /// Reference operation on $n$ qubits that givenU is to be compared against. - operation _assertEqualOnBasisVector (basis : Int[], givenU : (Qubit[] => Unit), expectedU : (Qubit[] => Unit is Adj)) : Unit { + internal operation AssertEqualOnBasisVector (basis : Int[], givenU : (Qubit[] => Unit), expectedU : (Qubit[] => Unit is Adj)) : Unit { let tolerance = 1e-5; using (qubits = Qubit[Length(basis)]) { AssertAllZeroWithinTolerance(qubits, tolerance); - _flipToBasis(basis, qubits); + FlipToBasis(basis, qubits); givenU(qubits); Adjoint expectedU(qubits); - Adjoint _flipToBasis(basis, qubits); + Adjoint FlipToBasis(basis, qubits); AssertAllZeroWithinTolerance(qubits, tolerance); } } @@ -157,8 +155,8 @@ namespace Microsoft.Quantum.Diagnostics { /// described in [ *I. L. Chuang, M. A. Nielsen* ](https://arxiv.org/abs/quant-ph/9610001). operation AssertOperationsEqualInPlace(nQubits : Int, givenU : (Qubit[] => Unit), expectedU : (Qubit[] => Unit is Adj)) : Unit { - let checkOperation = _assertEqualOnBasisVector(_, givenU, expectedU); - _iterateThroughCartesianPower(nQubits, 4, checkOperation); + let checkOperation = AssertEqualOnBasisVector(_, givenU, expectedU); + IterateThroughCartesianPower(nQubits, 4, checkOperation); } /// # Summary @@ -177,8 +175,8 @@ namespace Microsoft.Quantum.Diagnostics { /// Reference operation on $n$ qubits that `givenU` is to be compared against. operation AssertOperationsEqualInPlaceCompBasis (nQubits : Int, givenU : (Qubit[] => Unit), expectedU : (Qubit[] => Unit is Adj)) : Unit { - let checkOperation = _assertEqualOnBasisVector(_, givenU, expectedU); - _iterateThroughCartesianPower(nQubits, 2, checkOperation); + let checkOperation = AssertEqualOnBasisVector(_, givenU, expectedU); + IterateThroughCartesianPower(nQubits, 2, checkOperation); } } diff --git a/src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualReferenced.qs b/src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualReferenced.qs similarity index 93% rename from src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualReferenced.qs rename to src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualReferenced.qs index 1b17f67b92f..eed629789a1 100644 --- a/src/Simulation/QSharpCore/Diagnostics/AssertOperationsEqualReferenced.qs +++ b/src/Simulation/TargetDefinitions/Decompositions/AssertOperationsEqualReferenced.qs @@ -17,7 +17,7 @@ namespace Microsoft.Quantum.Diagnostics { /// A qubit array in the $\ket{0\cdots 0}$ state /// ## right /// A qubit array in the $\ket{0\cdots 0}$ state - operation _prepareEntangledState (left : Qubit[], right : Qubit[]) : Unit + internal operation PrepareEntangledState (left : Qubit[], right : Qubit[]) : Unit is Adj + Ctl { for (idxQubit in 0 .. Length(left) - 1) @@ -56,10 +56,10 @@ namespace Microsoft.Quantum.Diagnostics { operation AssertOperationsEqualReferenced (nQubits : Int, actual : (Qubit[] => Unit), expected : (Qubit[] => Unit is Adj)) : Unit { // Prepare a reference register entangled with the target register. using ((reference, target) = (Qubit[nQubits], Qubit[nQubits])) { - _prepareEntangledState(reference, target); + PrepareEntangledState(reference, target); actual(target); Adjoint expected(target); - Adjoint _prepareEntangledState(reference, target); + Adjoint PrepareEntangledState(reference, target); AssertAllZero(reference + target); ResetAll(target); ResetAll(reference); diff --git a/src/Simulation/TargetDefinitions/Decompositions/CCNOT.qs b/src/Simulation/TargetDefinitions/Decompositions/CCNOT.qs new file mode 100644 index 00000000000..99772e845a0 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/CCNOT.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the doubly controlled–NOT (CCNOT) gate to three qubits. + /// + /// # Input + /// ## control1 + /// First control qubit for the CCNOT gate. + /// ## control2 + /// Second control qubit for the CCNOT gate. + /// ## target + /// Target qubit for the CCNOT gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Controlled X([control1, control2], target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.CCNOT") + operation CCNOT (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj + Ctl { + body (...) { + Controlled X([control1, control2], target); + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/CCNOTFromCCZ.qs b/src/Simulation/TargetDefinitions/Decompositions/CCNOTFromCCZ.qs new file mode 100644 index 00000000000..5b1601c799b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/CCNOTFromCCZ.qs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the doubly controlled–NOT (CCNOT) gate to three qubits. + /// + /// # Input + /// ## control1 + /// First control qubit for the CCNOT gate. + /// ## control2 + /// Second control qubit for the CCNOT gate. + /// ## target + /// Target qubit for the CCNOT gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Controlled X([control1, control2], target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.CCNOT") + operation CCNOT (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj + Ctl { + body (...) { + // [Page 15 of arXiv:1206.0758v3](https://arxiv.org/pdf/1206.0758v3.pdf#page=15) + within { + H(target); + } + apply { + Controlled Z([control1, control2], target); + } + } + controlled (ctls, ...) { + Controlled X (ctls + [control1, control2], target); + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/CNOT.qs b/src/Simulation/TargetDefinitions/Decompositions/CNOT.qs new file mode 100644 index 00000000000..7817f4fd480 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/CNOT.qs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the controlled-NOT (CNOT) gate to a pair of qubits. + /// + /// # Description + /// \begin{align} + /// \operatorname{CNOT} \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 0 & 1 \\\\ + /// 0 & 0 & 1 & 0 + /// \end{bmatrix}, + /// \end{align} + /// + /// where rows and columns are ordered as in the quantum concepts guide. + /// + /// # Input + /// ## control + /// Control qubit for the CNOT gate. + /// ## target + /// Target qubit for the CNOT gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Controlled X([control], target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.CNOT") + operation CNOT (control : Qubit, target : Qubit) : Unit is Adj + Ctl { + body (...) { + Controlled X([control], target); + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ExpFrac.qs b/src/Simulation/TargetDefinitions/Decompositions/ExpFrac.qs new file mode 100644 index 00000000000..5a0bdeeb3f1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ExpFrac.qs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Math; + open Microsoft.Quantum.Convert; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the exponential of a multi-qubit Pauli operator + /// with an argument given by a dyadic fraction. + /// + /// # Description + /// \begin{align} + /// e^{i \pi k [P_0 \otimes P_1 \cdots P_{N-1}] / 2^n}, + /// \end{align} + /// where $P_i$ is the $i$th element of `paulis`, and where + /// $N = $`Length(paulis)`. + /// + /// # Input + /// ## paulis + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## numerator + /// Numerator ($k$) in the dyadic fraction representation of the angle + /// by which the qubit register is to be rotated. + /// ## power + /// Power of two ($n$) specifying the denominator of the angle by which + /// the qubit register is to be rotated. + /// ## qubits + /// Register to apply the given rotation to. + @EnableTestingViaName("Test.TargetDefinitions.ExpFrac") + operation ExpFrac (paulis : Pauli[], numerator : Int, power : Int, qubits : Qubit[]) : Unit is Adj + Ctl { + // Note that power must be converted to a double and used with 2.0 instead of 2 to allow for + // negative exponents that result in a fractional denominator. + let angle = (PI() * IntAsDouble(numerator)) / (2.0 ^ IntAsDouble(power)); + Exp(paulis, angle, qubits); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ExpFracFromExpUtil.qs b/src/Simulation/TargetDefinitions/Decompositions/ExpFracFromExpUtil.qs new file mode 100644 index 00000000000..226630ffb79 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ExpFracFromExpUtil.qs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Math; + open Microsoft.Quantum.Convert; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the exponential of a multi-qubit Pauli operator + /// with an argument given by a dyadic fraction. + /// + /// # Description + /// \begin{align} + /// e^{i \pi k [P_0 \otimes P_1 \cdots P_{N-1}] / 2^n}, + /// \end{align} + /// where $P_i$ is the $i$th element of `paulis`, and where + /// $N = $`Length(paulis)`. + /// + /// # Input + /// ## paulis + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## numerator + /// Numerator ($k$) in the dyadic fraction representation of the angle + /// by which the qubit register is to be rotated. + /// ## power + /// Power of two ($n$) specifying the denominator of the angle by which + /// the qubit register is to be rotated. + /// ## qubits + /// Register to apply the given rotation to. + @EnableTestingViaName("Test.TargetDefinitions.ExpFrac") + operation ExpFrac (paulis : Pauli[], numerator : Int, power : Int, qubits : Qubit[]) : Unit is Adj + Ctl { + body (...) { + if (Length(paulis) != Length(qubits)) { fail "Arrays 'pauli' and 'target' must have the same length"; } + + if (Length(paulis) != 0) { + let indices = IndicesOfNonIdentity(paulis); + let newPaulis = Subarray(indices, paulis); + let newQubits = Subarray(indices, qubits); + + if (Length(indices) != 0) { + let (kModPositive, n) = ReducedDyadicFractionPeriodic(numerator, power); // k is odd, in the range [1,2*2^n-1] or (k,n) are both 0 + let numeratorD = PI() * IntAsDouble(kModPositive); + let theta = numeratorD * PowD(2.0, IntAsDouble(-n)); + ExpUtil(newPaulis, theta, newQubits, RFrac(_, numerator, power, _)); + } + else { + ApplyGlobalPhaseFracWithR1Frac(numerator, power); + } + } + } + adjoint(...) { + ExpFrac(paulis, -numerator, power, qubits); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ExpFromExpUtil.qs b/src/Simulation/TargetDefinitions/Decompositions/ExpFromExpUtil.qs new file mode 100644 index 00000000000..6bd54f9a036 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ExpFromExpUtil.qs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the exponential of a multi-qubit Pauli operator. + /// + /// # Description + /// \begin{align} + /// e^{i \theta [P_0 \otimes P_1 \cdots P_{N-1}]}, + /// \end{align} + /// where $P_i$ is the $i$th element of `paulis`, and where + /// $N = $`Length(paulis)`. + /// + /// # Input + /// ## paulis + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## theta + /// Angle about the given multi-qubit Pauli operator by which the + /// target register is to be rotated. + /// ## qubits + /// Register to apply the given rotation to. + @EnableTestingViaName("Test.TargetDefinitions.Exp") + operation Exp (paulis : Pauli[], theta : Double, qubits : Qubit[]) : Unit is Adj + Ctl { + body (...) { + if (Length(paulis) != Length(qubits)) { fail "Arrays 'pauli' and 'qubits' must have the same length"; } + let (newPaulis, newQubits) = RemovePauliI(paulis, qubits); + + if (Length(newPaulis) != 0) { + ExpUtil(newPaulis, theta , newQubits, R(_, -2.0 * theta, _)); + } + else { + ApplyGlobalPhase(theta); + } + } + adjoint(...) { + Exp(paulis, -theta, qubits); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ExpUtil.qs b/src/Simulation/TargetDefinitions/Decompositions/ExpUtil.qs new file mode 100644 index 00000000000..5131ac27048 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ExpUtil.qs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + @EnableTestingViaName("Test.TargetDefinitions.ExpUtil") + internal operation ExpUtil (paulis : Pauli[], theta : Double, qubits : Qubit[], rotation : ((Pauli, Qubit) => Unit is Adj + Ctl)) : Unit is Ctl { + if (Length(paulis) != Length(qubits)) { fail "Arrays 'paulis' and 'qubits' must have the same length"; } + if (Length(paulis) == 1) { + rotation(paulis[0], qubits[0]); + } + else { // Length(paulis) > 1 + within { + for (i in 0 .. Length(paulis) - 1) { + MapPauli(qubits[i], PauliZ, paulis[i]); + } + } + apply { + within { + SpreadZ(qubits[0], qubits[ 1 .. Length(qubits) - 1]); + } + apply { + rotation(PauliZ, qubits[0]); + } + } + } + } + + +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ExpUtilFromIsing.qs b/src/Simulation/TargetDefinitions/Decompositions/ExpUtilFromIsing.qs new file mode 100644 index 00000000000..b1bbc9d0dc4 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ExpUtilFromIsing.qs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + @EnableTestingViaName("Test.TargetDefinitions.ExpUtil") + internal operation ExpUtil (paulis : Pauli[], theta : Double, qubits : Qubit[], rotation : ((Pauli, Qubit) => Unit is Adj + Ctl)) : Unit is Ctl { + if (Length(paulis) != Length(qubits)) { fail "Arrays 'paulis' and 'qubits' must have the same length"; } + if (Length(paulis) == 1) { + rotation(paulis[0], qubits[0]); + } + elif (Length(paulis) == 2) { + within { + MapPauli(qubits[1], paulis[0], paulis[1]); + } + apply { + if (paulis[0] == PauliX) { + IsingXX(theta / 2.0, qubits[0], qubits[1]); + } elif (paulis[0] == PauliY) { + IsingYY(theta / 2.0, qubits[0], qubits[1]); + } elif (paulis[0] == PauliZ) { + IsingZZ(theta / 2.0, qubits[0], qubits[1]); + } else { + fail "Type2 decompositions do not support PauliI as an input to Exp"; + } + } + } + else { // Length(paulis) > 2 + within { + for (i in 0 .. Length(paulis) - 1) { + MapPauli(qubits[i], PauliZ, paulis[i]); + } + } + apply { + within { + SpreadZ(qubits[1], qubits[2 .. Length(qubits) - 1]); + } + apply { + IsingZZ(theta / 2.0, qubits[0], qubits[1]); + } + } + } + } + +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/HFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/HFromSinglyControlled.qs new file mode 100644 index 00000000000..ff638cc18d9 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/HFromSinglyControlled.qs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Hadamard transformation to a single qubit. + /// + /// # Description + /// \begin{align} + /// H \mathrel{:=} + /// \frac{1}{\sqrt{2}} + /// \begin{bmatrix} + /// 1 & 1 \\\\ + /// 1 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.H") + operation H (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledH(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledH(qubit); + } + elif (Length(ctls) == 1) { + within{ + S(qubit); + H(qubit); + T(qubit); + } apply { + CNOT(ctls[0], qubit); + } + } + else { + ApplyWithLessControlsA(Controlled H, (ctls, qubit)); + } + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/I.qs b/src/Simulation/TargetDefinitions/Decompositions/I.qs new file mode 100644 index 00000000000..39ddebc3797 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/I.qs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs the identity operation (no-op) on a single qubit. + /// + /// # Remarks + /// This is a no-op. It is provided for completeness and because + /// sometimes it is useful to call the identity in an algorithm or to pass it as a parameter. + @EnableTestingViaName("Test.TargetDefinitions.I") + operation I (target : Qubit) : Unit is Adj + Ctl { + body (...) { } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/IsingXX.qs b/src/Simulation/TargetDefinitions/Decompositions/IsingXX.qs new file mode 100644 index 00000000000..2c4b93c4ad1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/IsingXX.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $XX$ rotation gate. + /// + /// # Description + /// \begin{align} + /// XX(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// \cos \theta & 0 & 0 & -i\sin \theta \\\\ + /// 0 & \cos \theta & -i\sin \theta & 0 \\\\ + /// 0 & -i\sin \theta & \cos \theta & 0 \\\\ + /// -i\sin \theta & 0 & 0 & \cos \theta + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingXX") + internal operation IsingXX (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliX, PauliX], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/IsingYY.qs b/src/Simulation/TargetDefinitions/Decompositions/IsingYY.qs new file mode 100644 index 00000000000..51d3a76c929 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/IsingYY.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $YY$ rotation gate. + /// + /// # Description + /// \begin{align} + /// YY(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// \cos \theta & 0 & 0 & i\sin \theta \\\\ + /// 0 & \cos \theta & -i\sin \theta & 0 \\\\ + /// 0 & -i\sin \theta & \cos \theta & 0 \\\\ + /// i\sin \theta & 0 & 0 & \cos \theta + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingYY") + internal operation IsingYY (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliY, PauliY], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/IsingZZ.qs b/src/Simulation/TargetDefinitions/Decompositions/IsingZZ.qs new file mode 100644 index 00000000000..16649bcffd6 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/IsingZZ.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $ZZ$ rotation gate. + /// + /// # Description + /// \begin{align} + /// ZZ(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 & 0 & 0 \\\\ + /// 0 & e^{-i \theta / 2} & 0 & 0 \\\\ + /// 0 & 0 & e^{-i \theta / 2} & 0 \\\\ + /// 0 & 0 & 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingZZ") + internal operation IsingZZ (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + Exp([PauliZ, PauliZ], theta * 2.0, [qubit0, qubit1]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/M.qs b/src/Simulation/TargetDefinitions/Decompositions/M.qs new file mode 100644 index 00000000000..a8fb33939a2 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/M.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs a measurement of a single qubit in the + /// Pauli $Z$ basis. + /// + /// # Description + /// The output result is given by + /// the distribution + /// \begin{align} + /// \Pr(\texttt{Zero} | \ket{\psi}) = + /// \braket{\psi | 0} \braket{0 | \psi}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to be measured. + /// + /// # Output + /// `Zero` if the $+1$ eigenvalue is observed, and `One` if + /// the $-1$ eigenvalue is observed. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Measure([PauliZ], [qubit]); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.M") + operation M (qubit : Qubit) : Result { + return Measure([PauliZ], [qubit]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetX.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetX.qs new file mode 100644 index 00000000000..183fbbfd0e3 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetX.qs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + open Microsoft.Quantum.Targeting; + + /// # Summary + /// Measures a single qubit in the X basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $X$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $X$ basis. + @RequiresCapability( + "BasicQuantumFunctionality", + "MResetX is replaced by a supported implementation on all execution targets." + ) + @EnableTestingViaName("Test.TargetDefinitions.MResetX") + operation MResetX (target : Qubit) : Result { + let result = Measure([PauliX], [target]); + + // We must return the qubit to the Z basis as well. + H(target); + + if (result == One) { + // Recall that the +1 eigenspace of a measurement operator corresponds to + // the Result case Zero. Thus, if we see a One case, we must reset the state + // have +1 eigenvalue. + X(target); + } + + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetXExplicit.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetXExplicit.qs new file mode 100644 index 00000000000..d853dc9e8e5 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetXExplicit.qs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the X basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $X$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $X$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetX") + operation MResetX (target : Qubit) : Result { + MapPauli(target, PauliZ, PauliX); + let result = M(target); + Reset(target); + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetXWithNoReuse.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetXWithNoReuse.qs new file mode 100644 index 00000000000..0db2613018d --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetXWithNoReuse.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the X basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $X$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $X$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetX") + operation MResetX (target : Qubit) : Result { + // Because the qubit cannot be reused after measurement, no actual + // reset is required. + return Measure([PauliX], [target]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetY.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetY.qs new file mode 100644 index 00000000000..290b1fb8352 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetY.qs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + open Microsoft.Quantum.Targeting; + + /// # Summary + /// Measures a single qubit in the Y basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Y$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Y$ basis. + @RequiresCapability( + "BasicQuantumFunctionality", + "MResetY is replaced by a supported implementation on all execution targets." + ) + @EnableTestingViaName("Test.TargetDefinitions.MResetY") + operation MResetY (target : Qubit) : Result { + let result = Measure([PauliY], [target]); + + // We must return the qubit to the Z basis as well. + Adjoint S(target); + H(target); + + if (result == One) { + // Recall that the +1 eigenspace of a measurement operator corresponds to + // the Result case Zero. Thus, if we see a One case, we must reset the state + // have +1 eigenvalue. + X(target); + } + + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetYExplicit.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetYExplicit.qs new file mode 100644 index 00000000000..1bb586cfb8e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetYExplicit.qs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the Y basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Y$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Y$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetY") + operation MResetY (target : Qubit) : Result { + MapPauli(target, PauliZ, PauliY); + let result = M(target); + Reset(target); + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetYWithNoReuse.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetYWithNoReuse.qs new file mode 100644 index 00000000000..a2337edb403 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetYWithNoReuse.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the Y basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Y$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Y$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetY") + operation MResetY (target : Qubit) : Result { + // Because the qubit cannot be reused after measurement, no actual + // reset is required. + return Measure([PauliY], [target]); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetZ.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetZ.qs new file mode 100644 index 00000000000..8bb4a8849ec --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetZ.qs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + open Microsoft.Quantum.Targeting; + + /// # Summary + /// Measures a single qubit in the Z basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Z$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Z$ basis. + @RequiresCapability( + "BasicQuantumFunctionality", + "MResetZ is replaced by a supported implementation on all execution targets." + ) + @EnableTestingViaName("Test.TargetDefinitions.MResetZ") + operation MResetZ (target : Qubit) : Result { + let result = M(target); + + if (result == One) { + // Recall that the +1 eigenspace of a measurement operator corresponds to + // the Result case Zero. Thus, if we see a One case, we must reset the state + // have +1 eigenvalue. + X(target); + } + + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetZExplicit.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetZExplicit.qs new file mode 100644 index 00000000000..53dac30786f --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetZExplicit.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the Z basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Z$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Z$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetZ") + operation MResetZ (target : Qubit) : Result { + let result = M(target); + Reset(target); + return result; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MResetZWithNoReuse.qs b/src/Simulation/TargetDefinitions/Decompositions/MResetZWithNoReuse.qs new file mode 100644 index 00000000000..a18daeb426b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MResetZWithNoReuse.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Measures a single qubit in the Z basis, + /// and resets it to a fixed initial state + /// following the measurement. + /// + /// # Description + /// Performs a single-qubit measurement in the $Z$-basis, + /// and ensures that the qubit is returned to $\ket{0}$ + /// following the measurement. + /// + /// # Input + /// ## target + /// A single qubit to be measured. + /// + /// # Output + /// The result of measuring `target` in the Pauli $Z$ basis. + @EnableTestingViaName("Test.TargetDefinitions.MResetZ") + operation MResetZ (target : Qubit) : Result { + // Because the qubit cannot be reused after measurement, no actual + // reset is required. + return M(target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Measure.qs b/src/Simulation/TargetDefinitions/Decompositions/Measure.qs new file mode 100644 index 00000000000..06f83119c47 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Measure.qs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs a joint measurement of one or more qubits in the + /// specified Pauli bases. + /// + /// # Description + /// The output result is given by the distribution: + /// \begin{align} + /// \Pr(\texttt{Zero} | \ket{\psi}) = + /// \frac12 \braket{ + /// \psi \mid| + /// \left( + /// \boldone + P_0 \otimes P_1 \otimes \cdots \otimes P_{N-1} + /// \right) \mid| + /// \psi + /// }, + /// \end{align} + /// where $P_i$ is the $i$th element of `bases`, and where + /// $N = \texttt{Length}(\texttt{bases})$. + /// That is, measurement returns a `Result` $d$ such that the eigenvalue of the + /// observed measurement effect is $(-1)^d$. + /// + /// # Input + /// ## bases + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## qubits + /// Register of qubits to be measured. + /// + /// # Output + /// `Zero` if the $+1$ eigenvalue is observed, and `One` if + /// the $-1$ eigenvalue is observed. + /// + /// # Remarks + /// If the basis array and qubit array are different lengths, then the + /// operation will fail. + @EnableTestingViaName("Test.TargetDefinitions.Measure") + operation Measure (bases : Pauli[], qubits : Qubit[]) : Result { + if (Length(bases) != Length(qubits)) { fail "Arrays 'bases' and 'qubits' must be of the same length."; } + mutable res = One; + if( Length(bases) == 1 ) { + within { + MapPauli(qubits[0], PauliZ, bases[0]); + } + apply { + set res = M(qubits[0]); + PreparePostM(res, qubits[0]); + } + } + else { + using( q = Qubit() ) { + H(q); + for( k in 0 .. Length(bases) - 1 ) { + if( bases[k] == PauliX ) { Controlled X ([qubits[k]], q); } + if( bases[k] == PauliZ ) { Controlled Z ([qubits[k]], q); } + if( bases[k] == PauliY ) { Controlled Y ([qubits[k]], q); } + } + H(q); + set res = M(q); + Reset(q); + } + } + return res; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/MeasureWithNoReuse.qs b/src/Simulation/TargetDefinitions/Decompositions/MeasureWithNoReuse.qs new file mode 100644 index 00000000000..1bac07a8550 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/MeasureWithNoReuse.qs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs a joint measurement of one or more qubits in the + /// specified Pauli bases. + /// + /// # Description + /// The output result is given by the distribution: + /// \begin{align} + /// \Pr(\texttt{Zero} | \ket{\psi}) = + /// \frac12 \braket{ + /// \psi \mid| + /// \left( + /// \boldone + P_0 \otimes P_1 \otimes \cdots \otimes P_{N-1} + /// \right) \mid| + /// \psi + /// }, + /// \end{align} + /// where $P_i$ is the $i$th element of `bases`, and where + /// $N = \texttt{Length}(\texttt{bases})$. + /// That is, measurement returns a `Result` $d$ such that the eigenvalue of the + /// observed measurement effect is $(-1)^d$. + /// + /// # Input + /// ## bases + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## qubits + /// Register of qubits to be measured. + /// + /// # Output + /// `Zero` if the $+1$ eigenvalue is observed, and `One` if + /// the $-1$ eigenvalue is observed. + /// + /// # Remarks + /// If the basis array and qubit array are different lengths, then the + /// operation will fail. + @EnableTestingViaName("Test.TargetDefinitions.Measure") + operation Measure (bases : Pauli[], qubits : Qubit[]) : Result { + if (Length(bases) != Length(qubits)) { fail "Arrays 'bases' and 'qubits' must be of the same length."; } + if (Length(bases) == 1) { + // Because the qubit cannot be reused after measurement, there is no + // need to unprepare the Pauli mapping. + MapPauli(qubits[0], PauliZ, bases[0]); + return M(qubits[0]); + } + else { + using (q = Qubit()) { + within { + H(q); + } + apply { + for (k in 0 .. Length(bases) - 1) { + if (bases[k] == PauliX) { Controlled X([qubits[k]], q); } + if (bases[k] == PauliZ) { Controlled Z([qubits[k]], q); } + if (bases[k] == PauliY) { Controlled Y([qubits[k]], q); } + } + } + return M(q); + } + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/PreparePostM.qs b/src/Simulation/TargetDefinitions/Decompositions/PreparePostM.qs new file mode 100644 index 00000000000..680d9d74faf --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/PreparePostM.qs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + @EnableTestingViaName("Test.TargetDefinitions.PreparePostM") + internal operation PreparePostM(result : Result, qubit : Qubit) : Unit { + // This platform requires reset after measurement, and then must + // re-prepare the measured state in the qubit. + Reset(qubit); + if (result == One) { + X(qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/PreparePostMNoop.qs b/src/Simulation/TargetDefinitions/Decompositions/PreparePostMNoop.qs new file mode 100644 index 00000000000..fb5dc304282 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/PreparePostMNoop.qs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + @EnableTestingViaName("Test.TargetDefinitions.PreparePostM") + internal operation PreparePostM(result : Result, qubit : Qubit) : Unit { + // This platform does not require any post-measurement reset, so + // no additional work is needed. + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/R.qs b/src/Simulation/TargetDefinitions/Decompositions/R.qs new file mode 100644 index 00000000000..bd3f376d6d4 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/R.qs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the given Pauli axis. + /// + /// # Description + /// \begin{align} + /// R_{\mu}(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_{\mu} / 2}, + /// \end{align} + /// where $\mu \in \{I, X, Y, Z\}$. + /// + /// # Input + /// ## pauli + /// Pauli operator ($\mu$) to be exponentiated to form the rotation. + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// When called with `pauli = PauliI`, this operation applies + /// a *global phase*. This phase can be significant + /// when used with the `Controlled` functor. + @EnableTestingViaName("Test.TargetDefinitions.R") + operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + if (pauli == PauliX) { + Rx(theta, qubit); + } + elif (pauli == PauliY) { + Ry(theta, qubit); + } + elif (pauli == PauliZ) { + Rz(theta, qubit); + } + else { // PauliI + ApplyGlobalPhase( - theta / 2.0 ); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/R1.qs b/src/Simulation/TargetDefinitions/Decompositions/R1.qs new file mode 100644 index 00000000000..02ed51439bd --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/R1.qs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $\ket{1}$ state by a given angle. + /// + /// # Description + /// \begin{align} + /// R_1(\theta) \mathrel{:=} + /// \operatorname{diag}(1, e^{i\theta}). + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// R(PauliI, -theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.R1") + operation R1 (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + R(PauliZ, theta, qubit); + R(PauliI, -theta, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/R1Frac.qs b/src/Simulation/TargetDefinitions/Decompositions/R1Frac.qs new file mode 100644 index 00000000000..056e0ba9e54 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/R1Frac.qs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $\ket{1}$ state by an angle specified + /// as a dyadic fraction. + /// + /// # Description + /// \begin{align} + /// R_1(n, k) \mathrel{:=} + /// \operatorname{diag}(1, e^{i \pi k / 2^n}). + /// \end{align} + /// + /// > [!WARNING] + /// > This operation uses the **opposite** sign convention from + /// > @"microsoft.quantum.intrinsic.r", and does not include the + /// > factor of $1/ 2$ included by @"microsoft.quantum.intrinsic.r1". + /// + /// # Input + /// ## numerator + /// Numerator in the dyadic fraction representation of the angle + /// by which the qubit is to be rotated. + /// ## power + /// Power of two specifying the denominator of the angle by which + /// the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// RFrac(PauliZ, -numerator, denominator + 1, qubit); + /// RFrac(PauliI, numerator, denominator + 1, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.R1Frac") + operation R1Frac (numerator : Int, power : Int, qubit : Qubit) : Unit is Adj + Ctl { + RFrac(PauliZ, -numerator, power + 1, qubit); + RFrac(PauliI, numerator, power + 1, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/RFrac.qs b/src/Simulation/TargetDefinitions/Decompositions/RFrac.qs new file mode 100644 index 00000000000..2c1e1b7be37 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/RFrac.qs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Math; + open Microsoft.Quantum.Convert; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the given Pauli axis by an angle specified + /// as a dyadic fraction. + /// + /// # Description + /// \begin{align} + /// R_{\mu}(n, k) \mathrel{:=} + /// e^{i \pi n \sigma_{\mu} / 2^k}, + /// \end{align} + /// where $\mu \in \{I, X, Y, Z\}$. + /// + /// > [!WARNING] + /// > This operation uses the **opposite** sign convention from + /// > @"microsoft.quantum.intrinsic.r". + /// + /// # Input + /// ## pauli + /// Pauli operator to be exponentiated to form the rotation. + /// ## numerator + /// Numerator in the dyadic fraction representation of the angle + /// by which the qubit is to be rotated. + /// ## power + /// Power of two specifying the denominator of the angle by which + /// the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// // PI() is a Q# function that returns an approximation of π. + /// R(pauli, -PI() * IntAsDouble(numerator) / IntAsDouble(2 ^ (power - 1)), qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.RFrac") + operation RFrac (pauli : Pauli, numerator : Int, power : Int, qubit : Qubit) : Unit is Adj + Ctl { + // Note that power must be converted to a double and used with 2.0 instead of 2 to allow for + // negative exponents that result in a fractional denominator. + let angle = ((-2.0 * PI()) * IntAsDouble(numerator)) / (2.0 ^ IntAsDouble(power)); + R(pauli, angle, qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Reset.qs b/src/Simulation/TargetDefinitions/Decompositions/Reset.qs new file mode 100644 index 00000000000..651ba46e2fa --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Reset.qs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + open Microsoft.Quantum.Targeting; + + /// # Summary + /// Given a single qubit, measures it and ensures it is in the |0⟩ state + /// such that it can be safely released. + /// + /// # Input + /// ## qubit + /// The qubit whose state is to be reset to $\ket{0}$. + @RequiresCapability( + "BasicQuantumFunctionality", + "Reset is replaced by a supported implementation on all execution targets." + ) + @EnableTestingViaName("Test.TargetDefinitions.Reset") + operation Reset (qubit : Qubit) : Unit { + if (M(qubit) == One) { + X(qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ResetAll.qs b/src/Simulation/TargetDefinitions/Decompositions/ResetAll.qs new file mode 100644 index 00000000000..6a520c85bb7 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ResetAll.qs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Given an array of qubits, measure them and ensure they are in the |0⟩ state + /// such that they can be safely released. + /// + /// # Input + /// ## qubits + /// An array of qubits whose states are to be reset to $\ket{0}$. + @EnableTestingViaName("Test.TargetDefinitions.ResetAll") + operation ResetAll (qubits : Qubit[]) : Unit { + for (qubit in qubits) { + Reset(qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ResetWithoutReuse.qs b/src/Simulation/TargetDefinitions/Decompositions/ResetWithoutReuse.qs new file mode 100644 index 00000000000..ef28b037cf2 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ResetWithoutReuse.qs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Given a single qubit, measures it and ensures it is in the |0⟩ state + /// such that it can be safely released. + /// + /// # Input + /// ## qubit + /// The qubit whose state is to be reset to $\ket{0}$. + @EnableTestingViaName("Test.TargetDefinitions.Reset") + operation Reset (qubit : Qubit) : Unit { + // This platform doesn't support use of a qubit after measurement, so + // `Reset` is really just marking the qubit as measured. + let r = M(qubit); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Rx.qs b/src/Simulation/TargetDefinitions/Decompositions/Rx.qs new file mode 100644 index 00000000000..e7cf9c8be1c --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Rx.qs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $x$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_x(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_x / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ + /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliX, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rx") + operation Rx (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + R(PauliX, theta, qubit); + } + adjoint (...) { + R(PauliX, -theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/RxFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/RxFromSinglyControlled.qs new file mode 100644 index 00000000000..e964eb00297 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/RxFromSinglyControlled.qs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # SummaRx + /// Applies a rotation about the $x$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_x(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_x / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ + /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliX, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rx") + operation Rx (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledRx(theta, qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledRx(theta, qubit); + } + elif (Length(ctls) == 1) { + within { + MapPauli(qubit, PauliZ, PauliX); + } + apply { + Controlled Rz(ctls, (theta, qubit)); + } + } + else { + ApplyWithLessControlsA(Controlled Rx, (ctls, (theta, qubit))); + } + } + adjoint (...) { + Rx(-theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Ry.qs b/src/Simulation/TargetDefinitions/Decompositions/Ry.qs new file mode 100644 index 00000000000..ac1cb18dcfa --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Ry.qs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $y$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_y(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_y / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ + /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliY, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Ry") + operation Ry (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + R(PauliY, theta, qubit); + } + adjoint (...) { + R(PauliY, -theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/RyFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/RyFromSinglyControlled.qs new file mode 100644 index 00000000000..5b6d46032b0 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/RyFromSinglyControlled.qs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $y$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_y(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_y / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ + /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliY, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Ry") + operation Ry (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledRy(theta, qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledRy(theta, qubit); + } + elif (Length(ctls) == 1) { + within { + MapPauli(qubit, PauliZ, PauliY); + } + apply { + Controlled Rz(ctls, (theta, qubit)); + } + } + else { + ApplyWithLessControlsA(Controlled Ry, (ctls, (theta, qubit))); + } + } + adjoint (...) { + Ry(-theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Rz.qs b/src/Simulation/TargetDefinitions/Decompositions/Rz.qs new file mode 100644 index 00000000000..08d0e2b239b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Rz.qs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $z$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_z(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_z / 2} = + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 \\\\ + /// 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rz") + operation Rz (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + R(PauliZ, theta, qubit); + } + adjoint (...) { + R(PauliZ, -theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/RzFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/RzFromSinglyControlled.qs new file mode 100644 index 00000000000..09bfa6aec51 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/RzFromSinglyControlled.qs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $z$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_z(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_z / 2} = + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 \\\\ + /// 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rz") + operation Rz (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledRz(theta, qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + Rz(theta, qubit); + } + elif (Length(ctls) == 1) { + Rz(theta/2.0, qubit); + CNOT(ctls[0], qubit); + Rz(-theta/2.0, qubit); + CNOT(ctls[0], qubit); + } + else { + ApplyWithLessControlsA(Controlled Rz, (ctls, (theta, qubit))); + } + } + adjoint (...) { + Rz(-theta, qubit); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/SFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/SFromSinglyControlled.qs new file mode 100644 index 00000000000..09655566e04 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/SFromSinglyControlled.qs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/4 phase gate to a single qubit. + /// + /// # Description + /// \begin{align} + /// S \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & i + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.S") + operation S (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledS(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledS(qubit); + } + elif (Length(ctls) == 1) { + T(ctls[0]); + T(qubit); + CNOT(ctls[0], qubit); + Adjoint T(qubit); + CNOT(ctls[0], qubit); + } + else { + ApplyWithLessControlsA(Controlled S, (ctls, qubit)); + } + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/SWAP.qs b/src/Simulation/TargetDefinitions/Decompositions/SWAP.qs new file mode 100644 index 00000000000..5b987ea6b74 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/SWAP.qs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the SWAP gate to a pair of qubits. + /// + /// # Description + /// \begin{align} + /// \operatorname{SWAP} \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 0 & 1 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 0 & 1 + /// \end{bmatrix}, + /// \end{align} + /// + /// where rows and columns are ordered as in the quantum concepts guide. + /// + /// # Input + /// ## qubit1 + /// First qubit to be swapped. + /// ## qubit2 + /// Second qubit to be swapped. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// CNOT(qubit1, qubit2); + /// CNOT(qubit2, qubit1); + /// CNOT(qubit1, qubit2); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.SWAP") + operation SWAP (qubit1 : Qubit, qubit2 : Qubit) : Unit is Adj + Ctl { + body (...) { + within { + CNOT(qubit1, qubit2); + } apply { + CNOT(qubit2, qubit1); + } + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/SetToBasisState.qs b/src/Simulation/TargetDefinitions/Decompositions/SetToBasisState.qs new file mode 100644 index 00000000000..740925d833c --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/SetToBasisState.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Measurement { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Sets a qubit to a given computational basis state by measuring the + /// qubit and applying a bit flip if needed. + /// + /// # Input + /// ## desired + /// The basis state that the qubit should be set to. + /// ## target + /// The qubit whose state is to be set. + /// + /// # Remarks + /// As an invariant of this operation, calling `M(q)` immediately + /// after `SetToBasisState(result, q)` will return `result`. + @EnableTestingViaName("Test.TargetDefinitions.SetToBasisState") + operation SetToBasisState(desired : Result, target : Qubit) : Unit { + if (desired != M(target)) { + X(target); + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/TFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/TFromSinglyControlled.qs new file mode 100644 index 00000000000..222ef97d9e1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/TFromSinglyControlled.qs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/8 gate to a single qubit. + /// + /// # Description + /// \begin{align} + /// T \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & e^{i \pi / 4} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.T") + operation T (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledT(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledT(qubit); + } + elif (Length(ctls) == 1) { + R1Frac(1, 3, ctls[0]); + R1Frac(1, 3, qubit); + CNOT(ctls[0], qubit); + Adjoint R1Frac(1, 3, qubit); + CNOT(ctls[0], qubit); + } + else { + ApplyWithLessControlsA(Controlled T, (ctls, qubit)); + } + } + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/Utils.qs b/src/Simulation/TargetDefinitions/Decompositions/Utils.qs new file mode 100644 index 00000000000..d2808323a0d --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/Utils.qs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + @EnableTestingViaName("Test.TargetDefinitions.SpreadZ") + internal operation SpreadZ (from : Qubit, to : Qubit[]) : Unit is Adj { + if (Length(to) > 0) { + CNOT(to[0], from); + if (Length(to) > 1) { + let half = Length(to) / 2; + SpreadZ(to[0], to[half + 1 .. Length(to) - 1]); + SpreadZ(from, to[1 .. half]); + } + } + } + + @EnableTestingViaName("Test.TargetDefinitions.ApplyGlobalPhase") + internal operation ApplyGlobalPhase (theta : Double) : Unit is Ctl + Adj { + body (...) {} + controlled (controls, (...)) { + if (Length(controls) > 0) { + let qubit = controls[0]; + let rest = controls[1...]; + // Invoke Controlled R1, which will recursively call back into ApplyGlobalPhase. + // Each time the controls is one shorter, until it is empty and the recursion stops. + Controlled R1(rest, (theta, qubit)); + } + } + } + + @EnableTestingViaName("Test.TargetDefinitions.ApplyGlobalPhaseFracWithR1Frac") + internal operation ApplyGlobalPhaseFracWithR1Frac (numerator : Int, power : Int) : Unit is Adj + Ctl { + body (...) {} + controlled (ctrls, ...) { + let numControls = Length(ctrls); + if (numControls > 0 ) { + // Invoke Controlled R1Frac, which will recursively call back into ApplyGlobalPhase. + // Each time the controls is one shorter, until it is empty and the recursion stops. + Controlled R1Frac(ctrls[1 .. numControls - 1], (numerator, power, ctrls[0])); + } + } + } + + @EnableTestingViaName("Test.TargetDefinitions.MapPauli") + internal operation MapPauli (qubit : Qubit, from : Pauli, to : Pauli) : Unit is Adj { + if (from == to) { + } + elif ((from == PauliZ and to == PauliX) or (from == PauliX and to == PauliZ)) { + H(qubit); + } + elif (from == PauliZ and to == PauliY) { + H(qubit); + S(qubit); + H(qubit); + } + elif (from == PauliY and to == PauliZ) { + H(qubit); + Adjoint S(qubit); + H(qubit); + } + elif (from == PauliY and to == PauliX) { + S(qubit); + } + elif (from == PauliX and to == PauliY) { + Adjoint S(qubit); + } + else { + fail "Unsupported input"; + } + } + + /// Given a multiply-controlled operation that requires k controls + /// applies it using ceiling(k/2) controls and using floor(k/2) temporary qubits + @EnableTestingViaName("Test.TargetDefinitions.ApplyWithLessControlsA") + internal operation ApplyWithLessControlsA<'T> (op : ((Qubit[],'T) => Unit is Adj), (controls : Qubit[], arg : 'T)) : Unit is Adj { + let numControls = Length(controls); + let numControlPairs = numControls / 2; + using (temps = Qubit[numControlPairs]) { + within { + for (numPair in 0 .. numControlPairs - 1) { // constant depth + PhaseCCX(controls[2*numPair], controls[2*numPair + 1], temps[numPair]); + } + } + apply { + let newControls = numControls % 2 == 0 ? temps | temps + [controls[numControls - 1]]; + op(newControls, arg); + } + } + } + + @EnableTestingViaName("Test.TargetDefinitions.PhaseCCX") + internal operation PhaseCCX (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj { + // https://arxiv.org/pdf/1210.0974.pdf#page=2 + H(target); + CNOT(target,control1); + CNOT(control1,control2); + T(control2); + Adjoint T(control1); + T(target); + CNOT(target,control1); + CNOT(control1,control2); + Adjoint T(control2); + CNOT(target,control2); + H(target); + } + + @EnableTestingViaName("Test.TargetDefinitions.ReducedDyadicFraction") + internal function ReducedDyadicFraction (numerator : Int, denominatorPowerOfTwo : Int) : (Int, Int) { + if (numerator == 0) { return (0,0); } + mutable num = numerator; + mutable denPow = denominatorPowerOfTwo; + while(num % 2 == 0) { + set num /= 2; + set denPow += 1; + } + return (num,denPow); + } + + @EnableTestingViaName("Test.TargetDefinitions.ReducedDyadicFractionPeriodic") + internal function ReducedDyadicFractionPeriodic (numerator : Int, denominatorPowerOfTwo : Int) : (Int, Int) { + let (k,n) = ReducedDyadicFraction(numerator,denominatorPowerOfTwo); // k is odd, or (k,n) are both 0 + let period = 2*2^n; // \pi k / 2^n is 2\pi periodic, therefore k is 2 * 2^n periodic + let kMod = k % period; // if k was negative, we get kMod in a range [-period + 1, 0] + let kModPositive = kMod >= 0 ? kMod | kMod + period; // kModPositive is in the range [0, period - 1] + return (kModPositive, n); + } + + // TODO(swernli): Consider removing this in favor of pulling Microsoft.Quantum.Arrays.Subarray + // into the runtime. + @EnableTestingViaName("Test.TargetDefinitions.Subarray") + internal function Subarray<'T> (indices : Int[], array : 'T[]) : 'T[] { + let nSliced = Length(indices); + mutable sliced = new 'T[nSliced]; + + for (idx in 0 .. nSliced - 1) { + set sliced w/= idx <- array[indices[idx]]; + } + + return sliced; + } + + @EnableTestingViaName("Test.TargetDefinitions.IndicesOfNonIdentity") + internal function IndicesOfNonIdentity (paulies : Pauli[]) : Int[] { + mutable nonIdPauliCount = 0; + + for (i in 0 .. Length(paulies) - 1) { + if (paulies[i] != PauliI) { set nonIdPauliCount += 1; } + } + + mutable indices = new Int[nonIdPauliCount]; + mutable index = 0; + + for (i in 0 .. Length(paulies) - 1) { + if (paulies[i] != PauliI) { + set indices w/= index <- i; + set index = index + 1; + } + } + + return indices; + } + + @EnableTestingViaName("Test.TargetDefinitions.RemovePauliI") + internal function RemovePauliI (paulis : Pauli[], qubits : Qubit[]) : (Pauli[], Qubit[]) { + let indices = IndicesOfNonIdentity(paulis); + let newPaulis = Subarray(indices, paulis); + let newQubits = Subarray(indices, qubits); + return (newPaulis, newQubits); + } + +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/XFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/XFromSinglyControlled.qs new file mode 100644 index 00000000000..e33e1c88263 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/XFromSinglyControlled.qs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $X$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_x \mathrel{:=} + /// \begin{bmatrix} + /// 0 & 1 \\\\ + /// 1 & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.X") + operation X (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledX(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledX(qubit); + } + elif (Length(ctls) == 1) { + ApplyControlledX(ctls[0], qubit); + } + elif (Length(ctls) == 2) { + CCNOT(ctls[0], ctls[1], qubit); + } + else { + ApplyWithLessControlsA(Controlled X, (ctls, qubit)); + } + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/YFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/YFromSinglyControlled.qs new file mode 100644 index 00000000000..7636e127f22 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/YFromSinglyControlled.qs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Y$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_y \mathrel{:=} + /// \begin{bmatrix} + /// 0 & -i \\\\ + /// i & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.Y") + operation Y (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledY(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledY(qubit); + } + elif (Length(ctls) == 1) { + within { + MapPauli(qubit, PauliX, PauliY); + } + apply { + CNOT(ctls[0], qubit); + } + } + elif (Length(ctls) == 2) { + within { + MapPauli(qubit, PauliZ, PauliY); + } + apply { + Controlled Z(ctls, qubit); + } + } + else { + ApplyWithLessControlsA(Controlled Y, (ctls, qubit)); + } + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Decompositions/ZFromSinglyControlled.qs b/src/Simulation/TargetDefinitions/Decompositions/ZFromSinglyControlled.qs new file mode 100644 index 00000000000..146bfc5da6d --- /dev/null +++ b/src/Simulation/TargetDefinitions/Decompositions/ZFromSinglyControlled.qs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Z$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_z \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.Z") + operation Z (qubit : Qubit) : Unit is Adj + Ctl { + body (...) { + ApplyUncontrolledZ(qubit); + } + controlled (ctls, ...) { + if (Length(ctls) == 0) { + ApplyUncontrolledZ(qubit); + } + elif (Length(ctls) == 1) { + ApplyControlledZ(ctls[0], qubit); + } + elif (Length(ctls) == 2) { + // [Page 15 of arXiv:1206.0758v3](https://arxiv.org/pdf/1206.0758v3.pdf#page=15) + Adjoint T(ctls[0]); + Adjoint T(ctls[1]); + CNOT(qubit, ctls[0]); + T(ctls[0]); + CNOT(ctls[1], qubit); + CNOT(ctls[1], ctls[0]); + T(qubit); + Adjoint T(ctls[0]); + CNOT(ctls[1], qubit); + CNOT(qubit, ctls[0]); + Adjoint T(qubit); + T(ctls[0]); + CNOT(ctls[1], ctls[0]); + } + else { + ApplyWithLessControlsA(Controlled Z, (ctls, qubit)); + } + } + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/DelaySign.cs b/src/Simulation/TargetDefinitions/DelaySign.cs new file mode 100644 index 00000000000..1e58f326190 --- /dev/null +++ b/src/Simulation/TargetDefinitions/DelaySign.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Reflection; + +// Attributes for delay-signing +#if SIGNED +[assembly:AssemblyKeyFile("..\\..\\..\\..\\Build\\267DevDivSNKey2048.snk")] +[assembly:AssemblyDelaySign(true)] +#endif + +internal static class DelaySign +{ +#pragma warning disable SA1310 // Fields should not have underscore. +#if SIGNED + public const string PUBLIC_KEY = ", PublicKey=" + + "002400000c800000140100000602000000240000525341310008000001000100613399aff18ef1" + + "a2c2514a273a42d9042b72321f1757102df9ebada69923e2738406c21e5b801552ab8d200a65a2" + + "35e001ac9adc25f2d811eb09496a4c6a59d4619589c69f5baf0c4179a47311d92555cd006acc8b" + + "5959f2bd6e10e360c34537a1d266da8085856583c85d81da7f3ec01ed9564c58d93d713cd0172c" + + "8e23a10f0239b80c96b07736f5d8b022542a4e74251a5f432824318b3539a5a087f8e53d2f135f" + + "9ca47f3bb2e10aff0af0849504fb7cea3ff192dc8de0edad64c68efde34c56d302ad55fd6e80f3" + + "02d5efcdeae953658d3452561b5f36c542efdbdd9f888538d374cef106acf7d93a4445c3c73cd9" + + "11f0571aaf3d54da12b11ddec375b3"; +#else + public const string PUBLIC_KEY = ""; +#endif +} diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledX.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledX.cs new file mode 100644 index 00000000000..180c37afce2 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledX.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyControlledX : IOperationFactory + { + void ApplyControlledX__Body(Qubit control, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledZ.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledZ.cs new file mode 100644 index 00000000000..f1277c03508 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyControlledZ.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyControlledZ : IOperationFactory + { + void ApplyControlledZ__Body(Qubit control, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledH.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledH.cs new file mode 100644 index 00000000000..6c3a3853527 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledH.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledH : IOperationFactory + { + void ApplyUncontrolledH__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRx.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRx.cs new file mode 100644 index 00000000000..df14696b85f --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRx.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledRx : IOperationFactory + { + void ApplyUncontrolledRx__Body(double angle, Qubit target); + + void ApplyUncontrolledRx__AdjointBody(double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRy.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRy.cs new file mode 100644 index 00000000000..c817abd4cd9 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRy.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledRy : IOperationFactory + { + void ApplyUncontrolledRy__Body(double angle, Qubit target); + + void ApplyUncontrolledRy__AdjointBody(double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRz.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRz.cs new file mode 100644 index 00000000000..97bab6ea276 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledRz.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledRz : IOperationFactory + { + void ApplyUncontrolledRz__Body(double angle, Qubit target); + + void ApplyUncontrolledRz__AdjointBody(double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledS.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledS.cs new file mode 100644 index 00000000000..2ffe2a2e9af --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledS.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledS : IOperationFactory + { + void ApplyUncontrolledS__Body(Qubit target); + + void ApplyUncontrolledS__AdjointBody(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledT.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledT.cs new file mode 100644 index 00000000000..e06d80675a6 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledT.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledT : IOperationFactory + { + void ApplyUncontrolledT__Body(Qubit target); + + void ApplyUncontrolledT__AdjointBody(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledX.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledX.cs new file mode 100644 index 00000000000..1f7163e9af1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledX.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledX : IOperationFactory + { + void ApplyUncontrolledX__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledY.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledY.cs new file mode 100644 index 00000000000..a280bbc4d5c --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledY.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledY : IOperationFactory + { + void ApplyUncontrolledY__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledZ.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledZ.cs new file mode 100644 index 00000000000..ce04925ca51 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_ApplyUncontrolledZ.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_ApplyUncontrolledZ : IOperationFactory + { + void ApplyUncontrolledZ__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Exp.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Exp.cs new file mode 100644 index 00000000000..f02267efb24 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Exp.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Exp : IOperationFactory + { + void Exp__Body(IQArray paulis, double angle, IQArray targets); + + void Exp__AdjointBody(IQArray paulis, double angle, IQArray targets); + + void Exp__ControlledBody(IQArray controls, IQArray paulis, double angle, IQArray targets); + + void Exp__ControlledAdjointBody(IQArray controls, IQArray paulis, double angle, IQArray targets); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_H.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_H.cs new file mode 100644 index 00000000000..a1cce04429e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_H.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_H : IOperationFactory + { + void H__Body(Qubit target); + + void H__ControlledBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingXX.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingXX.cs new file mode 100644 index 00000000000..364d078bd31 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingXX.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_IsingXX : IOperationFactory + { + void IsingXX__Body(double angle, Qubit target1, Qubit target2); + + void IsingXX__AdjointBody(double angle, Qubit target1, Qubit target2); + + void IsingXX__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2); + + void IsingXX__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingYY.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingYY.cs new file mode 100644 index 00000000000..606161eafda --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingYY.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_IsingYY : IOperationFactory + { + void IsingYY__Body(double angle, Qubit target1, Qubit target2); + + void IsingYY__AdjointBody(double angle, Qubit target1, Qubit target2); + + void IsingYY__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2); + + void IsingYY__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingZZ.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingZZ.cs new file mode 100644 index 00000000000..e53f81f828d --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_IsingZZ.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_IsingZZ : IOperationFactory + { + void IsingZZ__Body(double angle, Qubit target1, Qubit target2); + + void IsingZZ__AdjointBody(double angle, Qubit target1, Qubit target2); + + void IsingZZ__ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2); + + void IsingZZ__ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_M.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_M.cs new file mode 100644 index 00000000000..6cce4c7c6a5 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_M.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_M : IOperationFactory + { + Result M__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Measure.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Measure.cs new file mode 100644 index 00000000000..09caaa5ac47 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Measure.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Measure : IOperationFactory + { + Result Measure__Body(IQArray paulis, IQArray targets); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_R.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_R.cs new file mode 100644 index 00000000000..d7853d09844 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_R.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_R : IOperationFactory + { + void R__Body(Pauli pauli, double angle, Qubit target); + + void R__AdjointBody(Pauli pauli, double angle, Qubit target); + + void R__ControlledBody(IQArray controls, Pauli pauli, double angle, Qubit target); + + void R__ControlledAdjointBody(IQArray controls, Pauli pauli, double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Reset.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Reset.cs new file mode 100644 index 00000000000..7d9111327ad --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Reset.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Reset : IOperationFactory + { + void Reset__Body(Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Rx.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Rx.cs new file mode 100644 index 00000000000..cad8505a864 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Rx.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Rx : IOperationFactory + { + void Rx__Body(double angle, Qubit target); + + void Rx__AdjointBody(double angle, Qubit target); + + void Rx__ControlledBody(IQArray controls, double angle, Qubit target); + + void Rx__ControlledAdjointBody(IQArray controls, double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Ry.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Ry.cs new file mode 100644 index 00000000000..c8cee96909b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Ry.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Ry : IOperationFactory + { + void Ry__Body(double angle, Qubit target); + + void Ry__AdjointBody(double angle, Qubit target); + + void Ry__ControlledBody(IQArray controls, double angle, Qubit target); + + void Ry__ControlledAdjointBody(IQArray controls, double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Rz.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Rz.cs new file mode 100644 index 00000000000..716e68c6dec --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Rz.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Rz : IOperationFactory + { + void Rz__Body(double angle, Qubit target); + + void Rz__AdjointBody(double angle, Qubit target); + + void Rz__ControlledBody(IQArray controls, double angle, Qubit target); + + void Rz__ControlledAdjointBody(IQArray controls, double angle, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_S.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_S.cs new file mode 100644 index 00000000000..f26c0923d2a --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_S.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_S : IOperationFactory + { + void S__Body(Qubit target); + + void S__AdjointBody(Qubit target); + + void S__ControlledBody(IQArray controls, Qubit target); + + void S__ControlledAdjointBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_SWAP.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_SWAP.cs new file mode 100644 index 00000000000..a987d1bcf3b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_SWAP.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_SWAP : IOperationFactory + { + void SWAP__Body(Qubit target1, Qubit target2); + + void SWAP__ControlledBody(IQArray controls, Qubit target1, Qubit target2); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_T.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_T.cs new file mode 100644 index 00000000000..1e665fc087f --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_T.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_T : IOperationFactory + { + void T__Body(Qubit target); + + void T__AdjointBody(Qubit target); + + void T__ControlledBody(IQArray controls, Qubit target); + + void T__ControlledAdjointBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_X.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_X.cs new file mode 100644 index 00000000000..17d5aee37e3 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_X.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_X : IOperationFactory + { + void X__Body(Qubit target); + + void X__ControlledBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Y.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Y.cs new file mode 100644 index 00000000000..87fbef8300e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Y.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Y : IOperationFactory + { + void Y__Body(Qubit target); + + void Y__ControlledBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IGate_Z.cs b/src/Simulation/TargetDefinitions/Interfaces/IGate_Z.cs new file mode 100644 index 00000000000..1264e6cd20a --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IGate_Z.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Quantum.Simulation.Core; + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IGate_Z : IOperationFactory + { + void Z__Body(Qubit target); + + void Z__ControlledBody(IQArray controls, Qubit target); + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IQSharpCore.cs b/src/Simulation/TargetDefinitions/Interfaces/IQSharpCore.cs new file mode 100644 index 00000000000..6c47d4dd93e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IQSharpCore.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IQSharpCore : + IGate_Exp, + IGate_H, + IGate_Measure, + IGate_R, + IGate_S, + IGate_T, + IGate_X, + IGate_Y, + IGate_Z + { } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IType1Core.cs b/src/Simulation/TargetDefinitions/Interfaces/IType1Core.cs new file mode 100644 index 00000000000..fbf02b06a45 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IType1Core.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IType1Core : + IGate_ApplyControlledX, + IGate_ApplyControlledZ, + IGate_ApplyUncontrolledH, + IGate_ApplyUncontrolledRx, + IGate_ApplyUncontrolledRy, + IGate_ApplyUncontrolledRz, + IGate_ApplyUncontrolledS, + IGate_ApplyUncontrolledT, + IGate_ApplyUncontrolledX, + IGate_ApplyUncontrolledY, + IGate_ApplyUncontrolledZ, + IGate_M, + IGate_Reset + { } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/IType2Core.cs b/src/Simulation/TargetDefinitions/Interfaces/IType2Core.cs new file mode 100644 index 00000000000..3603389e9f4 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/IType2Core.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic.Interfaces +{ + public interface IType2Core : + IGate_H, + IGate_IsingXX, + IGate_IsingYY, + IGate_IsingZZ, + IGate_M, + IGate_Rx, + IGate_Ry, + IGate_Rz, + IGate_S, + IGate_SWAP, + IGate_T, + IGate_X, + IGate_Y, + IGate_Z + { } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Interfaces/Microsoft.Quantum.Targets.Interfaces.csproj b/src/Simulation/TargetDefinitions/Interfaces/Microsoft.Quantum.Targets.Interfaces.csproj new file mode 100644 index 00000000000..e8081a10b53 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Interfaces/Microsoft.Quantum.Targets.Interfaces.csproj @@ -0,0 +1,26 @@ + + + + + + netstandard2.1 + x64 + + + + Target package interfaces for the Q# runtime. + Quantum Q# QSharp + + + + + + + + + + + + + + diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledX.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledX.qs new file mode 100644 index 00000000000..0c5417ada18 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledX.qs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the controlled-X (or CNOT) gate to a pair of qubits. Does not support + /// the Controlled functor. + /// + /// # Description + /// \begin{align} + /// \operatorname{CNOT} \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 0 & 1 \\\\ + /// 0 & 0 & 1 & 0 + /// \end{bmatrix}, + /// \end{align} + /// + /// where rows and columns are ordered as in the quantum concepts guide. + /// + /// # Input + /// ## control + /// Control qubit for the CNOT gate. + /// ## target + /// Target qubit for the CNOT gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// CNOT(control, target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyControlledX") + internal operation ApplyControlledX (control : Qubit, target : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledZ.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledZ.qs new file mode 100644 index 00000000000..c91154afdab --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyControlledZ.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the controlled-Z (CZ) gate to a pair of qubits. + /// + /// $$ + /// \begin{align} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 1 & 0 \\\\ + /// 0 & 0 & 0 & -1 + /// \end{align}, + /// $$ + /// where rows and columns are organized as in the quantum concepts guide. + /// + /// # Input + /// ## control + /// Control qubit for the CZ gate. + /// ## target + /// Target qubit for the CZ gate. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Controlled Z([control], target); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyControlledZ") + internal operation ApplyControlledZ (control : Qubit, target : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledH.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledH.qs new file mode 100644 index 00000000000..8b0f82af9c2 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledH.qs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Hadamard transformation to a single qubit. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// H \mathrel{:=} + /// \frac{1}{\sqrt{2}} + /// \begin{bmatrix} + /// 1 & 1 \\\\ + /// 1 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledH") + internal operation ApplyUncontrolledH (qubit : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRx.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRx.qs new file mode 100644 index 00000000000..af0e8fcac43 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRx.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $x$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_x(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_x / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ + /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliX, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRx") + internal operation ApplyUncontrolledRx (theta : Double, qubit : Qubit) : Unit is Adj { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRy.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRy.qs new file mode 100644 index 00000000000..4c63a72fffe --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRy.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $y$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_y(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_y / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ + /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliY, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRy") + internal operation ApplyUncontrolledRy (theta : Double, qubit : Qubit) : Unit is Adj { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRz.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRz.qs new file mode 100644 index 00000000000..ffeb44ab440 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledRz.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $z$-axis by a given angle. Note that the Controlled + /// functor is not supported. + /// + /// # Description + /// \begin{align} + /// R_z(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_z / 2} = + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 \\\\ + /// 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledRz") + internal operation ApplyUncontrolledRz (theta : Double, qubit : Qubit) : Unit is Adj { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledS.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledS.qs new file mode 100644 index 00000000000..f8fe46dd430 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledS.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/4 phase gate to a single qubit. Note that the Controlled functor + /// is not supported. + /// + /// # Description + /// \begin{align} + /// S \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & i + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledS") + internal operation ApplyUncontrolledS (qubit : Qubit) : Unit is Adj { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledT.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledT.qs new file mode 100644 index 00000000000..2fd4b11d41d --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledT.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/8 gate to a single qubit. Note that the Controlled functor is + /// not supported. + /// + /// # Description + /// \begin{align} + /// T \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & e^{i \pi / 4} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledT") + internal operation ApplyUncontrolledT (qubit : Qubit) : Unit is Adj { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledX.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledX.qs new file mode 100644 index 00000000000..45a27d9a5f6 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledX.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $X$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_x \mathrel{:=} + /// \begin{bmatrix} + /// 0 & 1 \\\\ + /// 1 & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledX") + internal operation ApplyUncontrolledX (qubit : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledY.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledY.qs new file mode 100644 index 00000000000..8e9a2fe20bb --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledY.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Y$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_y \mathrel{:=} + /// \begin{bmatrix} + /// 0 & -i \\\\ + /// i & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledY") + internal operation ApplyUncontrolledY (qubit : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledZ.qs b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledZ.qs new file mode 100644 index 00000000000..302252cf68e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledZ.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Z$ gate. Note that the Controlled functor is not supported. + /// + /// # Description + /// \begin{align} + /// \sigma_z \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.ApplyUncontrolledZ") + internal operation ApplyUncontrolledZ (qubit : Qubit) : Unit is Adj { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Exp.qs b/src/Simulation/TargetDefinitions/Intrinsic/Exp.qs new file mode 100644 index 00000000000..df58c4a3f3c --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Exp.qs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the exponential of a multi-qubit Pauli operator. + /// + /// # Description + /// \begin{align} + /// e^{i \theta [P_0 \otimes P_1 \cdots P_{N-1}]}, + /// \end{align} + /// where $P_i$ is the $i$th element of `paulis`, and where + /// $N = $`Length(paulis)`. + /// + /// # Input + /// ## paulis + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## theta + /// Angle about the given multi-qubit Pauli operator by which the + /// target register is to be rotated. + /// ## qubits + /// Register to apply the given rotation to. + @EnableTestingViaName("Test.TargetDefinitions.Exp") + operation Exp (paulis : Pauli[], theta : Double, qubits : Qubit[]) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/H.qs b/src/Simulation/TargetDefinitions/Intrinsic/H.qs new file mode 100644 index 00000000000..740796ddd0b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/H.qs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Hadamard transformation to a single qubit. + /// + /// # Description + /// \begin{align} + /// H \mathrel{:=} + /// \frac{1}{\sqrt{2}} + /// \begin{bmatrix} + /// 1 & 1 \\\\ + /// 1 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.H") + operation H (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/IsingXX.qs b/src/Simulation/TargetDefinitions/Intrinsic/IsingXX.qs new file mode 100644 index 00000000000..c20f4c56731 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/IsingXX.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $XX$ rotation gate. + /// + /// # Description + /// \begin{align} + /// XX(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// \cos \theta & 0 & 0 & -i\sin \theta \\\\ + /// 0 & \cos \theta & -i\sin \theta & 0 \\\\ + /// 0 & -i\sin \theta & \cos \theta & 0 \\\\ + /// -i\sin \theta & 0 & 0 & \cos \theta + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingXX") + internal operation IsingXX (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/IsingYY.qs b/src/Simulation/TargetDefinitions/Intrinsic/IsingYY.qs new file mode 100644 index 00000000000..39fe3a24ff5 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/IsingYY.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $YY$ rotation gate. + /// + /// # Description + /// \begin{align} + /// YY(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// \cos \theta & 0 & 0 & i\sin \theta \\\\ + /// 0 & \cos \theta & -i\sin \theta & 0 \\\\ + /// 0 & -i\sin \theta & \cos \theta & 0 \\\\ + /// i\sin \theta & 0 & 0 & \cos \theta + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingYY") + internal operation IsingYY (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/IsingZZ.qs b/src/Simulation/TargetDefinitions/Intrinsic/IsingZZ.qs new file mode 100644 index 00000000000..c800c2b92f2 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/IsingZZ.qs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the two qubit Ising $ZZ$ rotation gate. + /// + /// # Description + /// \begin{align} + /// ZZ(\theta) \mathrel{:=} + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 & 0 & 0 \\\\ + /// 0 & e^{-i \theta / 2} & 0 & 0 \\\\ + /// 0 & 0 & e^{-i \theta / 2} & 0 \\\\ + /// 0 & 0 & 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// The angle about which the qubits are rotated. + /// ## qubit0 + /// The first qubit input to the gate. + /// ## qubit1 + /// The second qubit input to the gate. + @EnableTestingViaName("Test.TargetDefinitions.IsingZZ") + internal operation IsingZZ (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/M.qs b/src/Simulation/TargetDefinitions/Intrinsic/M.qs new file mode 100644 index 00000000000..7c44f88a5d1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/M.qs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs a measurement of a single qubit in the + /// Pauli $Z$ basis. + /// + /// # Description + /// The output result is given by + /// the distribution + /// \begin{align} + /// \Pr(\texttt{Zero} | \ket{\psi}) = + /// \braket{\psi | 0} \braket{0 | \psi}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to be measured. + /// + /// # Output + /// `Zero` if the $+1$ eigenvalue is observed, and `One` if + /// the $-1$ eigenvalue is observed. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// Measure([PauliZ], [qubit]); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.M") + operation M (qubit : Qubit) : Result { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Measure.qs b/src/Simulation/TargetDefinitions/Intrinsic/Measure.qs new file mode 100644 index 00000000000..ada792ca5f4 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Measure.qs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Performs a joint measurement of one or more qubits in the + /// specified Pauli bases. + /// + /// # Description + /// The output result is given by the distribution: + /// \begin{align} + /// \Pr(\texttt{Zero} | \ket{\psi}) = + /// \frac12 \braket{ + /// \psi \mid| + /// \left( + /// \boldone + P_0 \otimes P_1 \otimes \cdots \otimes P_{N-1} + /// \right) \mid| + /// \psi + /// }, + /// \end{align} + /// where $P_i$ is the $i$th element of `bases`, and where + /// $N = \texttt{Length}(\texttt{bases})$. + /// That is, measurement returns a `Result` $d$ such that the eigenvalue of the + /// observed measurement effect is $(-1)^d$. + /// + /// # Input + /// ## bases + /// Array of single-qubit Pauli values indicating the tensor product + /// factors on each qubit. + /// ## qubits + /// Register of qubits to be measured. + /// + /// # Output + /// `Zero` if the $+1$ eigenvalue is observed, and `One` if + /// the $-1$ eigenvalue is observed. + /// + /// # Remarks + /// If the basis array and qubit array are different lengths, then the + /// operation will fail. + @EnableTestingViaName("Test.TargetDefinitions.Measure") + operation Measure (bases : Pauli[], qubits : Qubit[]) : Result { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/R.qs b/src/Simulation/TargetDefinitions/Intrinsic/R.qs new file mode 100644 index 00000000000..8deee174ebb --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/R.qs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the given Pauli axis. + /// + /// # Description + /// \begin{align} + /// R_{\mu}(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_{\mu} / 2}, + /// \end{align} + /// where $\mu \in \{I, X, Y, Z\}$. + /// + /// # Input + /// ## pauli + /// Pauli operator ($\mu$) to be exponentiated to form the rotation. + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// When called with `pauli = PauliI`, this operation applies + /// a *global phase*. This phase can be significant + /// when used with the `Controlled` functor. + @EnableTestingViaName("Test.TargetDefinitions.R") + operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Reset.qs b/src/Simulation/TargetDefinitions/Intrinsic/Reset.qs new file mode 100644 index 00000000000..a8b16345b5e --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Reset.qs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Given a single qubit, measures it and ensures it is in the |0⟩ state + /// such that it can be safely released. + /// + /// # Input + /// ## qubit + /// The qubit whose state is to be reset to $\ket{0}$. + @EnableTestingViaName("Test.TargetDefinitions.Reset") + operation Reset (qubit : Qubit) : Unit { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Rx.qs b/src/Simulation/TargetDefinitions/Intrinsic/Rx.qs new file mode 100644 index 00000000000..20aa42633b7 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Rx.qs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $x$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_x(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_x / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -i\sin \frac{\theta}{2} \\\\ + /// -i\sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliX, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rx") + operation Rx (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Ry.qs b/src/Simulation/TargetDefinitions/Intrinsic/Ry.qs new file mode 100644 index 00000000000..e8df5d1fe88 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Ry.qs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $y$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_y(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_y / 2} = + /// \begin{bmatrix} + /// \cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \\\\ + /// \sin \frac{\theta}{2} & \cos \frac{\theta}{2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliY, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Ry") + operation Ry (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Rz.qs b/src/Simulation/TargetDefinitions/Intrinsic/Rz.qs new file mode 100644 index 00000000000..ca7c2d4d74c --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Rz.qs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies a rotation about the $z$-axis by a given angle. + /// + /// # Description + /// \begin{align} + /// R_z(\theta) \mathrel{:=} + /// e^{-i \theta \sigma_z / 2} = + /// \begin{bmatrix} + /// e^{-i \theta / 2} & 0 \\\\ + /// 0 & e^{i \theta / 2} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## theta + /// Angle about which the qubit is to be rotated. + /// ## qubit + /// Qubit to which the gate should be applied. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// R(PauliZ, theta, qubit); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.Rz") + operation Rz (theta : Double, qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/S.qs b/src/Simulation/TargetDefinitions/Intrinsic/S.qs new file mode 100644 index 00000000000..816c8771b31 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/S.qs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/4 phase gate to a single qubit. + /// + /// # Description + /// \begin{align} + /// S \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & i + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.S") + operation S (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/SWAP.qs b/src/Simulation/TargetDefinitions/Intrinsic/SWAP.qs new file mode 100644 index 00000000000..9b9c80138ed --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/SWAP.qs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the SWAP gate to a pair of qubits. + /// + /// # Description + /// \begin{align} + /// \operatorname{SWAP} \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 & 0 & 0 \\\\ + /// 0 & 0 & 1 & 0 \\\\ + /// 0 & 1 & 0 & 0 \\\\ + /// 0 & 0 & 0 & 1 + /// \end{bmatrix}, + /// \end{align} + /// + /// where rows and columns are ordered as in the quantum concepts guide. + /// + /// # Input + /// ## qubit1 + /// First qubit to be swapped. + /// ## qubit2 + /// Second qubit to be swapped. + /// + /// # Remarks + /// Equivalent to: + /// ```qsharp + /// CNOT(qubit1, qubit2); + /// CNOT(qubit2, qubit1); + /// CNOT(qubit1, qubit2); + /// ``` + @EnableTestingViaName("Test.TargetDefinitions.SWAP") + operation SWAP (qubit1 : Qubit, qubit2 : Qubit) : Unit is Adj + Ctl { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/T.qs b/src/Simulation/TargetDefinitions/Intrinsic/T.qs new file mode 100644 index 00000000000..dc3affe449a --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/T.qs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the π/8 gate to a single qubit. + /// + /// # Description + /// \begin{align} + /// T \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & e^{i \pi / 4} + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.T") + operation T (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/X.qs b/src/Simulation/TargetDefinitions/Intrinsic/X.qs new file mode 100644 index 00000000000..8b5f8feb62b --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/X.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $X$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_x \mathrel{:=} + /// \begin{bmatrix} + /// 0 & 1 \\\\ + /// 1 & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.X") + operation X (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Y.qs b/src/Simulation/TargetDefinitions/Intrinsic/Y.qs new file mode 100644 index 00000000000..92b28478843 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Y.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Y$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_y \mathrel{:=} + /// \begin{bmatrix} + /// 0 & -i \\\\ + /// i & 0 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.Y") + operation Y (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/Intrinsic/Z.qs b/src/Simulation/TargetDefinitions/Intrinsic/Z.qs new file mode 100644 index 00000000000..a05f34c60c8 --- /dev/null +++ b/src/Simulation/TargetDefinitions/Intrinsic/Z.qs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + open Microsoft.Quantum.Diagnostics; + + /// # Summary + /// Applies the Pauli $Z$ gate. + /// + /// # Description + /// \begin{align} + /// \sigma_z \mathrel{:=} + /// \begin{bmatrix} + /// 1 & 0 \\\\ + /// 0 & -1 + /// \end{bmatrix}. + /// \end{align} + /// + /// # Input + /// ## qubit + /// Qubit to which the gate should be applied. + @EnableTestingViaName("Test.TargetDefinitions.Z") + operation Z (qubit : Qubit) : Unit is Adj + Ctl { + body intrinsic; + adjoint self; + } +} \ No newline at end of file diff --git a/src/Simulation/TargetDefinitions/README.md b/src/Simulation/TargetDefinitions/README.md new file mode 100644 index 00000000000..e814502c598 --- /dev/null +++ b/src/Simulation/TargetDefinitions/README.md @@ -0,0 +1,11 @@ +# Target Package Definitions + +## Purpose + +A target package is intended to provide the core functionality of the callables in the Microsoft.Quantum.Intrinsic namespase specialized to a particular hardware or software (simulator) target. Not every target natively supports the same set of callables, so the expected pattern for adapting them to the Q# API is via the package that defines the set of natively supported callabes (defined as `body intrinsic` in Q#) and the set of decompositions in Q# that implemenent the remainder of the API via the subset of native callables. + +## Design + +Each target package is comprised of a subset of `body intrinsic` Q# definitions, drawn from the TargetDefinitions/Intrinsic folder, along with the necessary decomposition implementations from TargetDefinitions/Decompositions folder to sufficiently implement the remainder of the Microsoft.Quantum.Intrinsic API surface. Each intrinsic or decomposed callable is kept in a separate file to allow for easier reuse and recombination across packages. The individual package defines the subset files that should be compiled together into the package via a .props file in the TargetDefinitions/TargetPackages folder. That file acts as an easy reference for understanding which callabes are native to that target and which decompositions each target uses. As support for new targets is added, they can reuse existing intrinsic or decomposition definitions in a new combination and/or introduce new callables (some of which may be internal for use in decompositions only) that correspond to taret-specific capabilities. The goal for any target package is that each callabe that shares a name with a publicly defined API (such as `X` or `Measure`) will have the same signature and API contract even though the details of each implementaiton may vary. That way even if different targets have different capabilities, the core set of Q# gates functions the same across all targets (with allowances for increased complexity or resource utilization in a given decomposition). + +In addition, this folder defines an interfaces package that targets can use to attach their specific implementation of native callables to a runtime. Here, the interfaces package represents the union of all `body intrinsic` Q# callabes across all targets, which each callable having it's own unique API surface. Then the combined interface representing a particular target is a union of the interfaces required to implement the set of native supported callabes on that target. For example, IQSharpCore is the interface that combines the set of specific gate interfaces representing the natively supported gates of the QSharp.Core target, and any target that wants to support execution with the QSharpCore package would need to implement that interface. By implementing multiple interfaces, like our simulator does, a target can support multiple target packages without having to recompile or take a direct dependency on any specific target. Long term, we expect the indirection provided by these interfaces to be part of the code that is auto-generated from the Q# declatation witohut requiring any manual additions to the interfaces package. diff --git a/src/Simulation/TargetDefinitions/TargetPackages/Common.Package.props b/src/Simulation/TargetDefinitions/TargetPackages/Common.Package.props new file mode 100644 index 00000000000..37391e687c1 --- /dev/null +++ b/src/Simulation/TargetDefinitions/TargetPackages/Common.Package.props @@ -0,0 +1,39 @@ + + + + + + + + netstandard2.1 + true + false + false + detailed + + + + Quantum Q# QSharp + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/TargetDefinitions/TargetPackages/QSharpCore.Package.props b/src/Simulation/TargetDefinitions/TargetPackages/QSharpCore.Package.props new file mode 100644 index 00000000000..1f0fc421f2a --- /dev/null +++ b/src/Simulation/TargetDefinitions/TargetPackages/QSharpCore.Package.props @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/TargetDefinitions/TargetPackages/Type1.Package.props b/src/Simulation/TargetDefinitions/TargetPackages/Type1.Package.props new file mode 100644 index 00000000000..c916460dcf4 --- /dev/null +++ b/src/Simulation/TargetDefinitions/TargetPackages/Type1.Package.props @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/TargetDefinitions/TargetPackages/Type2.Package.props b/src/Simulation/TargetDefinitions/TargetPackages/Type2.Package.props new file mode 100644 index 00000000000..05fd378362a --- /dev/null +++ b/src/Simulation/TargetDefinitions/TargetPackages/Type2.Package.props @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj new file mode 100644 index 00000000000..2c079625605 --- /dev/null +++ b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj @@ -0,0 +1,11 @@ + + + + + + Type1 Targeting support for the Q# programming language. + true + + + + diff --git a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj new file mode 100644 index 00000000000..ce3994546d3 --- /dev/null +++ b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj @@ -0,0 +1,11 @@ + + + + + + Type2 Targeting support for the Q# programming language. + true + + + + diff --git a/src/Xunit/Microsoft.Quantum.Xunit.nuspec b/src/Xunit/Microsoft.Quantum.Xunit.nuspec index bfbedede6d9..0e798934212 100644 --- a/src/Xunit/Microsoft.Quantum.Xunit.nuspec +++ b/src/Xunit/Microsoft.Quantum.Xunit.nuspec @@ -22,7 +22,7 @@ - +