├── .cargo
└── config.toml
├── .devcontainer
├── Dockerfile
└── devcontainer.json
├── .gitattributes
├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── feature_request.md
│ └── maintenance_request.md
└── workflows
│ ├── devskim.yml
│ ├── gh-sync.yml
│ └── qdk-sync.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .sscignore
├── AdvantageBenchmark
├── privateBuild
│ ├── .editorconfig
│ ├── Program.cs
│ ├── Quantum.qs
│ ├── advantage.sln
│ ├── host.csproj
│ ├── parseLog.py
│ ├── runTest.ps1
│ └── runTest.sh
├── readme.md
└── releasedBuild
│ ├── advantage.sln
│ ├── host
│ └── host.csproj
│ └── quantum
│ └── quantum.csproj
├── CONTRIBUTING.md
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── NOTICE.txt
├── NuGet.Config
├── README.md
├── SECURITY.md
├── Simulation.sln
├── bootstrap.ps1
├── build
├── .gitignore
├── assets
│ └── qdk-nuget-icon.png
├── build.ps1
├── ci-codecheck.yml
├── ci.yml
├── e2e.yml
├── manifest.ps1
├── pack.ps1
├── prerequisites.ps1
├── set-env.ps1
├── steps-codecheck.yml
├── steps-init.yml
├── steps-wrap-up.yml
├── steps.yml
└── test.ps1
├── cspell.json
├── documentation
├── examples
│ ├── open-systems-concepts.ipynb
│ └── preview-simulators-from-python.ipynb
└── preview-simulators.md
├── global.json
├── omnisharp.json
├── rust-toolchain
└── src
├── Azure
├── Azure.Quantum.Client.Test
│ ├── Authentication
│ │ ├── CredentialFactoryTests.cs
│ │ └── TokenFileCredentialTests.cs
│ ├── Helpers
│ │ └── Problem.cs
│ ├── Tests.Microsoft.Azure.Quantum.Client.csproj
│ └── WorkspaceTest.cs
├── Azure.Quantum.Client
│ ├── Authentication
│ │ ├── CredentialFactory.cs
│ │ ├── DefaultQuantumCredential.cs
│ │ ├── TokenFileContent.cs
│ │ └── TokenFileCredential.cs
│ ├── Exceptions
│ │ ├── AzureQuantumException.cs
│ │ ├── StorageClientException.cs
│ │ └── WorkspaceClientException.cs
│ ├── JobManagement
│ │ ├── CloudJob.cs
│ │ ├── IWorkspace.cs
│ │ ├── ProviderStatusInfo.cs
│ │ ├── QuotaInfo.cs
│ │ ├── TargetStatusInfo.cs
│ │ ├── Workspace.cs
│ │ └── WorkspaceExtensions.cs
│ ├── Machine
│ │ └── QuantumMachineFactory.cs
│ ├── Microsoft.Azure.Quantum.Client.csproj
│ ├── Storage
│ │ ├── IJobStorageHelper.cs
│ │ ├── IStorageHelper.cs
│ │ ├── JobStorageHelper.cs
│ │ ├── JobStorageHelperBase.cs
│ │ ├── LinkedStorageJobHelper.cs
│ │ └── StorageHelper.cs
│ ├── SubmitterFactory.cs
│ └── Utility
│ │ ├── Compression.cs
│ │ ├── Constants.cs
│ │ ├── Ensure.cs
│ │ ├── FileSystem.cs
│ │ ├── IFileSystem.cs
│ │ └── LazyAsync.cs
└── Common
│ ├── AssemblyCommon.props
│ ├── DelaySign.cs
│ ├── StyleCop.ruleset
│ └── stylecop.json
├── Common
└── cmake
│ └── secure_dependencies.cmake
├── Qir
├── .clang-format
├── .clang-tidy
├── .gitignore
├── CommandLineTool
│ ├── Microsoft.Quantum.Qir.CommandLineTool.csproj
│ └── Program.cs
├── Common
│ ├── Externals
│ │ ├── CLI11
│ │ │ └── CLI11.hpp
│ │ ├── catch2
│ │ │ └── catch.hpp
│ │ ├── cgmanifest.json
│ │ └── readme.md
│ └── cmake
│ │ ├── qir_cmake_include.cmake
│ │ └── unit_test_include.cmake
├── LSan.ignore
├── QIR-RT-API-Design-Guidelines.md
├── Runtime
│ ├── .cargo
│ │ └── config.toml
│ ├── build-qir-stdlib.ps1
│ ├── prerequisites.ps1
│ ├── stdlib
│ │ ├── Cargo.toml
│ │ ├── build.rs
│ │ └── src
│ │ │ └── lib.rs
│ └── test-qir-stdlib.ps1
├── Samples
│ ├── CMakeLists.txt
│ ├── StandaloneInputReference
│ │ ├── .clang-tidy
│ │ ├── CMakeLists.txt
│ │ ├── qir-driver.cpp
│ │ ├── qsharp
│ │ │ ├── qir-standalone-input-reference.csproj
│ │ │ └── qir-standalone-input-reference.qs
│ │ └── readme.md
│ ├── build-qir-samples.ps1
│ └── test-qir-samples.ps1
├── Tests
│ ├── CMakeLists.txt
│ ├── FullstateSimulator
│ │ ├── CMakeLists.txt
│ │ ├── FullstateSimulatorTests.cpp
│ │ └── qsharp
│ │ │ ├── qir-test-simulator.csproj
│ │ │ └── qir-test-simulator.qs
│ ├── QIR-dynamic
│ │ ├── CMakeLists.txt
│ │ ├── qir-driver.cpp
│ │ └── qsharp
│ │ │ ├── qir-test-assert.qs
│ │ │ ├── qir-test-dump.qs
│ │ │ ├── qir-test-random.csproj
│ │ │ └── qir-test-random.qs
│ ├── QIR-static
│ │ ├── CMakeLists.txt
│ │ ├── FloatUtils.hpp
│ │ ├── qir-driver.cpp
│ │ ├── qir-test-math.cpp
│ │ ├── qir-test-other.cpp
│ │ ├── qir-test-strings.cpp
│ │ └── qsharp
│ │ │ ├── Math.qs
│ │ │ ├── qir-gen.csproj
│ │ │ ├── qir-test-arrays.qs
│ │ │ ├── qir-test-functors.qs
│ │ │ ├── qir-test-math.qs
│ │ │ ├── qir-test-other.qs
│ │ │ ├── qir-test-output.qs
│ │ │ ├── qir-test-partials.qs
│ │ │ ├── qir-test-qubits-results.qs
│ │ │ └── qir-test-strings.qs
│ ├── Tools
│ │ ├── QirDriverGeneratorTests.cs
│ │ ├── QirExecutableGeneratorTests.cs
│ │ ├── QirExecutableTests.cs
│ │ ├── TestCases
│ │ │ └── FullStateDriverGenerator
│ │ │ │ ├── UseBoolArg.cpp
│ │ │ │ ├── UseBoolArrayArg.cpp
│ │ │ │ ├── UseDoubleArg.cpp
│ │ │ │ ├── UseDoubleArrayArg.cpp
│ │ │ │ ├── UseIntegerArg.cpp
│ │ │ │ ├── UseIntegerArrayArg.cpp
│ │ │ │ ├── UseMiscArgs.cpp
│ │ │ │ ├── UseNoArgs.cpp
│ │ │ │ ├── UsePauliArg.cpp
│ │ │ │ ├── UsePauliArrayArg.cpp
│ │ │ │ ├── UseRangeArg.cpp
│ │ │ │ ├── UseRangeArrayArg.cpp
│ │ │ │ ├── UseResultArg.cpp
│ │ │ │ ├── UseResultArrayArg.cpp
│ │ │ │ └── UseStringArg.cpp
│ │ ├── Tests.Microsoft.Quantum.Qir.Runtime.Tools.csproj
│ │ └── Util.cs
│ ├── build-qir-tests.ps1
│ └── test-qir-tests.ps1
├── Tools
│ ├── Driver
│ │ ├── IQirDriverGenerator.cs
│ │ ├── IQirSimulatorInitializer.cs
│ │ ├── QirCppDriver.cs
│ │ ├── QirCppDriver.tt
│ │ ├── QirCppDriverEx.cs
│ │ ├── QirCppDriverGenerator.cs
│ │ ├── QirCppInterop.cs
│ │ ├── QirFullStateDriverGenerator.cs
│ │ └── QirFullStateSimulatorInitializer.cs
│ ├── EntryPointOperationLoader.cs
│ ├── Executable
│ │ ├── ClangClient.cs
│ │ ├── IClangClient.cs
│ │ ├── IQirExecutable.cs
│ │ ├── IQirExecutableGenerator.cs
│ │ ├── IQirExecutableRunner.cs
│ │ ├── QirExecutable.cs
│ │ ├── QirExecutableGenerator.cs
│ │ ├── QirExecutableRunner.cs
│ │ └── QirFullStateExecutable.cs
│ ├── Externals
│ │ └── CLI11
│ │ │ └── CLI11.hpp
│ ├── Microsoft.Quantum.Qir.Runtime.Tools.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QirTools.cs
│ └── README.md
├── UBSan.ignore
├── check-sources-formatted.ps1
└── qir-utils.ps1
├── README.md
├── Simulation
├── AutoSubstitution.Integration.Tests
│ ├── Integration.cs
│ ├── Integration.qs
│ └── Tests.Microsoft.Quantum.AutoSubstitution.Integration.csproj
├── AutoSubstitution.Tests
│ ├── CodeGenerationTests.cs
│ ├── TestFiles
│ │ ├── Core.qs
│ │ ├── FailAlternativeDoesNotExist.qs
│ │ ├── FailDifferentSignatures.qs
│ │ ├── FailDifferentSpecializationKinds.qs
│ │ ├── FailNoNamespace.qs
│ │ ├── Success.cs_
│ │ ├── Success.qs
│ │ ├── SuccessA.cs_
│ │ ├── SuccessA.qs
│ │ ├── SuccessC.cs_
│ │ ├── SuccessC.qs
│ │ ├── SuccessCA.cs_
│ │ └── SuccessCA.qs
│ └── Tests.Microsoft.Quantum.AutoSubstitution.csproj
├── AutoSubstitution
│ ├── CodeGenerator.cs
│ ├── Microsoft.Quantum.AutoSubstitution.csproj
│ ├── Microsoft.Quantum.AutoSubstitution.props
│ ├── RewriteStep.cs
│ └── Substitution.qs
├── Common
│ ├── AssemblyCommon.props
│ ├── AssemblyInfo.cs
│ ├── DebugSymbols.props
│ ├── DelaySign.cs
│ ├── DelaySign.fs
│ ├── Exceptions
│ │ ├── NotDistinctQubits.cs
│ │ ├── NotEnoughQubits.cs
│ │ ├── ReleasedQubitsAreNotInZeroState.cs
│ │ └── TranslationException.cs
│ ├── Factory.cs
│ ├── IQuantumProcessor.cs
│ ├── IQubitManager.cs
│ ├── Microsoft.Quantum.Simulation.Common.csproj
│ ├── OperationException.cs
│ ├── PortablePDBReader.cs
│ ├── QuantumProcessorBase.cs
│ ├── QubitManager.cs
│ ├── Simulators.Dev.props
│ ├── Simulators.Test.props
│ └── Utils.cs
├── Core
│ ├── AbstractCallable.cs
│ ├── Argument.cs
│ ├── ArgumentType.cs
│ ├── ArgumentValue.cs
│ ├── Attributes.cs
│ ├── Default.cs
│ ├── EntryPointInfo.cs
│ ├── Extensions.cs
│ ├── Functions
│ │ ├── Function.cs
│ │ └── FunctionPartial.cs
│ ├── Generics
│ │ ├── Adjoint.cs
│ │ ├── Controlled.cs
│ │ ├── GenericCallable.cs
│ │ ├── GenericPartial.cs
│ │ ├── PartialMapper.cs
│ │ └── Unitary.cs
│ ├── GetQubits.cs
│ ├── IData.cs
│ ├── IOperationFactory.cs
│ ├── IgnorableAssert.cs
│ ├── Microsoft.Quantum.Runtime.Core.csproj
│ ├── OperationFunctor.cs
│ ├── Operations
│ │ ├── Adjoint.cs
│ │ ├── Controlled.cs
│ │ ├── Operation.cs
│ │ ├── OperationPartial.cs
│ │ └── Unitary.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QArray.cs
│ ├── QRange.cs
│ ├── QTuple.cs
│ ├── QVoid.cs
│ ├── Qubit.cs
│ ├── QubitsExtractor.cs
│ ├── RuntimeMetadata.cs
│ ├── Submitters
│ │ ├── IQSharpSubmitter.cs
│ │ ├── IQirSubmitter.cs
│ │ ├── IQuantumMachine.cs
│ │ ├── IQuantumMachineExecutionContext.cs
│ │ ├── IQuantumMachineJob.cs
│ │ ├── IQuantumMachineOutput.cs
│ │ ├── IQuantumMachineSubmissionContext.cs
│ │ └── SubmissionOptions.cs
│ ├── TypeExtensions.cs
│ ├── Types.cs
│ └── Udts
│ │ ├── UDTBase.cs
│ │ ├── UDTPartial.cs
│ │ └── UdtFactory.cs
├── EntryPointDriver.Tests
│ ├── Core.qs
│ ├── Intrinsic.qs
│ ├── Tests.Microsoft.Quantum.EntryPointDriver.fsproj
│ ├── Tests.fs
│ └── Tests.qs
├── EntryPointDriver
│ ├── Azure
│ │ ├── Azure.cs
│ │ ├── AzureSettings.cs
│ │ ├── GenerateAzurePayloadSettings.cs
│ │ ├── OutputFormat.cs
│ │ ├── QSharpSubmission.cs
│ │ └── QirSubmission.cs
│ ├── Driver.cs
│ ├── DriverSettings.cs
│ ├── IEntryPoint.cs
│ ├── Maybe.cs
│ ├── Microsoft.Quantum.EntryPointDriver.csproj
│ ├── Mock
│ │ ├── ErrorQuantumMachine.cs
│ │ ├── ExampleJob.cs
│ │ ├── NoOpQirSubmitter.cs
│ │ ├── NoOpQuantumMachine.cs
│ │ └── NoOpSubmitter.cs
│ ├── OptionInfo.cs
│ ├── Options.cs
│ ├── Parsers.cs
│ ├── Simulation.cs
│ └── Validation.cs
├── Native
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── advantage_44_4.log
│ ├── argmaxnrm2_test
│ ├── bititerator_test
│ ├── bitops_test
│ ├── build-native-simulator.ps1
│ ├── capi_test
│ ├── codegen
│ │ ├── codegen_fma.py
│ │ ├── codegen_test.cpp
│ │ ├── generate.ps1
│ │ └── generate.sh
│ ├── cpuid_test
│ ├── diagmatrix_test
│ ├── doCopy.ps1
│ ├── factory_test
│ ├── linux
│ │ ├── libomp.so
│ │ └── libomp.so.5
│ ├── local_test
│ ├── openmp_test
│ ├── osx
│ │ ├── include
│ │ │ ├── omp-tools.h
│ │ │ ├── omp.h
│ │ │ └── ompt.h
│ │ └── libomp.dylib
│ ├── parseLog.py
│ ├── prerequisites.ps1
│ ├── src
│ │ ├── .clang-format
│ │ ├── CMakeLists.txt
│ │ ├── SafeInt.hpp
│ │ ├── catch2
│ │ │ ├── catch.hpp
│ │ │ ├── catch_driver.cpp
│ │ │ ├── cgmanifest.json
│ │ │ └── readme.md
│ │ ├── config.hpp
│ │ ├── config.hpp.in
│ │ ├── external
│ │ │ ├── avx
│ │ │ │ ├── kernel1.hpp
│ │ │ │ ├── kernel2.hpp
│ │ │ │ ├── kernel3.hpp
│ │ │ │ ├── kernel4.hpp
│ │ │ │ ├── kernel5.hpp
│ │ │ │ ├── kernel6.hpp
│ │ │ │ ├── kernel7.hpp
│ │ │ │ └── kernels.hpp
│ │ │ ├── avx2
│ │ │ │ ├── kernel1.hpp
│ │ │ │ ├── kernel2.hpp
│ │ │ │ ├── kernel3.hpp
│ │ │ │ ├── kernel4.hpp
│ │ │ │ ├── kernel5.hpp
│ │ │ │ ├── kernel6.hpp
│ │ │ │ ├── kernel7.hpp
│ │ │ │ └── kernels.hpp
│ │ │ ├── avx512
│ │ │ │ ├── kernel1.hpp
│ │ │ │ ├── kernel2.hpp
│ │ │ │ ├── kernel3.hpp
│ │ │ │ ├── kernel4.hpp
│ │ │ │ ├── kernel5.hpp
│ │ │ │ ├── kernel6.hpp
│ │ │ │ ├── kernel7.hpp
│ │ │ │ └── kernels.hpp
│ │ │ ├── cintrin.hpp
│ │ │ ├── fused.hpp
│ │ │ ├── fusion.hpp
│ │ │ ├── nointrin
│ │ │ │ ├── kernel1.hpp
│ │ │ │ ├── kernel2.hpp
│ │ │ │ ├── kernel3.hpp
│ │ │ │ ├── kernel4.hpp
│ │ │ │ ├── kernel5.hpp
│ │ │ │ ├── kernel6.hpp
│ │ │ │ ├── kernel7.hpp
│ │ │ │ ├── kerneldefs.hpp
│ │ │ │ ├── kernels.cpp
│ │ │ │ ├── kernels.hpp
│ │ │ │ └── kerneltest.hpp
│ │ │ └── timing.hpp
│ │ ├── simulator
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Project.sln
│ │ │ ├── capi.cpp
│ │ │ ├── capi.hpp
│ │ │ ├── capi_test.cpp
│ │ │ ├── dbw_test.cpp
│ │ │ ├── factory.cpp
│ │ │ ├── factory.hpp
│ │ │ ├── factory_test.cpp
│ │ │ ├── gates.hpp
│ │ │ ├── kernels.hpp
│ │ │ ├── local_test.cpp
│ │ │ ├── qir.cpp
│ │ │ ├── qir.hpp
│ │ │ ├── simulator.cpp
│ │ │ ├── simulator.hpp
│ │ │ ├── simulatoravx.cpp
│ │ │ ├── simulatoravx2.cpp
│ │ │ ├── simulatoravx512.cpp
│ │ │ ├── simulatorinterface.hpp
│ │ │ ├── types.hpp
│ │ │ └── wavefunction.hpp
│ │ ├── util
│ │ │ ├── CMakeLists.txt
│ │ │ ├── alignedalloc.hpp
│ │ │ ├── argmaxnrm2.hpp
│ │ │ ├── argmaxnrm2_test.cpp
│ │ │ ├── bititerator.hpp
│ │ │ ├── bititerator_test.cpp
│ │ │ ├── bitops.hpp
│ │ │ ├── bitops_test.cpp
│ │ │ ├── cpuid.hpp
│ │ │ ├── cpuid_test.cpp
│ │ │ ├── diagmatrix.hpp
│ │ │ ├── diagmatrix_test.cpp
│ │ │ ├── openmp.cpp
│ │ │ ├── openmp.hpp
│ │ │ ├── openmp_test.cpp
│ │ │ ├── splitinterval.hpp
│ │ │ ├── tinymatrix.hpp
│ │ │ └── tinymatrix_test.cpp
│ │ ├── version.hpp
│ │ └── version.hpp.in
│ ├── stats.xlsx
│ ├── test-native-simulator.ps1
│ ├── tinymatrix_test
│ └── win10
│ │ └── libomp140.x86_64.dll
├── NativeSparseSimulator
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── CSharpIntegrationTests.cpp
│ ├── SparseSimulator.h
│ ├── SparseSimulatorTests.cpp
│ ├── TestHelpers.cpp
│ ├── TestHelpers.hpp
│ ├── basic_quantum_state.hpp
│ ├── build.ps1
│ ├── capi.cpp
│ ├── capi.hpp
│ ├── factory.cpp
│ ├── factory.hpp
│ ├── gates.h
│ ├── quantum_state.hpp
│ ├── test.ps1
│ └── types.h
├── QCTraceSimulator.Tests
│ ├── App.config
│ ├── BasicTests.cs
│ ├── CircuitTests.cs
│ ├── Circuits
│ │ ├── CCXGateCount.qs
│ │ ├── CatState.qs
│ │ ├── CatStateCore.qs
│ │ ├── DistinctQubitTest.qs
│ │ ├── MeasurementTrackingTests.qs
│ │ ├── MetricsCalculationTests.qs
│ │ └── UseReleasedQubitsTest.qs
│ ├── PrimitiveOperationsCounterTest.cs
│ ├── Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj
│ └── UtilsTests.cs
├── QCTraceSimulator
│ ├── CallGraphEdge.cs
│ ├── DepthCounter.cs
│ ├── DistinctInputsChecker.cs
│ ├── Exceptions.cs
│ ├── GateCounter.cs
│ ├── ICSVColumns.cs
│ ├── ICallGraphStatistics.cs
│ ├── IDoubleStatistic.cs
│ ├── IQCTraceSimulatorListener.cs
│ ├── InvalidatedQubitsUseChecker.cs
│ ├── MeasurementConstraint.cs
│ ├── Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj
│ ├── MinMaxStatistic.cs
│ ├── MomentsStatistic.cs
│ ├── MultivariableRecord.cs
│ ├── QCTraceSimulatorCore.cs
│ ├── QubitAvailabilityTimeTracker.cs
│ ├── QubitConstraint.cs
│ ├── QubitManagerRestrictedReuse.cs
│ ├── QubitMetrics.cs
│ ├── SortedQubitPool.cs
│ ├── StatisticsCollector.cs
│ ├── TraceableQubit.cs
│ ├── TraceableQubitFactory.cs
│ ├── TraceableQubitManager.cs
│ ├── Utils.cs
│ └── WidthCounter.cs
├── QSharpCore
│ ├── Intrinsic.cs
│ ├── Measurement.cs
│ ├── Microsoft.Quantum.QSharp.Core.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── QuantumProcessor
│ │ ├── Allocate.cs
│ │ ├── Assert.cs
│ │ ├── AssertProb.cs
│ │ ├── Borrow.cs
│ │ ├── ClassicalControl.cs
│ │ ├── Dump.cs
│ │ ├── Exp.cs
│ │ ├── ExpFrac.cs
│ │ ├── H.cs
│ │ ├── M.cs
│ │ ├── Measure.cs
│ │ ├── QuantumProcessorDispatcher.cs
│ │ ├── R.cs
│ │ ├── R1.cs
│ │ ├── R1Frac.cs
│ │ ├── RFrac.cs
│ │ ├── Random.cs
│ │ ├── Release.cs
│ │ ├── Reset.cs
│ │ ├── Return.cs
│ │ ├── S.cs
│ │ ├── SWAP.cs
│ │ ├── T.cs
│ │ ├── X.cs
│ │ ├── Y.cs
│ │ └── Z.cs
├── QSharpFoundation.Tests
│ ├── Microsoft.Quantum.Bitwise.qs
│ └── Tests.Microsoft.Quantum.QSharp.Foundation.csproj
├── QSharpFoundation
│ ├── Arrays
│ │ ├── Empty.cs
│ │ ├── Empty.qs
│ │ └── Enumeration.qs
│ ├── Assert.qs
│ ├── Bitwise
│ │ ├── Bitwise.cs
│ │ ├── Bitwise.qs
│ │ └── Deprecated.qs
│ ├── Canon
│ │ └── NoOp.qs
│ ├── ClassicalControl.qs
│ ├── Convert
│ │ ├── Convert.cs
│ │ ├── Convert.qs
│ │ └── Deprecated.qs
│ ├── Core.cs
│ ├── Core.qs
│ ├── Diagnostics
│ │ ├── Assert.qs
│ │ ├── AssertAllZero.qs
│ │ ├── AssertQubit.qs
│ │ ├── Dump.qs
│ │ ├── Facts.qs
│ │ └── UnitTests.qs
│ ├── Environment.qs
│ ├── Estimation
│ │ ├── AccountForEstimates.qs
│ │ └── Caching.qs
│ ├── Math
│ │ ├── Constants.qs
│ │ ├── Deprecated.qs
│ │ ├── FloatingPoint.qs
│ │ ├── Math.cs
│ │ ├── Math.qs
│ │ ├── Trig.qs
│ │ └── Types.qs
│ ├── Message.qs
│ ├── Microsoft.Quantum.QSharp.Foundation.csproj
│ ├── Random.qs
│ ├── Random
│ │ ├── Convienence.qs
│ │ ├── Internal.qs
│ │ ├── Intrinsic.qs
│ │ ├── Normal.qs
│ │ ├── Properties
│ │ │ └── NamespaceInfo.qs
│ │ ├── Types.qs
│ │ └── Uniform.qs
│ ├── Statements
│ │ ├── Allocate.cs
│ │ ├── Borrow.cs
│ │ ├── Release.cs
│ │ └── Return.cs
│ └── Targeting.qs
├── README.md
├── Simulators.Tests
│ ├── App.config
│ ├── Circuits
│ │ ├── Arrays.qs
│ │ ├── AssertEqual.cs
│ │ ├── AssertEqual.qs
│ │ ├── BitOperations.qs
│ │ ├── Bug1514.qs
│ │ ├── Bug2248.qs
│ │ ├── Bug2469.qs
│ │ ├── Bug3059.qs
│ │ ├── Bug3758.qs
│ │ ├── CallableInterfacesTest.qs
│ │ ├── ClassicalRotationsTest.qs
│ │ ├── ClosedType.qs
│ │ ├── ConditionalExpression.qs
│ │ ├── Convert.qs
│ │ ├── CoreOperations.qs
│ │ ├── Default.qs
│ │ ├── ExpTest.qs
│ │ ├── Fail.qs
│ │ ├── Functions.qs
│ │ ├── Generics.qs
│ │ ├── GetAvailableTest.qs
│ │ ├── Issue132.qs
│ │ ├── Issue76.qs
│ │ ├── JointMeasureTest.qs
│ │ ├── MeasureEachZTest.qs
│ │ ├── MemberNames.qs
│ │ ├── NamedItems.qs
│ │ ├── Namespaces.qs
│ │ ├── NativeOperations.cs
│ │ ├── NativeOperations.qs
│ │ ├── PrimitiveEquivalences.qs
│ │ ├── Recursion.qs
│ │ ├── RepeatUntilSuccess.qs
│ │ ├── RuntimeMetadataTest.qs
│ │ ├── SetQubit.qs
│ │ ├── StartOperation.qs
│ │ ├── SwapTest.qs
│ │ ├── TeleportTest.qs
│ │ ├── Tuples.qs
│ │ ├── UnitTests.qs
│ │ ├── UserDefinedTypes.qs
│ │ ├── VerifyUnitary.qs
│ │ └── bug3223.qs
│ ├── CoreTests.cs
│ ├── DebuggingToolsTests.cs
│ ├── DiagnosticsWrappers.qs
│ ├── GenericsTests.cs
│ ├── GetQubitsTests.cs
│ ├── GlobalUsings.cs
│ ├── NativeOperationsTests.cs
│ ├── OpenSystemsSimulatorTests
│ │ ├── NativeInterfaceTests.cs
│ │ └── TestOperations.qs
│ ├── OperationsTestHelper.cs
│ ├── OperationsTestHelperSimSupport.cs
│ ├── PartialMapperTests.cs
│ ├── PrimitivesExtensionsTests.cs
│ ├── QArrayTests.cs
│ ├── QCTraceSimulatorPrimitivesTests.cs
│ ├── QCTraceSimulatorPrimitivesTests
│ │ ├── InterfaceImpl.qs
│ │ ├── OneQubitOperationsTests.qs
│ │ ├── ThreePlusQubitOperationsTests.qs
│ │ └── TwoQubitOperationsTests.qs
│ ├── QTupleTests.cs
│ ├── QuantumSimulatorTests
│ │ ├── BasicTests.cs
│ │ ├── CircuitsTests.cs
│ │ ├── QubitReleaseTest.cs
│ │ └── VerifyGates.cs
│ ├── QuantumTestSuite.cs
│ ├── QuantumTestSuite
│ │ ├── AssertEqualInPlace.qs
│ │ ├── AssertProbAndCliffordOneQubitTest.qs
│ │ ├── AssertProbAndMeasureOneQubitTest.qs
│ │ ├── AssertProbMultiQubit.qs
│ │ ├── AssertProbOneQubit.qs
│ │ ├── AssertQubitUnitary.qs
│ │ ├── AssertState.qs
│ │ ├── AssertUnitary.qs
│ │ ├── Complex.qs
│ │ ├── Config.qs
│ │ ├── ControlledOperationTester.qs
│ │ ├── ControlledOperationsTestUtils.qs
│ │ ├── IterateThroughCartesianProduct.qs
│ │ ├── JointOneQubitTests.qs
│ │ ├── KnownIssues.qs
│ │ ├── LinearAlgebra.qs
│ │ ├── ManyControlQubitsTest.qs
│ │ ├── Math.qs
│ │ ├── Matrices.qs
│ │ ├── OneQubitTestList.qs
│ │ ├── OneQubitUnitaries.qs
│ │ ├── PauliExpectation.qs
│ │ ├── SelfTests.qs
│ │ ├── TestSuiteCalculations.nb
│ │ ├── ThreeQubitUnitaries.qs
│ │ └── TwoQubitUnitaries.qs
│ ├── QubitManagerTests.cs
│ ├── RangeTests.cs
│ ├── RuntimeMetadataTests.cs
│ ├── SerializationTests
│ │ ├── GeneratorSerializationTests.cs
│ │ ├── NoiseModelSerializationTests.cs
│ │ ├── ProcessSerializationTests.cs
│ │ ├── SerializationExtensions.cs
│ │ └── StateSerializationTests.cs
│ ├── SimulatorBaseTests.cs
│ ├── StackTraceTests.cs
│ ├── StartOperationTests.cs
│ ├── TestProjects
│ │ ├── Directory.Build.props
│ │ ├── IntrinsicTests
│ │ │ ├── Arrays
│ │ │ │ └── Tests.qs
│ │ │ ├── Bitwise
│ │ │ │ └── Tests.qs
│ │ │ ├── Convert
│ │ │ │ └── Tests.qs
│ │ │ ├── IntrinsicTests.csproj
│ │ │ ├── Math
│ │ │ │ └── Tests.qs
│ │ │ ├── Random
│ │ │ │ └── Tests.qs
│ │ │ └── Utils.qs
│ │ ├── IonQExe
│ │ │ ├── IonQExe.csproj
│ │ │ ├── IonQSimulation.qs
│ │ │ └── MeasurementSupportTests.qs
│ │ ├── Library with Spaces
│ │ │ ├── Library with Spaces.csproj
│ │ │ └── Library.qs
│ │ ├── Library1
│ │ │ ├── Library.qs
│ │ │ └── Library1.csproj
│ │ ├── Library2
│ │ │ ├── Library.qs
│ │ │ └── Library2.csproj
│ │ ├── QCIExe
│ │ │ ├── ClassicallyControlledSupportTests.qs
│ │ │ ├── MeasurementSupportTests.qs
│ │ │ ├── QCIExe.csproj
│ │ │ └── QCISimulation.qs
│ │ ├── QSharpExe
│ │ │ ├── Main.qs
│ │ │ └── QSharpExe.csproj
│ │ ├── QirExe
│ │ │ ├── Main.qs
│ │ │ └── QirExe.csproj
│ │ ├── QuantinuumExe
│ │ │ ├── ClassicallyControlledSupportTests.qs
│ │ │ ├── MeasurementSupportTests.qs
│ │ │ ├── QuantinuumExe.csproj
│ │ │ └── QuantinuumSimulation.qs
│ │ ├── TargetedExe
│ │ │ ├── Program.qs
│ │ │ └── TargetedExe.csproj
│ │ └── UnitTests
│ │ │ ├── Facts.qs
│ │ │ ├── Hello.qs
│ │ │ ├── SpaceTests.qs
│ │ │ ├── SparseSimulator.qs
│ │ │ ├── TestNameTests.qs
│ │ │ └── UnitTests.csproj
│ ├── Tests.Microsoft.Quantum.Simulators.csproj
│ ├── ToffoliSimulatorTests.cs
│ ├── TracerHelper.cs
│ ├── TrivialSimulator.cs
│ └── TypeExtensionsTest.cs
├── Simulators.Type1.Tests
│ ├── App.config
│ ├── OperationsTestHelperSimSupport.cs
│ └── Tests.Microsoft.Quantum.Simulators.Type1.csproj
├── Simulators.Type2.Tests
│ ├── App.config
│ ├── OperationsTestHelperSimSupport.cs
│ └── Tests.Microsoft.Quantum.Simulators.Type2.csproj
├── Simulators.Type3.Tests
│ ├── App.config
│ ├── OperationsTestHelperSimSupport.cs
│ └── Tests.Microsoft.Quantum.Simulators.Type3.csproj
├── Simulators.Type4.Tests
│ ├── App.config
│ ├── OperationsTestHelperSimSupport.cs
│ └── Tests.Microsoft.Quantum.Simulators.Type4.csproj
├── Simulators
│ ├── .gitignore
│ ├── CommonNativeSimulator
│ │ ├── ApplyControlledX.cs
│ │ ├── ApplyControlledZ.cs
│ │ ├── ApplyUncontrolledH.cs
│ │ ├── ApplyUncontrolledRx.cs
│ │ ├── ApplyUncontrolledRxx.cs
│ │ ├── ApplyUncontrolledRy.cs
│ │ ├── ApplyUncontrolledRyy.cs
│ │ ├── ApplyUncontrolledRz.cs
│ │ ├── ApplyUncontrolledRzz.cs
│ │ ├── ApplyUncontrolledS.cs
│ │ ├── ApplyUncontrolledSAdj.cs
│ │ ├── ApplyUncontrolledSWAP.cs
│ │ ├── ApplyUncontrolledT.cs
│ │ ├── ApplyUncontrolledTAdj.cs
│ │ ├── ApplyUncontrolledX.cs
│ │ ├── ApplyUncontrolledY.cs
│ │ ├── ApplyUncontrolledZ.cs
│ │ ├── Assert.cs
│ │ ├── AssertProb.cs
│ │ ├── CommonNativeSimulator.cs
│ │ ├── DisplayableState.cs
│ │ ├── Dump.cs
│ │ ├── Exp.cs
│ │ ├── Extensions.cs
│ │ ├── H.cs
│ │ ├── MZ.cs
│ │ ├── Measure.cs
│ │ ├── NativeWrappers.cs
│ │ ├── Qubit.cs
│ │ ├── QubitManager.cs
│ │ ├── R.cs
│ │ ├── Reset.cs
│ │ ├── Rx.cs
│ │ ├── Ry.cs
│ │ ├── Rz.cs
│ │ ├── S.cs
│ │ ├── SWAP.cs
│ │ ├── SimulatorBase.cs
│ │ ├── StackTrace.cs
│ │ ├── T.cs
│ │ ├── X.cs
│ │ ├── Y.cs
│ │ └── Z.cs
│ ├── FindNuspecReferences.ps1
│ ├── GlobalUsings.cs
│ ├── Microsoft.Quantum.Simulators.csproj
│ ├── Microsoft.Quantum.Simulators.nuspec.template
│ ├── OpenSystemsSimulator
│ │ ├── ContinuousTimeOperations.cs
│ │ ├── DataModel
│ │ │ ├── ChpDecomposition.cs
│ │ │ ├── ComplexArrayConverter.cs
│ │ │ ├── DelegatedConverter.cs
│ │ │ ├── Extensions.cs
│ │ │ ├── Generator.cs
│ │ │ ├── Instrument.cs
│ │ │ ├── NoiseModel.cs
│ │ │ ├── Process.cs
│ │ │ ├── README.md
│ │ │ ├── State.cs
│ │ │ └── StateConverter.cs
│ │ ├── Decompositions
│ │ │ ├── ApplyWithLessControls.qs
│ │ │ ├── ControlledH.qs
│ │ │ ├── IntrinsicInterface.qs
│ │ │ ├── NativeInterface.qs
│ │ │ ├── README.md
│ │ │ └── Utils.qs
│ │ ├── Diagnostics.cs
│ │ ├── IsExternalInit.cs
│ │ ├── NativeImplementations.cs
│ │ ├── NativeInterface.cs
│ │ ├── OpenSystemsSimulator.cs
│ │ ├── QubitManager.cs
│ │ └── README.md
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QCTraceSimulator
│ │ ├── Circuits
│ │ │ ├── AndLadder.qs
│ │ │ ├── ApplyByIndex.qs
│ │ │ ├── CCX.qs
│ │ │ ├── CCZ.qs
│ │ │ ├── CCminusIX.qs
│ │ │ ├── CCminusIZ.qs
│ │ │ ├── CZ.qs
│ │ │ ├── ControlledH.qs
│ │ │ ├── ControlledR.qs
│ │ │ ├── ControlledR1.qs
│ │ │ ├── ControlledR1Frac.qs
│ │ │ ├── ControlledRFrac.qs
│ │ │ ├── ControlledRZ.qs
│ │ │ ├── ControlledRZFrac.qs
│ │ │ ├── ControlledSWAP.qs
│ │ │ ├── ControlledT.qs
│ │ │ ├── ControlledTPower.qs
│ │ │ ├── ControlledTS.qs
│ │ │ ├── ExpFracZZ.qs
│ │ │ ├── ExpFracZZZ.qs
│ │ │ ├── ExpZZ.qs
│ │ │ ├── FailOn.qs
│ │ │ ├── IndiciesOfNonIdentity.qs
│ │ │ ├── Interface.qs
│ │ │ ├── InternalOperations.qs
│ │ │ ├── Mod.qs
│ │ │ ├── MultiCX.qs
│ │ │ ├── MultiControlledFromOpAndSinglyCtrldOp.qs
│ │ │ ├── MultiControlledMultiNot.qs
│ │ │ ├── MultiControlledU.qs
│ │ │ ├── MultiPauliFlip.qs
│ │ │ ├── PauliArrayByIndex.qs
│ │ │ ├── PauliXFlip.qs
│ │ │ ├── PauliZFlip.qs
│ │ │ ├── Primitive.CCNOT.qs
│ │ │ ├── Primitive.CNOT.qs
│ │ │ ├── Primitive.Exp.qs
│ │ │ ├── Primitive.ExpFrac.qs
│ │ │ ├── Primitive.H.qs
│ │ │ ├── Primitive.HY.qs
│ │ │ ├── Primitive.IsingXX.qs
│ │ │ ├── Primitive.IsingYY.qs
│ │ │ ├── Primitive.IsingZZ.qs
│ │ │ ├── Primitive.MultiX.qs
│ │ │ ├── Primitive.R.qs
│ │ │ ├── Primitive.R1.qs
│ │ │ ├── Primitive.R1Frac.qs
│ │ │ ├── Primitive.RFrac.qs
│ │ │ ├── Primitive.Rx.qs
│ │ │ ├── Primitive.Ry.qs
│ │ │ ├── Primitive.Rz.qs
│ │ │ ├── Primitive.S.qs
│ │ │ ├── Primitive.SWAP.qs
│ │ │ ├── Primitive.T.qs
│ │ │ ├── Primitive.X.qs
│ │ │ ├── Primitive.Y.qs
│ │ │ ├── Primitive.Z.qs
│ │ │ └── ReducedForm.qs
│ │ ├── Docs
│ │ │ └── Width and Depth in the Tracer.docx
│ │ ├── InterfaceUtils.cs
│ │ ├── QCTraceSimulator.Diagnostics.Dump.cs
│ │ ├── QCTraceSimulator.Interface.CX.cs
│ │ ├── QCTraceSimulator.Interface.Clifford.cs
│ │ ├── QCTraceSimulator.Interface.ForceMeasure.cs
│ │ ├── QCTraceSimulator.Interface.R.cs
│ │ ├── QCTraceSimulator.Interface.RFrac.cs
│ │ ├── QCTraceSimulator.Primitive.Allocate.cs
│ │ ├── QCTraceSimulator.Primitive.Assert.cs
│ │ ├── QCTraceSimulator.Primitive.AssertProb.cs
│ │ ├── QCTraceSimulator.Primitive.Borrow.cs
│ │ ├── QCTraceSimulator.Primitive.Measure.cs
│ │ ├── QCTraceSimulator.Primitive.Release.cs
│ │ ├── QCTraceSimulator.Primitive.Return.cs
│ │ ├── QCTraceSimulator.Primitive.random.cs
│ │ ├── QCTraceSimulator.cs
│ │ ├── QCTraceSimulatorImpl.cs
│ │ └── Utils.cs
│ ├── QuantumSimulator
│ │ ├── Dump.cs
│ │ ├── NativeImports.cs
│ │ ├── NativeWrappers.cs
│ │ └── QuantumSimulator.cs
│ ├── SparseSimulator
│ │ ├── Dump.cs
│ │ ├── NativeImports.cs
│ │ ├── NativeWrappers.cs
│ │ └── SparseSimulator.cs
│ └── ToffoliSimulator
│ │ ├── Assert.cs
│ │ ├── AssertProb.cs
│ │ ├── Dump.cs
│ │ ├── Exp.cs
│ │ ├── Extensions.cs
│ │ ├── H.cs
│ │ ├── Measure.cs
│ │ ├── R.cs
│ │ ├── S.cs
│ │ ├── T.cs
│ │ ├── ToffoliSimulator.cs
│ │ ├── X.cs
│ │ ├── Y.cs
│ │ └── Z.cs
├── TargetDefinitions
│ ├── Decompositions
│ │ ├── ApplyControlledX.qs
│ │ ├── ApplyControlledZFromRzz.qs
│ │ ├── ApplyUncontrolledH.qs
│ │ ├── ApplyUncontrolledRy.qs
│ │ ├── ApplyUncontrolledS.qs
│ │ ├── ApplyUncontrolledSAdj.qs
│ │ ├── ApplyUncontrolledT.qs
│ │ ├── ApplyUncontrolledTAdj.qs
│ │ ├── ApplyUncontrolledX.qs
│ │ ├── ApplyUncontrolledY.qs
│ │ ├── ApplyUncontrolledZ.qs
│ │ ├── AssertOperationsEqualInPlace.qs
│ │ ├── AssertOperationsEqualReferenced.qs
│ │ ├── CCNOT.qs
│ │ ├── CCNOTFromCCZ.qs
│ │ ├── CNOT.qs
│ │ ├── CNOTFromSinglyControlled.qs
│ │ ├── CX.qs
│ │ ├── CYFromCNOT.qs
│ │ ├── CZFromSinglyControlled.qs
│ │ ├── ExpFrac.qs
│ │ ├── ExpFracFromExpUtil.qs
│ │ ├── ExpFromExpUtil.qs
│ │ ├── ExpUtil.qs
│ │ ├── ExpUtilFromIsing.qs
│ │ ├── HFromSinglyControlled.qs
│ │ ├── I.qs
│ │ ├── M.qs
│ │ ├── MResetX.qs
│ │ ├── MResetXExplicit.qs
│ │ ├── MResetY.qs
│ │ ├── MResetYExplicit.qs
│ │ ├── MResetZ.qs
│ │ ├── MResetZExplicit.qs
│ │ ├── MWithPostPrep.qs
│ │ ├── Measure.qs
│ │ ├── MeasureEachZ.qs
│ │ ├── MeasureWithNoReuse.qs
│ │ ├── PreparePostM.qs
│ │ ├── PreparePostMNoop.qs
│ │ ├── R.qs
│ │ ├── R1.qs
│ │ ├── R1Frac.qs
│ │ ├── R1FromSinglyControlled.qs
│ │ ├── RFrac.qs
│ │ ├── RFromSinglyControlledR1.qs
│ │ ├── Reset.qs
│ │ ├── ResetAll.qs
│ │ ├── ResultArrayAsInt.qs
│ │ ├── Rx.qs
│ │ ├── RxFromSinglyControlled.qs
│ │ ├── RxxFromExp.qs
│ │ ├── RxxFromRzz.qs
│ │ ├── RxxFromSinglyControlled.qs
│ │ ├── Ry.qs
│ │ ├── RyFromSinglyControlled.qs
│ │ ├── RyyFromExp.qs
│ │ ├── RyyFromRzz.qs
│ │ ├── RyyFromSinglyControlled.qs
│ │ ├── Rz.qs
│ │ ├── RzFromSinglyControlled.qs
│ │ ├── RzzFromExp.qs
│ │ ├── RzzFromRz.qs
│ │ ├── RzzFromSinglyControlled.qs
│ │ ├── SFromSinglyControlled.qs
│ │ ├── SWAP.qs
│ │ ├── SWAPFromSinglyControlled.qs
│ │ ├── SetToBasisState.qs
│ │ ├── TFromSinglyControlled.qs
│ │ ├── Utils.qs
│ │ ├── XFromSinglyControlled.qs
│ │ ├── YFromSinglyControlled.qs
│ │ └── ZFromSinglyControlled.qs
│ ├── DelaySign.cs
│ ├── Interfaces
│ │ ├── IIntrinsicApplyControlledX.cs
│ │ ├── IIntrinsicApplyControlledZ.cs
│ │ ├── IIntrinsicApplyUncontrolledH.cs
│ │ ├── IIntrinsicApplyUncontrolledRx.cs
│ │ ├── IIntrinsicApplyUncontrolledRxx.cs
│ │ ├── IIntrinsicApplyUncontrolledRy.cs
│ │ ├── IIntrinsicApplyUncontrolledRyy.cs
│ │ ├── IIntrinsicApplyUncontrolledRz.cs
│ │ ├── IIntrinsicApplyUncontrolledRzz.cs
│ │ ├── IIntrinsicApplyUncontrolledS.cs
│ │ ├── IIntrinsicApplyUncontrolledSAdj.cs
│ │ ├── IIntrinsicApplyUncontrolledSWAP.cs
│ │ ├── IIntrinsicApplyUncontrolledT.cs
│ │ ├── IIntrinsicApplyUncontrolledTAdj.cs
│ │ ├── IIntrinsicApplyUncontrolledX.cs
│ │ ├── IIntrinsicApplyUncontrolledY.cs
│ │ ├── IIntrinsicApplyUncontrolledZ.cs
│ │ ├── IIntrinsicExp.cs
│ │ ├── IIntrinsicH.cs
│ │ ├── IIntrinsicM.cs
│ │ ├── IIntrinsicMZ.cs
│ │ ├── IIntrinsicMeasure.cs
│ │ ├── IIntrinsicR.cs
│ │ ├── IIntrinsicReset.cs
│ │ ├── IIntrinsicRx.cs
│ │ ├── IIntrinsicRy.cs
│ │ ├── IIntrinsicRz.cs
│ │ ├── IIntrinsicS.cs
│ │ ├── IIntrinsicSWAP.cs
│ │ ├── IIntrinsicT.cs
│ │ ├── IIntrinsicX.cs
│ │ ├── IIntrinsicY.cs
│ │ ├── IIntrinsicZ.cs
│ │ ├── IQSharpCore.cs
│ │ ├── IType1Core.cs
│ │ ├── IType2Core.cs
│ │ ├── IType3Core.cs
│ │ ├── IType4Core.cs
│ │ └── Microsoft.Quantum.Targets.Interfaces.csproj
│ ├── Intrinsic
│ │ ├── ApplyControlledX.qs
│ │ ├── ApplyControlledZ.qs
│ │ ├── ApplyUncontrolledH.qs
│ │ ├── ApplyUncontrolledRx.qs
│ │ ├── ApplyUncontrolledRxx.qs
│ │ ├── ApplyUncontrolledRy.qs
│ │ ├── ApplyUncontrolledRyy.qs
│ │ ├── ApplyUncontrolledRz.qs
│ │ ├── ApplyUncontrolledRzz.qs
│ │ ├── ApplyUncontrolledS.qs
│ │ ├── ApplyUncontrolledSAdj.qs
│ │ ├── ApplyUncontrolledSWAP.qs
│ │ ├── ApplyUncontrolledT.qs
│ │ ├── ApplyUncontrolledTAdj.qs
│ │ ├── ApplyUncontrolledX.qs
│ │ ├── ApplyUncontrolledY.qs
│ │ ├── ApplyUncontrolledZ.qs
│ │ ├── Exp.qs
│ │ ├── H.qs
│ │ ├── M.qs
│ │ ├── MZ.qs
│ │ ├── Measure.qs
│ │ ├── Properties
│ │ │ └── NamespaceInfo.qs
│ │ ├── R.qs
│ │ ├── Reset.qs
│ │ ├── Rx.qs
│ │ ├── Ry.qs
│ │ ├── Rz.qs
│ │ ├── S.qs
│ │ ├── SWAP.qs
│ │ ├── T.qs
│ │ ├── X.qs
│ │ ├── Y.qs
│ │ └── Z.qs
│ ├── README.md
│ ├── TargetPackages
│ │ ├── Common.Package.props
│ │ ├── QSharpCore.Package.props
│ │ ├── Type1.Package.props
│ │ ├── Type2.Package.props
│ │ ├── Type3.Package.props
│ │ └── Type4.Package.props
│ └── Tests
│ │ ├── DecompositionTests.qs
│ │ ├── Reference.qs
│ │ ├── Tests.TargetDefinitions.csproj
│ │ ├── Type1
│ │ ├── Tests.Type1.csproj
│ │ └── Tests.qs
│ │ └── UtilitiesTest.qs
├── Type1Core
│ ├── Microsoft.Quantum.Type1.Core.csproj
│ └── Microsoft.Quantum.Type1.Core.props
├── Type2Core
│ ├── Microsoft.Quantum.Type2.Core.csproj
│ └── Microsoft.Quantum.Type2.Core.props
├── Type3Core
│ ├── Microsoft.Quantum.Type3.Core.csproj
│ └── Microsoft.Quantum.Type3.Core.props
├── Type4Core
│ ├── Microsoft.Quantum.Type4.Core.csproj
│ └── Microsoft.Quantum.Type4.Core.props
└── qdk_sim_rs
│ ├── .gitignore
│ ├── CONTRIBUTING.md
│ ├── Cargo.toml
│ ├── NuGet.Config
│ ├── README.md
│ ├── benches
│ ├── c_api_benchmark.rs
│ ├── data
│ │ ├── benchmark-noise-model.json
│ │ └── noise-model-export.ipynb
│ └── microbenchmark.rs
│ ├── build-qdk-sim-rs.ps1
│ ├── build.rs
│ ├── cbindgen.toml
│ ├── docs-includes
│ ├── after.html
│ └── header.html
│ ├── docs
│ ├── c-api.md
│ └── python-api.md
│ ├── prerequisites.ps1
│ ├── pyproject.toml
│ ├── qdk_sim_experimental
│ ├── __init__.py
│ └── version.py
│ ├── setup.py
│ ├── src
│ ├── c_api.rs
│ ├── chp_decompositions.rs
│ ├── common_matrices.rs
│ ├── error.rs
│ ├── instrument
│ │ ├── common.rs
│ │ └── mod.rs
│ ├── lib.rs
│ ├── linalg
│ │ ├── array_ext.rs
│ │ ├── decompositions
│ │ │ ├── eig.rs
│ │ │ ├── lu.rs
│ │ │ └── mod.rs
│ │ ├── expm.rs
│ │ ├── inv.rs
│ │ ├── mod.rs
│ │ ├── pow.rs
│ │ └── tensor.rs
│ ├── math
│ │ ├── mod.rs
│ │ └── sp_func.rs
│ ├── noise_model.rs
│ ├── paulis.rs
│ ├── processes
│ │ ├── apply.rs
│ │ ├── generators
│ │ │ ├── common.rs
│ │ │ └── mod.rs
│ │ └── mod.rs
│ ├── python.rs
│ ├── states.rs
│ ├── tableau.rs
│ └── utils.rs
│ ├── test-qdk-sim-rs.ps1
│ └── tests
│ ├── chp_simulation_tests.rs
│ ├── data
│ └── ideal-noise-model.json
│ └── serialization_tests.rs
└── Xunit
├── DelaySign.cs
├── Exceptions.cs
├── Microsoft.Quantum.Xunit.csproj
├── Microsoft.Quantum.Xunit.nuspec
├── OperationDriverAttribute.cs
├── TestCase.cs
├── TestCaseDiscoverer.cs
└── TestOperation.cs
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [target.'cfg(target_os = "windows")']
2 | rustflags = ["-C", "control-flow-guard"]
3 |
4 |
--------------------------------------------------------------------------------
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.191.0/containers/codespaces-linux/.devcontainer/base.Dockerfile
2 |
3 | FROM mcr.microsoft.com/vscode/devcontainers/universal:1-linux
4 |
5 | USER root
6 |
7 | # Install CMake 3.20 (required since apt-get uses 3.16 and repo requires 3.20)
8 | RUN curl -SsL https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-linux-x86_64.sh -o cmakeinstall.sh \
9 | && echo "f582e02696ceee81818dc3378531804b2213ed41c2a8bc566253d16d894cefab cmakeinstall.sh" | sha256sum -c --strict - \
10 | && chmod +x cmakeinstall.sh \
11 | && ./cmakeinstall.sh --prefix=/usr/local --exclude-subdir \
12 | && rm cmakeinstall.sh
13 |
14 | USER codespace
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement, needs triage
6 | assignees: ''
7 | ---
8 |
9 | **Please describe what you would like the feature to accomplish.**
10 | A clear and concise description of what you want to accomplish and why.
11 |
12 | **Describe the solution you'd like**
13 | A clear and concise description of what you want to happen.
14 |
15 | **Describe alternatives you've considered**
16 | A clear and concise description of any alternative solutions or features you've considered.
17 |
18 | **Additional context**
19 | Add any other context or screenshots about the feature request here.
20 |
--------------------------------------------------------------------------------
/.github/workflows/devskim.yml:
--------------------------------------------------------------------------------
1 | name: DevSkim
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 | workflow_dispatch:
9 | schedule:
10 | # set schedule to run at 2AM PT on Saturdays
11 | - cron: '0 9 * * Sat'
12 |
13 | jobs:
14 | lint:
15 | name: DevSkim
16 | runs-on: ubuntu-latest
17 | permissions:
18 | actions: read
19 | contents: read
20 | security-events: write
21 | steps:
22 | - name: Checkout code
23 | uses: actions/checkout@v3
24 |
25 | - name: Run DevSkim scanner
26 | uses: microsoft/DevSkim-Action@v1
27 |
28 | - name: Upload DevSkim scan results to GitHub Security tab
29 | uses: github/codeql-action/upload-sarif@v2
30 | with:
31 | sarif_file: devskim-results.sarif
32 |
--------------------------------------------------------------------------------
/.github/workflows/qdk-sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync QDK repos
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | sync-repos:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: Login to Azure
13 | uses: Azure/login@v1
14 | with:
15 | creds: ${{ secrets.AZURE_CREDENTIALS }}
16 |
17 | - id: AzureKeyVault
18 | uses: Azure/get-keyvault-secrets@v1
19 | with:
20 | keyvault: 'kv-qdk-build'
21 | secrets: 'qdkBuildPAT'
22 |
23 | - name: 'Trigger QDK sync build'
24 | uses: Azure/pipelines@releases/v1
25 | with:
26 | azure-devops-project-url: 'https://dev.azure.com/ms-quantum-public/Microsoft Quantum (public)'
27 | azure-pipeline-name: 'microsoft.qdk.sync'
28 | azure-devops-token: ${{ steps.AzureKeyVault.outputs.qdkBuildPAT }}
29 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the pre-commit tool to run an initial
2 | # suite of lightweight tests on each commit, reducing the
3 | # probability of failing in CI.
4 | # For more information on pre-commit, see https://pre-commit.com/.
5 | repos:
6 | - repo: https://github.com/doublify/pre-commit-rust
7 | rev: v1.0
8 | hooks:
9 | - id: fmt
10 | args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']
11 | - id: cargo-check
12 | args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']
13 | # This step runs cargo-clippy, a linting tool provided with the
14 | # Rust toolchain. Please see https://github.com/rust-lang/rust-clippy
15 | # and https://rust-lang.github.io/rust-clippy/master/index.html
16 | # for more information.
17 | - id: clippy
18 | args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']
19 |
20 |
--------------------------------------------------------------------------------
/.sscignore:
--------------------------------------------------------------------------------
1 | {
2 | "cfs": ["CFS0012", "CFS0013"]
3 | }
4 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/privateBuild/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # SA1025: Code should not contain multiple whitespace in a row
4 | dotnet_diagnostic.SA1025.severity = none
5 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/privateBuild/advantage.sln:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/AdvantageBenchmark/privateBuild/advantage.sln
--------------------------------------------------------------------------------
/AdvantageBenchmark/privateBuild/host.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Exe
7 | net6.0
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/privateBuild/runTest.ps1:
--------------------------------------------------------------------------------
1 | for ($tst=1; $tst -le 2; $tst++) {
2 | for ($thrd=4; $thrd -ge 1; $thrd--) {
3 | for ($span=4; $span -ge 0; $span--) {
4 | $env:OMP_NUM_THREADS = $thrd
5 | $env:QDK_SIM_FUSESPAN = $span
6 | .\bin\Release\net6.0\host.exe $tst $tst 5
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/privateBuild/runTest.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for tst in {1..3}
4 | do
5 | for thrd in {20..2..-2}
6 | do
7 | for span in {7..0..-1}
8 | do
9 | export OMP_NUM_THREADS=$thrd
10 | export QDK_SIM_FUSESPAN=$span
11 | ./bin/Release/net6.0/host $tst $tst 5
12 | done
13 | done
14 | done
15 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/releasedBuild/host/host.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Exe
13 | net6.0
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | netstandard2.1
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 |
3 | members = [
4 | "src/Simulation/qdk_sim_rs",
5 | "src/Qir/Runtime/stdlib",
6 | ]
7 |
8 | [profile.release]
9 | debug = true
10 | codegen-units = 1 # Reduce number of codegen units to increase optimizations.
11 | opt-level = 3
12 | panic = 'unwind'
13 |
--------------------------------------------------------------------------------
/build/.gitignore:
--------------------------------------------------------------------------------
1 | *.snk
--------------------------------------------------------------------------------
/build/assets/qdk-nuget-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/build/assets/qdk-nuget-icon.png
--------------------------------------------------------------------------------
/build/e2e.yml:
--------------------------------------------------------------------------------
1 | name: $(Build.Major).$(Build.Minor).$(BuildId)
2 |
3 | parameters:
4 | - name: validation_level
5 | displayName: Validation Level
6 | type: string
7 | default: normal
8 | values:
9 | - minimal
10 | - normal
11 | - full
12 |
13 | trigger: none
14 |
15 | pr:
16 | - main
17 | - feature/*
18 | - features/*
19 | - release/*
20 |
21 | resources:
22 | repositories:
23 | - repository: qdk
24 | type: github
25 | endpoint: github
26 | name: microsoft/qdk
27 | ref: refs/heads/main
28 |
29 | extends:
30 | template: build/qdk-module-e2e.yml@qdk
31 | parameters:
32 | module: qsharp-runtime
33 | validation_level: ${{ parameters.validation_level }}
34 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Microsoft.Quantum.Sdk": "0.28.302812"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/omnisharp.json:
--------------------------------------------------------------------------------
1 | {
2 | "script": {
3 | "enableScriptNuGetReferences": true
4 | },
5 | "msbuild": {
6 | "loadProjectsOnDemand": true
7 | }
8 | }
--------------------------------------------------------------------------------
/rust-toolchain:
--------------------------------------------------------------------------------
1 | nightly-2022-08-01
2 |
--------------------------------------------------------------------------------
/src/Azure/Azure.Quantum.Client/Authentication/TokenFileContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #nullable enable
5 |
6 | namespace Microsoft.Azure.Quantum.Authentication
7 | {
8 | using System.Text.Json.Serialization;
9 |
10 | ///
11 | /// Contract for the contents of the token file used in TokenFileCredential.
12 | ///
13 | public class TokenFileContent
14 | {
15 | ///
16 | /// The access token.
17 | ///
18 | [JsonPropertyName("access_token")]
19 | public string? AccessToken { get; set; }
20 |
21 | ///
22 | /// The expiry time of the token in milliseconds since epoch.
23 | ///
24 | [JsonPropertyName("expires_on")]
25 | public long ExpiresOn { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Azure/Azure.Quantum.Client/Utility/IFileSystem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #nullable enable
5 |
6 | namespace Microsoft.Azure.Quantum.Utility
7 | {
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 |
11 | public interface IFileSystem
12 | {
13 | bool FileExists(string path);
14 |
15 | T GetFileContent(string path);
16 |
17 | Task GetFileContentAsync(string path, CancellationToken cancellationToken);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Azure/Common/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "companyName": "Microsoft Corporation"
6 | },
7 | "orderingRules": {
8 | "usingDirectivesPlacement": "outsideNamespace"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Qir/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore the generated qir files from Q# compiler
2 | **/qsharp/qir/
3 |
--------------------------------------------------------------------------------
/src/Qir/CommandLineTool/Microsoft.Quantum.Qir.CommandLineTool.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | x64
6 | net6.0
7 |
8 |
9 |
10 | true
11 | qir-cli
12 | Command-line tool for interacting with QIR.
13 | Quantum QIR
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Qir/Common/Externals/readme.md:
--------------------------------------------------------------------------------
1 | # External components
2 |
3 | ## Catch2
4 |
5 | We are using v2.13.6 single-header distribution of catch2 native framework from https://github.com/catchorg/Catch2, v2.x branch
6 | ([Getting Catch2](https://github.com/catchorg/Catch2/blob/v2.x/docs/tutorial.md#getting-catch2), "single header version").
7 |
8 | ## CLI11
9 |
10 | We are using v1.9.1 single-header distribution of CLI11 command line parser for C++ from (https://github.com/CLIUtils/CLI11) (5cb3efabce007c3a0230e4cc2e27da491c646b6c).
11 |
--------------------------------------------------------------------------------
/src/Qir/LSan.ignore:
--------------------------------------------------------------------------------
1 | leak:qir-dynamic-tests
2 | leak:qir-static-tests
3 |
--------------------------------------------------------------------------------
/src/Qir/Runtime/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [profile.release]
2 | panic = 'abort'
3 |
--------------------------------------------------------------------------------
/src/Qir/Runtime/stdlib/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "qir-stdlib"
3 | version = "0.1.0"
4 | authors = ["Microsoft"]
5 | edition = "2021"
6 | license = "MIT"
7 |
8 | [dependencies]
9 | qir-stdlib = { git = "https://github.com/qir-alliance/qir-runner/", rev = "f04c90b1908a1bed7b7b21db1c2e10d84504227c" }
10 |
11 | [lib]
12 | crate-type = ["staticlib"]
13 |
--------------------------------------------------------------------------------
/src/Qir/Runtime/stdlib/src/lib.rs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // This module simply wraps and reexports the API available from the qir-stdlib. See the Cargo.toml
5 | // for the source of the library implementation.
6 | pub use qir_stdlib::{
7 | arrays::*, bigints::*, callables::*, math::*, output_recording::*, range_support::*,
8 | strings::*, tuples::*, *,
9 | };
10 |
--------------------------------------------------------------------------------
/src/Qir/Samples/StandaloneInputReference/.clang-tidy:
--------------------------------------------------------------------------------
1 | InheritParentConfig: true
2 | Checks:
3 | '-bugprone-exception-escape,-cert-err58-cpp'
4 |
5 | HeaderFilterRegex: ''
6 |
--------------------------------------------------------------------------------
/src/Qir/Samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | True
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Qir/Samples/build-qir-samples.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | [CmdletBinding()]
5 | param (
6 | [Parameter()]
7 | [Switch]
8 | $SkipQSharpBuild
9 | )
10 |
11 | Write-Host "##[info]Compile Q# Sample Projects into QIR"
12 |
13 | . (Join-Path $PSScriptRoot .. qir-utils.ps1)
14 |
15 | & (Join-Path $PSScriptRoot ".." check-sources-formatted.ps1) -Path $PSScriptRoot
16 |
17 | Build-QirProject (Join-Path $PSScriptRoot StandaloneInputReference qsharp) -SkipQSharpBuild:$SkipQSharpBuild
18 |
19 | if (-not (Build-CMakeProject $PSScriptRoot "QIR Samples")) {
20 | throw "At least one project failed to compile. Check the logs."
21 | }
--------------------------------------------------------------------------------
/src/Qir/Samples/test-qir-samples.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | . (Join-Path $PSScriptRoot .. qir-utils.ps1)
5 |
6 | # TODO: macOS: `ASAN_OPTIONS=detect_leaks=1` (https://clang.llvm.org/docs/AddressSanitizer.html#memory-leak-detection).
7 | $env:ASAN_OPTIONS = "check_initialization_order=true:detect_stack_use_after_return=true:" `
8 | + "alloc_dealloc_mismatch=true:new_delete_type_mismatch=true:strict_init_order=true:strict_string_checks=true:" `
9 | + "detect_invalid_pointer_pairs=2"
10 |
11 | if (-not (Test-CTest (Join-Path $PSScriptRoot bin $Env:BUILD_CONFIGURATION StandaloneInputReference) "QIR Samples (StandaloneInputReference)")) {
12 | throw "At least one project failed testing. Check the logs."
13 | }
14 |
--------------------------------------------------------------------------------
/src/Qir/Tests/FullstateSimulator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(fullstate-simulator-tests FullstateSimulatorTests.cpp)
2 |
3 | target_source_from_qir(fullstate-simulator-tests qsharp/obj/qsharp/qir-test-simulator.bc)
4 |
5 | target_link_libraries(fullstate-simulator-tests PUBLIC
6 | "-L${simulator_lib_path}"
7 | -lMicrosoft.Quantum.Simulator.Runtime
8 | )
9 |
10 | target_include_directories(fullstate-simulator-tests PUBLIC
11 | ${test_includes}
12 | )
13 |
14 | install(TARGETS fullstate-simulator-tests RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/bin")
15 | add_unit_test(fullstate-simulator-tests)
16 |
17 |
--------------------------------------------------------------------------------
/src/Qir/Tests/FullstateSimulator/qsharp/qir-test-simulator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | True
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-dynamic/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(TEST_FILES qsharp/obj/qsharp/qir-test-random.bc)
2 |
3 | #==============================================================================
4 | # This executable target links test code against the dynamic libraries rather than the explicit
5 | # static QIR/RT libs (qir will statically link in the bridge via transitivity of target_link_libraries).
6 | #
7 | add_executable(qir-dynamic-tests qir-driver.cpp)
8 |
9 | foreach(file ${TEST_FILES})
10 | target_source_from_qir(qir-dynamic-tests ${file})
11 | endforeach()
12 |
13 | target_link_libraries(qir-dynamic-tests PUBLIC
14 | "-L${simulator_lib_path}"
15 | -lMicrosoft.Quantum.Simulator.Runtime
16 | )
17 |
18 | target_include_directories(qir-dynamic-tests PUBLIC
19 | ${test_includes}
20 | )
21 |
22 | install(TARGETS qir-dynamic-tests RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/bin")
23 | add_unit_test(qir-dynamic-tests)
24 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-dynamic/qsharp/qir-test-dump.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Testing.QIR
5 | {
6 | open Microsoft.Quantum.Diagnostics;
7 |
8 | @EntryPoint()
9 | function DumpMachineToFileTest(filePath : String) : Unit {
10 | DumpMachine(filePath);
11 | }
12 |
13 | @EntryPoint()
14 | function DumpMachineTest() : Unit {
15 | DumpMachine();
16 | }
17 |
18 | @EntryPoint()
19 | operation DumpRegisterTest() : Unit {
20 | use q2 = Qubit[2] {
21 | DumpRegister((), q2);
22 | }
23 | }
24 |
25 | @EntryPoint()
26 | operation DumpRegisterToFileTest(filePath : String) : Unit {
27 | use q2 = Qubit[2] {
28 | DumpRegister(filePath, q2);
29 | }
30 | }
31 | } // namespace Microsoft.Quantum.Testing.QIR
32 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-dynamic/qsharp/qir-test-random.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | True
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-dynamic/qsharp/qir-test-random.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Testing.QIR
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | @EntryPoint()
9 | operation QuantumRandomNumberGenerator() : Int {
10 | mutable randomNumber = 0;
11 |
12 | for i in 1 .. 64 {
13 | use q = Qubit();
14 | H(q);
15 | set randomNumber = randomNumber <<< 1;
16 | if M(q) == One {
17 | set randomNumber += 1;
18 | }
19 | }
20 | return randomNumber;
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(TEST_FILES
2 | qsharp/qir/qir-gen.ll
3 | )
4 |
5 | #==============================================================================
6 | # The executable target for QIR tests triggers the custom actions to compile ll files
7 | #
8 | add_executable(qir-static-tests
9 | qir-driver.cpp
10 | qir-test-math.cpp
11 | qir-test-strings.cpp
12 | qir-test-other.cpp
13 | )
14 |
15 | foreach(file ${TEST_FILES})
16 | target_source_from_qir(qir-static-tests ${file})
17 | endforeach()
18 |
19 | target_link_libraries(qir-static-tests PUBLIC
20 | "-L${simulator_lib_path}"
21 | -lMicrosoft.Quantum.Simulator.Runtime
22 | )
23 |
24 | target_include_directories(qir-static-tests PUBLIC
25 | ${test_includes}
26 | ${public_includes}
27 | )
28 |
29 | install(TARGETS qir-static-tests RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/bin")
30 | add_unit_test(qir-static-tests)
31 |
32 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qir-test-other.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "catch.hpp"
5 |
6 | extern "C" uint64_t Microsoft__Quantum__Testing__QIR__Other__ParityTest__Interop(); // NOLINT
7 | extern "C" uint64_t Microsoft__Quantum__Testing__QIR__Other__PauliArrayAsIntTest__Interop(); // NOLINT
8 |
9 | TEST_CASE("QIR: Other.PauliArrayAsInt", "[qir.Other][qir.Other.PauliArrayAsInt]")
10 | {
11 | REQUIRE(0 == Microsoft__Quantum__Testing__QIR__Other__PauliArrayAsIntTest__Interop());
12 | }
13 |
14 | TEST_CASE("QIR: Other.Parity", "[qir.Other][qir.Other.Parity]")
15 | {
16 | REQUIRE(0 == Microsoft__Quantum__Testing__QIR__Other__ParityTest__Interop());
17 | }
18 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qir-test-strings.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | #include
4 |
5 | #include "catch.hpp"
6 |
7 |
8 | extern "C" uint64_t Microsoft__Quantum__Testing__QIR__Str__PauliToStringTest__Interop(); // NOLINT
9 |
10 |
11 | TEST_CASE("QIR: Strings", "[qir.Str][qir.Str.PauliToString]")
12 | {
13 | REQUIRE(0 == Microsoft__Quantum__Testing__QIR__Str__PauliToStringTest__Interop());
14 | }
15 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/Math.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | open Microsoft.Quantum.Targeting;
7 | open Microsoft.Quantum.Core;
8 |
9 | @Inline()
10 | function NAN() : Double {
11 | body intrinsic;
12 | }
13 |
14 | @Inline()
15 | function IsNan(d: Double) : Bool {
16 | body intrinsic;
17 | }
18 |
19 | @Inline()
20 | function INFINITY() : Double {
21 | body intrinsic;
22 | }
23 |
24 | @Inline()
25 | function IsInf(d: Double) : Bool {
26 | body intrinsic;
27 | }
28 |
29 | @Inline()
30 | function IsNegativeInfinity(d : Double) : Bool {
31 | body intrinsic;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/qir-gen.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | True
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/qir-test-output.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Testing.QIR.Out {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | @EntryPoint()
9 | function MessageTest(msg: String) : Unit {
10 | Message(msg);
11 | }
12 |
13 | } // namespace Microsoft.Quantum.Testing.QIR.Out
14 |
15 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/qir-test-partials.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Testing.QIR {
5 | function Subtract(from : Int, what : Int) : Int {
6 | return from - what;
7 | }
8 |
9 | @EntryPoint()
10 | function TestPartials(x : Int, y : Int) : Int {
11 | let subtractor = Subtract(x, _);
12 | return subtractor(y);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/qir-test-qubits-results.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | namespace Microsoft.Quantum.Testing.QIR {
4 | open Microsoft.Quantum.Intrinsic;
5 |
6 | @EntryPoint()
7 | operation TestQubitResultManagement() : Unit {
8 | // exercise __quantum__rt__qubit_allocate_array
9 | use qs = Qubit[2] {
10 | X(qs[1]);
11 | // exercise __quantum__rt__qubit_allocate
12 | use q = Qubit() {
13 | // exercise __quantum__rt__result_equal and accessing result constants
14 | if (M(qs[1]) == One) { X(q); }
15 | if (M(qs[0]) == M(q)) { fail("Unexpected measurement result"); }
16 | } // exercise __quantum__rt__qubit_release
17 | } // exercise __quantum__rt__qubit_release_array
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Qir/Tests/QIR-static/qsharp/qir-test-strings.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Testing.QIR.Str {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | @EntryPoint()
9 | function PauliToStringTest() : Int {
10 |
11 | if "Pauli value: PauliI" !=
12 | $"Pauli value: {PauliI}" { return 1; } // The return value indicates which test case has failed.
13 | if "PauliX" != $"{PauliX}" { return 2; }
14 | if "PauliY" != $"{PauliY}" { return 3; }
15 | if "PauliZ" != $"{PauliZ}" { return 4; }
16 |
17 | return 0;
18 | }
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/src/Qir/Tests/build-qir-tests.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | [CmdletBinding()]
5 | param (
6 | [Parameter()]
7 | [Switch]
8 | $SkipQSharpBuild
9 | )
10 |
11 | Write-Host "##[info]Compile Q# Test Projects into QIR"
12 |
13 | . (Join-Path $PSScriptRoot .. qir-utils.ps1)
14 |
15 | & (Join-Path $PSScriptRoot ".." check-sources-formatted.ps1) -Path $PSScriptRoot
16 |
17 | Build-QirProject (Join-Path $PSScriptRoot QIR-static qsharp) -SkipQSharpBuild:$SkipQSharpBuild
18 | Build-QirProject (Join-Path $PSScriptRoot QIR-dynamic qsharp) -SkipQSharpBuild:$SkipQSharpBuild
19 | Build-QirProject (Join-Path $PSScriptRoot FullstateSimulator qsharp) -SkipQSharpBuild:$SkipQSharpBuild
20 |
21 | if (-not (Build-CMakeProject $PSScriptRoot "QIR Tests")) {
22 | throw "At least one project failed to compile. Check the logs."
23 | }
--------------------------------------------------------------------------------
/src/Qir/Tools/Driver/IQirDriverGenerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.IO;
5 | using System.Threading.Tasks;
6 | using Microsoft.Quantum.Qir.Serialization;
7 |
8 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Driver
9 | {
10 | public interface IQirDriverGenerator
11 | {
12 | Task GenerateAsync(EntryPointOperation entryPoint, Stream stream);
13 |
14 | string GetCommandLineArguments(ExecutionInformation executionInformation);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Driver/IQirSimulatorInitializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Threading.Tasks;
7 |
8 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Driver
9 | {
10 | public interface IQirRuntimeInitializer
11 | {
12 | public string Generate();
13 |
14 | public IEnumerable Headers { get; }
15 |
16 | public IEnumerable LinkLibraries { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Driver/QirCppDriverEx.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Qir.Serialization;
5 |
6 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Driver
7 | {
8 | public partial class QirCppDriver
9 | {
10 | public readonly EntryPointOperation EntryPoint;
11 |
12 | public readonly IQirRuntimeInitializer RuntimeInitializer;
13 |
14 | public QirCppDriver(EntryPointOperation entryPoint, IQirRuntimeInitializer runtimeInitializer)
15 | {
16 | EntryPoint = entryPoint;
17 | RuntimeInitializer = runtimeInitializer;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Driver/QirFullStateSimulatorInitializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Driver
7 | {
8 | public class QirFullStateSimulatorInitializer : IQirRuntimeInitializer
9 | {
10 | internal QirFullStateSimulatorInitializer() {}
11 |
12 | public string Generate() => "";
13 |
14 | public IEnumerable Headers => new string[0];
15 |
16 | public IEnumerable LinkLibraries => new string[0];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Executable/IClangClient.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Executable
7 | {
8 | ///
9 | /// Wraps the 'clang' tool used for compilation.
10 | ///
11 | public interface IClangClient
12 | {
13 | Task CreateExecutableAsync(string[] inputFiles, string[] linkedLibraries, string[] libraryPaths, string[] includePaths, string outputPath);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Executable/IQirExecutableRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.IO;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.Quantum.Qir.Runtime.Tools.Executable
8 | {
9 | public interface IQirExecutableRunner
10 | {
11 | ///
12 | /// Runs a QIR executable with the given arguments.
13 | ///
14 | /// Location of the executable to run.
15 | /// Stream to write program output.
16 | /// Arguments to supply the program with.
17 | ///
18 | Task RunExecutableAsync(FileInfo executableFile, Stream stream, string arguments);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Qir/Tools/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Runtime.InteropServices;
3 |
4 | // In SDK-style projects such as this one, several assembly attributes that were historically
5 | // defined in this file are now automatically added during build and populated with
6 | // values defined in project properties. For details of which attributes are included
7 | // and how to customise this process see: https://aka.ms/assembly-info-properties
8 |
9 |
10 | // Setting ComVisible to false makes the types in this assembly not visible to COM
11 | // components. If you need to access a type in this assembly from COM, set the ComVisible
12 | // attribute to true on that type.
13 |
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM.
17 |
18 | [assembly: Guid("1594aae8-0e24-442b-9201-430ce9ee4d2e")]
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Integration.Tests/Integration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Simulators;
5 | using Xunit;
6 |
7 | namespace Microsoft.Quantum.AutoSubstitution.Testing
8 | {
9 | public class CodeGenerationTests
10 | {
11 | [Fact]
12 | public void CanSimulateWithAlternativeSimulator()
13 | {
14 | var sim = new ToffoliSimulator();
15 | TestQuantumSwap.Run(sim).Wait();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/Core.qs:
--------------------------------------------------------------------------------
1 | // This file is needed to ensure that the Microsoft.Quantum.Core namespace
2 | // exists for the tests.
3 |
4 | namespace Microsoft.Quantum.Core {
5 | }
6 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/FailAlternativeDoesNotExist.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("Namespace.NotExisting", "ToffoliSimulator")
5 | operation Fail() : Unit {}
6 | }
7 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/FailDifferentSignatures.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("AutoSubstitutionTests.FailClassical", "ToffoliSimulator")
5 | operation Fail(a : Int) : Unit {}
6 |
7 | operation FailClassical(a : Double) : Unit {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/FailDifferentSpecializationKinds.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("FailClassical", "ToffoliSimulator")
5 | operation Fail() : Unit is Adj {}
6 |
7 | operation FailClassical() : Unit {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/FailNoNamespace.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("FailClassical", "ToffoliSimulator")
5 | operation Fail() : Unit {}
6 |
7 | operation FailClassical() : Unit {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/Success.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("AutoSubstitutionTests.SuccessClassical", "ToffoliSimulator")
5 | operation Success() : Unit {}
6 |
7 | operation SuccessClassical() : Unit {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/SuccessA.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("AutoSubstitutionTests.SuccessClassical", "ToffoliSimulator")
5 | operation Success() : Unit is Adj {}
6 |
7 | operation SuccessClassical() : Unit is Adj {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/SuccessC.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("AutoSubstitutionTests.SuccessClassical", "ToffoliSimulator")
5 | operation Success() : Unit is Ctl {}
6 |
7 | operation SuccessClassical() : Unit is Ctl {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution.Tests/TestFiles/SuccessCA.qs:
--------------------------------------------------------------------------------
1 | namespace AutoSubstitutionTests {
2 | open Microsoft.Quantum.Targeting;
3 |
4 | @SubstitutableOnTarget("AutoSubstitutionTests.SuccessClassical", "ToffoliSimulator")
5 | operation Success() : Unit is Adj+Ctl {}
6 |
7 | operation SuccessClassical() : Unit is Adj+Ctl {}
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution/Microsoft.Quantum.AutoSubstitution.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.AutoSubstitution.dll
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/AutoSubstitution/Substitution.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Targeting {
5 | /// # Summary
6 | /// Enables to substitute an operation with an alternative operation for a given target
7 | ///
8 | /// # Named Items
9 | /// ## AlternativeOperation
10 | /// Fully qualified name of alternative operation to substitute operation with.
11 | ///
12 | /// ## TargetName
13 | /// One of `QuantumSimulator`, `ToffoliSimulator`, or a fully qualified name
14 | /// of a custom target.
15 | @Attribute()
16 | newtype SubstitutableOnTarget = (AlternativeOperation : String, TargetName : String);
17 | }
18 |
--------------------------------------------------------------------------------
/src/Simulation/Common/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | // Allow the test assembly to use our internal methods
7 | [assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)]
8 |
--------------------------------------------------------------------------------
/src/Simulation/Common/Exceptions/NotDistinctQubits.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Microsoft.Quantum.Simulation.Simulators.Exceptions
10 | {
11 | public class NotDistinctQubits : Exception
12 | {
13 | public NotDistinctQubits(Qubit q)
14 | : base($"Trying to apply an intrinsic operation with a qubit repeated in the argument list (qubit:{q}).")
15 | {
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Common/Exceptions/NotEnoughQubits.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Microsoft.Quantum.Simulation.Simulators.Exceptions
11 | {
12 | public class NotEnoughQubits : Exception
13 | {
14 | public NotEnoughQubits(long requested, long available)
15 | : base($"Not enough Qubits. Requested {requested} but only {available} are available.")
16 | {
17 | this.Requested = requested;
18 | this.Available = available;
19 | }
20 |
21 | public long Requested { get; private set; }
22 | public long Available { get; private set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Simulation/Common/Exceptions/ReleasedQubitsAreNotInZeroState.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Microsoft.Quantum.Simulation.Simulators.Exceptions
11 | {
12 | public class ReleasedQubitsAreNotInZeroState : Exception
13 | {
14 | public ReleasedQubitsAreNotInZeroState()
15 | : base("Released qubits are not in zero state.")
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Simulation/Common/Exceptions/TranslationException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Quantum.Simulation.Common.Exceptions
7 | {
8 | public class QuantumProcessorTranslationException : Exception
9 | {
10 | public QuantumProcessorTranslationException()
11 | : base("An exception occurred while performing a translation on a quantum processor.")
12 | {
13 | }
14 |
15 | public QuantumProcessorTranslationException(string message)
16 | : base(message)
17 | {
18 | }
19 |
20 | public QuantumProcessorTranslationException(string message, Exception inner)
21 | : base(message, inner)
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Simulation/Common/Microsoft.Quantum.Simulation.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net6.0
8 | x64
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Simulation/Common/OperationException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Runtime.CompilerServices;
6 |
7 | #nullable enable
8 |
9 | namespace Microsoft.Quantum.Simulation.Common
10 | {
11 | ///
12 | /// A class that implements exception to be thrown when Operation is not supported.
13 | ///
14 | public class UnsupportedOperationException : PlatformNotSupportedException
15 | {
16 | public UnsupportedOperationException(string text = "",
17 | [CallerFilePath] string file = "",
18 | [CallerMemberName] string member = "",
19 | [CallerLineNumber] int line = 0)
20 | : base($"{file}::{line}::[{member}]:{text}")
21 | {
22 | }
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/src/Simulation/Core/Generics/Unitary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Core
5 | {
6 | ///
7 | /// Represents an operation that has both a Controlled and an Adjoint
8 | /// operation and whose input Type is not resolved until it gets
9 | /// Applied at runtime.
10 | ///
11 | public interface IUnitary : IAdjointable, IControllable
12 | {
13 | new IUnitary Adjoint { get; }
14 |
15 | new IUnitary Controlled { get; }
16 |
17 | new IUnitary Partial(object partialTuple);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Simulation/Core/IData.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Quantum.Simulation.Core
7 | {
8 | ///
9 | /// Represents data that can be used as input arguments or return values of an Apply operation.
10 | ///
11 | public interface IApplyData
12 | {
13 | object Value { get; }
14 |
15 | ///
16 | /// If there are no qubits contained in the value returns null
17 | ///
18 | ///
19 | IEnumerable Qubits { get; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Simulation/Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | // Allow the test assembly to use our internal methods
7 | [assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)]
8 |
--------------------------------------------------------------------------------
/src/Simulation/EntryPointDriver.Tests/Core.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Core {
5 | @Attribute()
6 | newtype Attribute = Unit;
7 |
8 | @Attribute()
9 | newtype EntryPoint = Unit;
10 | }
11 |
--------------------------------------------------------------------------------
/src/Simulation/EntryPointDriver.Tests/Intrinsic.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | operation H (q : Qubit) : Unit {
6 | body intrinsic;
7 | adjoint intrinsic;
8 | controlled intrinsic;
9 | controlled adjoint intrinsic;
10 | }
11 |
12 | operation X (q : Qubit) : Unit {
13 | body intrinsic;
14 | adjoint intrinsic;
15 | controlled intrinsic;
16 | controlled adjoint intrinsic;
17 | }
18 |
19 | operation M (q : Qubit) : Result {
20 | body intrinsic;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Simulation/EntryPointDriver/Azure/GenerateAzurePayloadSettings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.EntryPointDriver
5 | {
6 |
7 | ///
8 | /// Settings for a submission to Azure Quantum.
9 | ///
10 | public sealed class GenerateAzurePayloadSettings
11 | {
12 | ///
13 | /// The target device ID.
14 | ///
15 | public string? Target { get; set; }
16 |
17 | ///
18 | /// Show additional information.
19 | ///
20 | public bool Verbose { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Simulation/EntryPointDriver/Azure/OutputFormat.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.EntryPointDriver
5 | {
6 | ///
7 | /// The information to show in the output after the job is submitted.
8 | ///
9 | public enum OutputFormat
10 | {
11 | ///
12 | /// Show a friendly message with a URI that can be used to see the job results.
13 | ///
14 | FriendlyUri,
15 |
16 | ///
17 | /// Show only the job ID.
18 | ///
19 | Id
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Simulation/Native/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | build
3 | /.vs
4 | /vs2017
5 | *.csv
6 | foo*
7 | *.filters
8 | *.cmake
9 | *.vcxproj
10 | CMakeFiles/
11 | CMakeCache.txt
12 | *.so
13 |
--------------------------------------------------------------------------------
/src/Simulation/Native/argmaxnrm2_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/argmaxnrm2_test
--------------------------------------------------------------------------------
/src/Simulation/Native/bititerator_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/bititerator_test
--------------------------------------------------------------------------------
/src/Simulation/Native/bitops_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/bitops_test
--------------------------------------------------------------------------------
/src/Simulation/Native/capi_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/capi_test
--------------------------------------------------------------------------------
/src/Simulation/Native/cpuid_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/cpuid_test
--------------------------------------------------------------------------------
/src/Simulation/Native/diagmatrix_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/diagmatrix_test
--------------------------------------------------------------------------------
/src/Simulation/Native/doCopy.ps1:
--------------------------------------------------------------------------------
1 | param([string]$bld = "Release")
2 |
3 | "================== COPYING $bld"
4 | $dll = "Microsoft.Quantum.Simulator.Runtime.*" # DLL and PDB
5 | $srcDir = "C:\depot\Git\qsharp-runtime\src\Simulation\Native\build\$bld"
6 | foreach ($dest in "H2O","Ham","integer-factorization") {
7 | foreach ($typ in "Release","Debug") {
8 | $dstDir = "C:\depot\Git\msr-quarc\wecker\QDK\$dest\bin\$typ"
9 | $dstDir += "\netcoreapp3.0\runtimes\win-x64\native"
10 | robocopy /NJH /NJS /NP /NDL $srcDir $dstDir $dll | Out-Null
11 | }
12 | }
13 | exit 0
14 |
--------------------------------------------------------------------------------
/src/Simulation/Native/factory_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/factory_test
--------------------------------------------------------------------------------
/src/Simulation/Native/linux/libomp.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/linux/libomp.so
--------------------------------------------------------------------------------
/src/Simulation/Native/linux/libomp.so.5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/linux/libomp.so.5
--------------------------------------------------------------------------------
/src/Simulation/Native/local_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/local_test
--------------------------------------------------------------------------------
/src/Simulation/Native/openmp_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/openmp_test
--------------------------------------------------------------------------------
/src/Simulation/Native/osx/libomp.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/osx/libomp.dylib
--------------------------------------------------------------------------------
/src/Simulation/Native/src/catch2/catch_driver.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
5 | #include "catch.hpp"
6 |
7 | // https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md
--------------------------------------------------------------------------------
/src/Simulation/Native/src/catch2/cgmanifest.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "Registrations":[
4 | {
5 | "Component": {
6 | "Type": "git",
7 | "Git": {
8 | "RepositoryUrl": "https://github.com/catchorg/Catch2",
9 | "CommitHash": "87074da73ecb1c2e7c35fd14f50ca21c4c002adc" }
10 | }
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/src/Simulation/Native/src/catch2/readme.md:
--------------------------------------------------------------------------------
1 | # Catch2
2 |
3 | We are using v2.13.6 single-header distribution of catch2 native framework from https://github.com/catchorg/Catch2.
--------------------------------------------------------------------------------
/src/Simulation/Native/src/external/avx/kernels.hpp:
--------------------------------------------------------------------------------
1 | // (C) 2018 ETH Zurich, ITP, Thomas Häner and Damian Steiger
2 |
3 | #ifndef KERNELS_HPP_
4 | #define KERNELS_HPP_
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include "../cintrin.hpp"
13 | #include "util/alignedalloc.hpp"
14 |
15 | #define LOOP_COLLAPSE1 2
16 | #define LOOP_COLLAPSE2 3
17 | #define LOOP_COLLAPSE3 4
18 | #define LOOP_COLLAPSE4 5
19 | #define LOOP_COLLAPSE5 6
20 | #define LOOP_COLLAPSE6 7
21 | #define LOOP_COLLAPSE7 8
22 |
23 | #include "kernel1.hpp"
24 | #include "kernel2.hpp"
25 | #include "kernel3.hpp"
26 | #include "kernel4.hpp"
27 | #include "kernel5.hpp"
28 | #include "kernel6.hpp"
29 | #include "kernel7.hpp"
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/external/avx2/kernels.hpp:
--------------------------------------------------------------------------------
1 | // (C) 2018 ETH Zurich, ITP, Thomas Häner and Damian Steiger
2 |
3 | #ifndef KERNELS_HPP_
4 | #define KERNELS_HPP_
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include "../cintrin.hpp"
13 | #include "util/alignedalloc.hpp"
14 |
15 | #define LOOP_COLLAPSE1 2
16 | #define LOOP_COLLAPSE2 3
17 | #define LOOP_COLLAPSE3 4
18 | #define LOOP_COLLAPSE4 5
19 | #define LOOP_COLLAPSE5 6
20 | #define LOOP_COLLAPSE6 7
21 | #define LOOP_COLLAPSE7 8
22 |
23 | #include "kernel1.hpp"
24 | #include "kernel2.hpp"
25 | #include "kernel3.hpp"
26 | #include "kernel4.hpp"
27 | #include "kernel5.hpp"
28 | #include "kernel6.hpp"
29 | #include "kernel7.hpp"
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/external/avx512/kernels.hpp:
--------------------------------------------------------------------------------
1 | // (C) 2018 ETH Zurich, ITP, Thomas Häner and Damian Steiger
2 |
3 | #ifndef KERNELS_HPP_
4 | #define KERNELS_HPP_
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include "../cintrin.hpp"
13 | #include "util/alignedalloc.hpp"
14 |
15 | #define LOOP_COLLAPSE1 2
16 | #define LOOP_COLLAPSE2 3
17 | #define LOOP_COLLAPSE3 4
18 | #define LOOP_COLLAPSE4 5
19 | #define LOOP_COLLAPSE5 6
20 | #define LOOP_COLLAPSE6 7
21 | #define LOOP_COLLAPSE7 8
22 |
23 | #include "kernel1.hpp"
24 | #include "kernel2.hpp"
25 | #include "kernel3.hpp"
26 | #include "kernel4.hpp"
27 | #include "kernel5.hpp"
28 | #include "kernel6.hpp"
29 | #include "kernel7.hpp"
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/external/nointrin/kernels.hpp:
--------------------------------------------------------------------------------
1 | // (C) 2018 ETH Zurich, ITP, Thomas Häner and Damian Steiger
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "../cintrin.hpp"
10 | #include "util/alignedalloc.hpp"
11 |
12 | template
13 | T mul(T a, T b){
14 | return a*b;
15 | }
16 | template
17 | T add(T a, T b){
18 | return a+b;
19 | }
20 |
21 | #define LOOP_COLLAPSE1 2
22 | #define LOOP_COLLAPSE2 3
23 | #define LOOP_COLLAPSE3 4
24 | #define LOOP_COLLAPSE4 5
25 | #define LOOP_COLLAPSE5 6
26 | #define LOOP_COLLAPSE6 7
27 | #define LOOP_COLLAPSE7 8
28 |
29 | #include "kernel1.hpp"
30 | #include "kernel2.hpp"
31 | #include "kernel3.hpp"
32 | #include "kernel4.hpp"
33 | #include "kernel5.hpp"
34 | #include "kernel6.hpp"
35 | #include "kernel7.hpp"
36 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/factory.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include "config.hpp"
5 | #include "simulatorinterface.hpp"
6 |
7 | namespace Microsoft
8 | {
9 | namespace Quantum
10 | {
11 | namespace Simulator
12 | {
13 | MICROSOFT_QUANTUM_DECL unsigned create(unsigned = 0u);
14 | MICROSOFT_QUANTUM_DECL void destroy(unsigned);
15 | MICROSOFT_QUANTUM_DECL std::shared_ptr& get(unsigned);
16 | } // namespace Simulator
17 | } // namespace Quantum
18 | } // namespace Microsoft
19 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/factory_test.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include "simulator/factory.hpp"
5 | #include
6 |
7 | using namespace Microsoft::Quantum::Simulator;
8 |
9 | int main(int argc, char** argv)
10 | {
11 | auto sim = get(create());
12 |
13 | unsigned q = 0; // qubit number
14 | sim->allocateQubit(q);
15 |
16 | // produce random bits using H gates
17 | for (int i = 0; i < 100; i++)
18 | {
19 | sim->H(q);
20 | int result = sim->M(q);
21 |
22 | std::cout << result << std::endl;
23 | }
24 |
25 | sim->release(q);
26 |
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/simulator.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include "simulator/simulator.hpp"
5 |
6 | namespace sim = Microsoft::Quantum::SIMULATOR;
7 |
8 | MICROSOFT_QUANTUM_DECL Microsoft::Quantum::Simulator::SimulatorInterface* sim::createSimulator(unsigned maxlocal)
9 | {
10 | return new sim::SimulatorType(maxlocal);
11 | }
12 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/simulatoravx.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #define HAVE_INTRINSICS
5 |
6 | #include "simulator/simulator.hpp"
7 |
8 | namespace sim = Microsoft::Quantum::SimulatorAVX;
9 |
10 | MICROSOFT_QUANTUM_DECL Microsoft::Quantum::Simulator::SimulatorInterface* sim::createSimulator(unsigned maxlocal)
11 | {
12 | return new sim::SimulatorType(maxlocal);
13 | }
14 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/simulatoravx2.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #define HAVE_INTRINSICS
5 | #define HAVE_FMA
6 |
7 | #include "simulator/simulator.hpp"
8 |
9 | namespace sim = Microsoft::Quantum::SimulatorAVX2;
10 |
11 | MICROSOFT_QUANTUM_DECL Microsoft::Quantum::Simulator::SimulatorInterface* sim::createSimulator(unsigned maxlocal)
12 | {
13 | return new sim::SimulatorType(maxlocal);
14 | }
15 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/simulator/simulatoravx512.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #define HAVE_INTRINSICS
5 | #define HAVE_AVX512
6 | #define HAVE_FMA
7 |
8 | #include "simulator/simulator.hpp"
9 |
10 | namespace sim = Microsoft::Quantum::SimulatorAVX512;
11 |
12 | MICROSOFT_QUANTUM_DECL Microsoft::Quantum::Simulator::SimulatorInterface* sim::createSimulator(unsigned maxlocal)
13 | {
14 | return new sim::SimulatorType(maxlocal);
15 | }
16 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/util/bitops_test.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include
5 | #include
6 |
7 | #include "bitops.hpp"
8 |
9 | int main()
10 | {
11 | using namespace Microsoft::Quantum;
12 |
13 | assert(ilog2(1) == 0);
14 | assert(ilog2(2) == 1);
15 | assert(ilog2(4) == 2);
16 | assert(ilog2(8) == 3);
17 |
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/util/cpuid_test.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include "cpuid.hpp"
5 | #include
6 |
7 | int main()
8 | {
9 | if (Microsoft::Quantum::haveAVX512()) std::cout << "Have AVX-512\n";
10 | if (Microsoft::Quantum::haveAVX2()) std::cout << "Have AVX2\n";
11 | if (Microsoft::Quantum::haveFMA()) std::cout << "Have FMA\n";
12 | if (Microsoft::Quantum::haveAVX())
13 | std::cout << "Have AVX\n";
14 | else
15 | std::cout << "Don't have AVX\n";
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/util/openmp.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include
5 |
6 | #include "util/openmp.hpp"
7 |
8 | void Microsoft::Quantum::openmp::init(unsigned numthreads)
9 | {
10 | #ifdef _OPENMP
11 | if (numthreads) omp_set_num_threads(numthreads);
12 | #if defined(__ICC) || defined(__INTEL_COMPILER)
13 | kmp_set_defaults("KMP_AFFINITY=compact");
14 | #endif
15 | #else
16 | assert(numthreads < 2);
17 | #endif
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/util/openmp_test.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #include "util/openmp.hpp"
5 | #include
6 | #include
7 |
8 | int main()
9 | {
10 |
11 | using namespace Microsoft::Quantum::openmp;
12 |
13 | init();
14 | init(1);
15 | assert(omp_get_num_threads() == 1);
16 | assert(omp_get_thread_num() == 0);
17 | #ifdef _OPENMP
18 | omp_mutex mutex;
19 | std::lock_guard guard(mutex);
20 | #endif
21 |
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/version.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | /* #undef MICROSOFT_QUANTUM_SIMULATOR_VERSION */
7 | /* #undef MICROSOFT_QUANTUM_SIMULATOR_VERSION_MAJOR */
8 | /* #undef MICROSOFT_QUANTUM_SIMULATOR_VERSION_MINOR */
9 | /* #undef MICROSOFT_QUANTUM_SIMULATOR_VERSION_PATCH */
10 | /* #undef MICROSOFT_QUANTUM_SIMULATOR_VERSION_STRING */
11 | #define MICROSOFT_QUANTUM_SIMULATOR_YEAR "2020"
12 |
--------------------------------------------------------------------------------
/src/Simulation/Native/src/version.hpp.in:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_VERSION "@MICROSOFT_QUANTUM_SIMULATOR_VERSION@"
7 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_VERSION_MAJOR @MICROSOFT_QUANTUM_SIMULATOR_VERSION_MAJOR@
8 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_VERSION_MINOR @MICROSOFT_QUANTUM_SIMULATOR_VERSION_MINOR@
9 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_VERSION_PATCH @MICROSOFT_QUANTUM_SIMULATOR_VERSION_PATCH@
10 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_VERSION_STRING "@MICROSOFT_QUANTUM_SIMULATOR_VERSION_STRING@"
11 | #cmakedefine MICROSOFT_QUANTUM_SIMULATOR_YEAR "@MICROSOFT_QUANTUM_SIMULATOR_YEAR@"
12 |
--------------------------------------------------------------------------------
/src/Simulation/Native/stats.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/stats.xlsx
--------------------------------------------------------------------------------
/src/Simulation/Native/test-native-simulator.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | Write-Host "##[info]Test Native simulator"
5 | Push-Location (Join-Path $PSScriptRoot "build")
6 |
7 | ctest -C "$Env:BUILD_CONFIGURATION" --verbose
8 |
9 | if ($LastExitCode -ne 0) {
10 | Write-Host "##vso[task.logissue type=error;]Failed to test Native Simulator"
11 | $script:all_ok = $False
12 | }
13 |
14 | Pop-Location
15 |
--------------------------------------------------------------------------------
/src/Simulation/Native/tinymatrix_test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/tinymatrix_test
--------------------------------------------------------------------------------
/src/Simulation/Native/win10/libomp140.x86_64.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Native/win10/libomp140.x86_64.dll
--------------------------------------------------------------------------------
/src/Simulation/NativeSparseSimulator/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/src/Simulation/NativeSparseSimulator/TestHelpers.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include "SparseSimulator.h"
7 | #include
8 | #include
9 |
10 | using namespace Microsoft::Quantum::SPARSESIMULATOR;
11 |
12 | #ifndef M_PI
13 | #define M_PI 3.14159265358979323846
14 | #endif
15 |
16 | namespace SparseSimulatorTestHelpers
17 | {
18 | void apply_exp(
19 | std::vector& wfn,
20 | std::vector b,
21 | double phi,
22 | std::vector qs);
23 |
24 | void assert_amplitude_equality(amplitude amp, double real, double imag);
25 |
26 | void assert_amplitude_equality(amplitude expected_amp, amplitude actual_amp);
27 |
28 | // Prepares some qubits, then checks whether various Pauli exponentials work
29 | }
30 |
--------------------------------------------------------------------------------
/src/Simulation/NativeSparseSimulator/factory.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Manages simulators in a vector of pointers to simulators
5 |
6 | #pragma once
7 |
8 | #include "types.h"
9 | #include "SparseSimulator.h"
10 |
11 | namespace Microsoft::Quantum::SPARSESIMULATOR
12 | {
13 |
14 | simulator_id_type createSimulator(logical_qubit_id);
15 | void destroySimulator(simulator_id_type);
16 |
17 | std::shared_ptr& getSimulator(simulator_id_type);
18 |
19 | } // namespace Microsoft::Quantum::SPARSESIMULATOR
20 |
--------------------------------------------------------------------------------
/src/Simulation/NativeSparseSimulator/test.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | Write-Host "##[info]Test Native Sparse Simulator"
5 | Push-Location (Join-Path $PSScriptRoot "build")
6 |
7 | ctest -C "$Env:BUILD_CONFIGURATION" --verbose
8 |
9 | $RetVal = $LastExitCode
10 |
11 | if ($RetVal -ne 0) {
12 | Write-Host "##vso[task.logissue type=error;]Failed to test Native Sparse Simulator"
13 | }
14 |
15 | Pop-Location
16 |
17 | Exit $RetVal
18 |
--------------------------------------------------------------------------------
/src/Simulation/QCTraceSimulator.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Simulation/QCTraceSimulator.Tests/Circuits/CCXGateCount.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.Tests {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 |
9 | operation MultiControlledXDriver (numberOfQubits : Int) : Unit {
10 |
11 |
12 | using (qubits = Qubit[numberOfQubits]) {
13 | Controlled X(qubits[1 .. numberOfQubits - 1], qubits[0]);
14 | }
15 | }
16 |
17 |
18 | operation CCNOTDriver () : Unit {
19 |
20 |
21 | using (qubits = Qubit[3]) {
22 | CCNOT(qubits[0], qubits[1], qubits[2]);
23 | T(qubits[0]);
24 | }
25 | }
26 |
27 | }
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/Simulation/QCTraceSimulator.Tests/Circuits/UseReleasedQubitsTest.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.Tests {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 |
9 | operation UseReleasedQubitTest () : Unit {
10 |
11 | mutable q = new Qubit[1];
12 |
13 | using (ans = Qubit()) {
14 | set q = q w/ 0 <- ans;
15 | }
16 |
17 | H(q[0]);
18 | }
19 |
20 | }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Simulation/QCTraceSimulator/ICallGraphStatistics.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime
11 | {
12 | public interface ICallGraphStatistics
13 | {
14 | IStatisticCollectorResults Results { get; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Simulation/QCTraceSimulator/Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net6.0
8 | x64
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Core support for the Q# programming language.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpCore/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 | using System.Runtime.InteropServices;
7 |
8 | // Allow the simulator assembly to use our internal methods
9 | [assembly: InternalsVisibleTo("Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)]
--------------------------------------------------------------------------------
/src/Simulation/QSharpCore/QuantumProcessor/M.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 |
7 | namespace Microsoft.Quantum.Simulation.QuantumProcessor
8 | {
9 | public partial class QuantumProcessorDispatcher
10 | {
11 | public class QuantumProcessorDispatcherM : Quantum.Intrinsic.M
12 | {
13 | private QuantumProcessorDispatcher Simulator { get; }
14 |
15 | public QuantumProcessorDispatcherM(QuantumProcessorDispatcher m) : base(m)
16 | {
17 | this.Simulator = m;
18 | }
19 |
20 | public override Func __Body__ => (q) =>
21 | {
22 | return Simulator.QuantumProcessor.M(q);
23 | };
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation.Tests/Microsoft.Quantum.Bitwise.qs:
--------------------------------------------------------------------------------
1 | namespace Quantum.QSharpFoundation.Tests {
2 | open Microsoft.Quantum.Diagnostics;
3 | open Microsoft.Quantum.Bitwise;
4 |
5 | @Test("SparseSimulator")
6 | operation TestParity() : Unit {
7 | Fact(Parity(-1) == 0, "Expected 0.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Arrays/Empty.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 |
7 | namespace Microsoft.Quantum.Arrays
8 | {
9 | public partial class EmptyArray<__TElement__>
10 | {
11 | public class Native : EmptyArray<__TElement__>
12 | {
13 | public Native(IOperationFactory m) : base(m) { }
14 | public override Func> __Body__ => _ =>
15 | new QArray<__TElement__>();
16 | }
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Arrays/Empty.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Arrays {
5 |
6 | /// # Summary
7 | /// Returns the empty array of a given type.
8 | ///
9 | /// # Type Parameters
10 | /// ## 'TElement
11 | /// The type of elements of the array.
12 | ///
13 | /// # Output
14 | /// The empty array.
15 | ///
16 | /// # Example
17 | /// ```qsharp
18 | /// let empty = EmptyArray();
19 | /// ```
20 | function EmptyArray<'TElement>() : 'TElement[] {
21 | return new 'TElement[0];
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Assert.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurement")
6 | operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit
7 | is Adj + Ctl {
8 | Microsoft.Quantum.Diagnostics.AssertMeasurement(bases, qubits, result, msg);
9 | }
10 |
11 | @Deprecated("Microsoft.Quantum.Diagnostics.AssertMeasurementProbability")
12 | operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit
13 | is Adj + Ctl {
14 | Microsoft.Quantum.Diagnostics.AssertMeasurementProbability(bases, qubits, result, prob, msg, tol);
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Message.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | /// # Summary
6 | /// Logs a message.
7 | ///
8 | /// # Input
9 | /// ## msg
10 | /// The message to be reported.
11 | ///
12 | /// # Remarks
13 | /// The specific behavior of this function is simulator-dependent,
14 | /// but in most cases the given message will be written to the console.
15 | ///
16 | /// # Example
17 | /// The following causes `"Hello, world!"` to be reported (typically to
18 | /// the console):
19 | /// ```qsharp
20 | /// let name = "world";
21 | /// Message($"Hello, {name}!");
22 | /// ```
23 | function Message (msg : String) : Unit {
24 | body intrinsic;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Random/Internal.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Random {
5 |
6 | // This operation duplicates an operation from the Q# standard libraries
7 | // and is used to support partially applying all inputs to a given
8 | // operation without actually executing it.
9 | internal operation Delay<'TInput, 'TOutput>(op : ('TInput => 'TOutput), input : 'TInput, delay : Unit) : 'TOutput {
10 | return op(input);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Random/Properties/NamespaceInfo.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | /// # Summary
5 | /// This namespace contains functions, operations, and UDTs
6 | /// for working with random values and probability distributions.
7 | namespace Microsoft.Quantum.Random {}
8 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Statements/Allocate.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic
7 | {
8 | public abstract class Allocate : AbstractCallable
9 | {
10 | public Allocate(IOperationFactory m) : base(m) { }
11 |
12 | public abstract Qubit Apply();
13 |
14 | public abstract IQArray Apply(long count);
15 |
16 | public override void __Init__() { }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Statements/Borrow.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic
7 | {
8 | public abstract class Borrow : AbstractCallable
9 | {
10 | public Borrow(IOperationFactory m) : base(m) { }
11 |
12 | public abstract Qubit Apply();
13 |
14 | public abstract IQArray Apply(long count);
15 |
16 | public override void __Init__() { }
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Statements/Release.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic
7 | {
8 | public abstract class Release : AbstractCallable
9 | {
10 | public Release(IOperationFactory m) : base(m) { }
11 |
12 | public abstract void Apply(Qubit q);
13 |
14 | public abstract void Apply(IQArray qubits);
15 |
16 | public override void __Init__() { }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/QSharpFoundation/Statements/Return.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic
7 | {
8 | public abstract class Return : AbstractCallable
9 | {
10 | public Return(IOperationFactory m) : base(m) { }
11 |
12 | public abstract void Apply(Qubit q);
13 |
14 | public abstract void Apply(IQArray qubits);
15 |
16 | public override void __Init__() { }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/AssertEqual.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 | using Xunit;
7 |
8 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
9 | {
10 | public partial class AssertEqual<__T__>
11 | {
12 | public class Native : AssertEqual<__T__>
13 | {
14 | public Native(IOperationFactory m) : base(m) { }
15 |
16 | public override Func<(__T__, __T__), QVoid> __Body__ => (_args) =>
17 | {
18 | var (expected, actual) = _args;
19 | Assert.Equal(expected, actual);
20 | return QVoid.Instance;
21 | };
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/AssertEqual.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits {
5 |
6 | function AssertEqual<'T> (expected : 'T, actual : 'T) : Unit {
7 | body intrinsic;
8 | }
9 |
10 | }
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Bug1514.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Bug1514 {
5 |
6 | operation Bug1514() : Unit {
7 | Foo();
8 | Bar(3);
9 | }
10 |
11 | operation Foo() : Unit {
12 | }
13 |
14 | function Bar<'T>(a: 'T) : Unit {
15 | }
16 | }
17 |
18 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
19 | {
20 | open Bug1514;
21 |
22 | operation Bug1514Test () : Unit
23 | {
24 | Bug1514();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Bug2469.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | operation TestSafeToRunCliffords (flag : Bool) : Unit
9 | {
10 | using (q = Qubit())
11 | {
12 | X(q);
13 | if (flag)
14 | {
15 | Y(q);
16 | Z(q);
17 | H(q);
18 | S(q);
19 | }
20 | X(q); // So that it's safe to release
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/ConditionalExpression.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 | open Microsoft.Quantum.Diagnostics;
8 |
9 | operation ConditionalExpressionTest() : Unit {
10 | using (q = Qubit()) {
11 | AssertQubit(Zero, q);
12 |
13 | mutable flag = false;
14 | (flag ? X | I)(q);
15 | AssertQubit(Zero, q);
16 |
17 | set flag = true;
18 | (flag ? X | I)(q);
19 | AssertQubit(One, q);
20 |
21 | Reset(q);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Functions.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | function Add(a: Int, b: Int) : Int
9 | {
10 | return a + b;
11 | }
12 |
13 | function ApplyTwice<'T>(f: ('T -> Int), a: 'T) : Int
14 | {
15 | return f(a) + f(a);
16 | }
17 |
18 | operation PartialFunctionsTest () : Unit
19 | {
20 | let plusFive = Add(5, _);
21 | let partial_3 = ApplyTwice(_, 3);
22 | let partial_9 = ApplyTwice(_, 9);
23 |
24 | AssertEqual(12, ApplyTwice(plusFive, 1));
25 | AssertEqual(16, partial_3(plusFive));
26 | AssertEqual(28, partial_9(plusFive));
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Issue132.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | operation SliceGenerationTest() : Unit {
9 | using (qs = Qubit[4]) {
10 | PrepareCatState(qs);
11 | if (M(qs[0]) == One) {
12 | for (target in qs) {
13 | X(target);
14 | }
15 | }
16 | }
17 | }
18 |
19 | operation PrepareCatState(register : Qubit[]) : Unit is Adj + Ctl {
20 | H(register[0]);
21 | for (target in register[1...]) {
22 | CNOT(register[0], target);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Issue76.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Issue76
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | function BuggyReturn<'T> (param: 'T): Bool {
9 | return true;
10 | }
11 |
12 | function AssertBuggyReturn<'T> (param: 'T): Unit {
13 | if (not BuggyReturn<'T>(param)) {
14 | Message("BuggyReturn returned false");
15 | }
16 | }
17 | }
18 |
19 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
20 | {
21 | open Issue76;
22 | open Microsoft.Quantum.Intrinsic;
23 |
24 | function BuggyReturnTest () : Unit
25 | {
26 | AssertBuggyReturn(0);
27 | if (not BuggyReturn(0)) {
28 | Message("BuggyReturn returned false");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/NamedItems.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits
5 | {
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 | newtype NestedPair = (Double, ((Fst : Bool, String), Snd : Int));
9 |
10 | operation NamedItemAccessTest () : Unit {
11 |
12 | let udt = NestedPair(1.0, ((true, "Hello"), 10));
13 | if (not udt::Fst) {
14 | fail "wrong initialization";
15 | }
16 | Message($"Snd is {udt::Snd}");
17 | }
18 |
19 | operation NamedItemUpdateTest () : Unit {
20 |
21 | let udt1 = NestedPair(1.0, ((true, "Hello"), 10));
22 | mutable udt2 = udt1 w/ Fst <- false;
23 | set udt2 w/= Snd <- 5;
24 | if (not udt1::Fst or udt1::Snd != 10 or udt2::Fst or udt2::Snd != 5) {
25 | fail "wrong values";
26 | }
27 | }
28 |
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/Namespaces.qs:
--------------------------------------------------------------------------------
1 | // // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // // Licensed under the MIT License.
3 |
4 | // Will cause compilation failure if callable type references in generated C# aren't
5 | // prepended with "global::".
6 | namespace Issue46 {
7 |
8 | operation ReturnZero () : Result {
9 |
10 | return Zero;
11 | }
12 |
13 | }
14 |
15 | namespace Microsoft.Quantum.Tests.Namespaces.Issue46 {
16 |
17 | operation TestOp () : Result {
18 |
19 | return Issue46.ReturnZero();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/NativeOperations.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace NativeOperations
5 | {
6 | operation IntrinsicBody () : String
7 | {
8 | body intrinsic;
9 | }
10 |
11 | operation DefaultBody () : String
12 | {
13 | return "hello";
14 | }
15 |
16 | operation IntrinsicBodyGeneric<'T>(arg: 'T) : String
17 | {
18 | body intrinsic;
19 | }
20 |
21 | operation DefaultBodyGeneric<'T>(arg: 'T) : 'T
22 | {
23 | return arg;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/SetQubit.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 |
8 |
9 | operation SetQubit (desired : Result, q1 : Qubit) : Unit {
10 |
11 | let current = M(q1);
12 |
13 | if (desired != current) {
14 | X(q1);
15 | }
16 | }
17 |
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/SwapTest.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits {
5 | open Microsoft.Quantum.Intrinsic;
6 | open Microsoft.Quantum.Diagnostics;
7 |
8 |
9 | operation SwapTest () : Unit {
10 |
11 |
12 | using (qubits = Qubit[2]) {
13 | let q1 = qubits[0];
14 | let q2 = qubits[1];
15 | X(q1);
16 | SWAP(q1, q2);
17 |
18 | // Make sure all allocated qubits are measured before release
19 | let (r1, r2) = (M(q1), M(q2));
20 | AssertQubit(Zero, q1);
21 | AssertQubit(One, q2);
22 | X(q2);
23 | }
24 | }
25 |
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/Circuits/UnitTests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests.Circuits {
5 |
6 | open Microsoft.Quantum.Intrinsic;
7 | open Microsoft.Quantum.Diagnostics;
8 |
9 | @Test("QuantumSimulator")
10 | @Test("ToffoliSimulator")
11 | @Test("SparseSimulator")
12 | operation QSharpUnitTest() : Unit {
13 | Message("Worked!");
14 | }
15 |
16 | @Test("QuantumSimulator")
17 | @Test("Microsoft.Quantum.Simulation.Simulators.Tests.TrivialSimulator")
18 | @Test("Microsoft.Quantum.Simulation.Simulators.Tests.ModifiedTrivialSimulator")
19 | @Test("Microsoft.Quantum.Simulation.Simulators.Tests.UnitTests.TrivialSimulator")
20 | @Test("SparseSimulator")
21 | operation ArbitraryUnitTestTarget() : Unit {
22 | Message("Worked!");
23 | }
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/DiagnosticsWrappers.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.Tests {
5 | open Microsoft.Quantum.Diagnostics;
6 |
7 | operation DumpToFile(filename : String) : Unit {
8 | DumpMachine(filename);
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | global using System;
5 | global using Xunit;
6 | global using Xunit.Abstractions;
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | false
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Arrays/Tests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Arrays {
5 | open Microsoft.Quantum.Diagnostics;
6 |
7 | /// # Summary
8 | /// Checks that empty arrays are indeed empty.
9 | @Test("QuantumSimulator")
10 | @Test("ToffoliSimulator")
11 | @Test("Microsoft.Quantum.Simulation.Simulators.OpenSystemsSimulator")
12 | @Test("SparseSimulator")
13 | function EmptyArraysAreEmpty() : Unit {
14 | Fact(
15 | Length(EmptyArray()) == 0,
16 | "Empty array of type Int[] was not actually empty."
17 | );
18 | Fact(
19 | Length(EmptyArray<(Double, Pauli[])>()) == 0,
20 | "Empty array of type (Double, Pauli[])[] was not actually empty."
21 | );
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Convert/Tests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Tests {
5 | open Microsoft.Quantum.Convert;
6 | open Microsoft.Quantum.Diagnostics;
7 |
8 | @Test("QuantumSimulator")
9 | @Test("SparseSimulator")
10 | function DoubleAsStringIsCorrect() : Unit {
11 | EqualityFactS(DoubleAsString(12.345), "12.345", "DoubleAsString was incorrect.");
12 | }
13 |
14 | @Test("QuantumSimulator")
15 | @Test("SparseSimulator")
16 | function IntAsStringIsCorrect() : Unit {
17 | EqualityFactS(IntAsString(12345), "12345", "IntAsString was incorrect.");
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | false
6 |
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQSimulation.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 |
5 | namespace Microsoft.Quantum.Simulation.Testing.IonQ {
6 | open Microsoft.Quantum.Diagnostics;
7 | open Microsoft.Quantum.Simulation.Testing.IonQ.MeasurementSupportTests;
8 |
9 | @Test("QuantumSimulator")
10 | @Test("SparseSimulator")
11 | operation MeasureInMiddleTest() : Unit {
12 | MeasureInMiddle();
13 | }
14 |
15 | @Test("QuantumSimulator")
16 | @Test("SparseSimulator")
17 | operation QubitAfterMeasurementTest() : Unit {
18 | QubitAfterMeasurement();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/IonQExe/MeasurementSupportTests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 |
5 | namespace Microsoft.Quantum.Simulation.Testing.IonQ.MeasurementSupportTests {
6 |
7 | open Microsoft.Quantum.Intrinsic;
8 |
9 | operation MeasureInMiddle() : Unit {
10 | using (qs = Qubit[2]) {
11 | H(qs[0]);
12 | let r1 = M(qs[0]);
13 | H(qs[1]);
14 | let r2 = M(qs[1]);
15 | Reset(qs[0]);
16 | Reset(qs[1]);
17 | }
18 | }
19 |
20 | operation QubitAfterMeasurement() : Unit {
21 | using (q = Qubit()) {
22 | H(q);
23 | let r1 = M(q);
24 | H(q);
25 | let r2 = M(q);
26 | Reset(q);
27 | }
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | false
5 | false
6 |
7 |
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library.qs:
--------------------------------------------------------------------------------
1 | namespace LibraryWithSpaces {
2 | function HelloQ() : String {
3 | return "Hello quantum world!";
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QCIExe/MeasurementSupportTests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 |
5 | namespace Microsoft.Quantum.Simulation.Testing.QCI.MeasurementSupportTests {
6 |
7 | open Microsoft.Quantum.Intrinsic;
8 |
9 | operation MeasureInMiddle() : Unit {
10 | using (qs = Qubit[2]) {
11 | H(qs[0]);
12 | let r1 = M(qs[0]);
13 | H(qs[1]);
14 | let r2 = M(qs[1]);
15 | Reset(qs[0]);
16 | Reset(qs[1]);
17 | }
18 | }
19 |
20 | operation QubitAfterMeasurement() : Unit {
21 | using (q = Qubit()) {
22 | H(q);
23 | let r1 = M(q);
24 | H(q);
25 | let r2 = M(q);
26 | Reset(q);
27 | }
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/Main.qs:
--------------------------------------------------------------------------------
1 | namespace QSharpExe {
2 |
3 | open Microsoft.Quantum.Intrinsic;
4 |
5 | @EntryPoint()
6 | operation Main () : Result {
7 | using (q = Qubit()) {
8 | H(q);
9 | let res = M(q);
10 | if (res == One) {
11 | X(q);
12 | }
13 | return res;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Exe
4 | net6.0
5 |
6 | false
7 | false
8 | false
9 | ToffoliSimulator
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QirExe/Main.qs:
--------------------------------------------------------------------------------
1 | namespace QirExe {
2 | open Microsoft.Quantum.Intrinsic;
3 |
4 | @EntryPoint()
5 | operation Main(xs : Int[], (y : Int, z : Int)) : Unit {
6 | Message("Hello, world!");
7 | Message($"({xs}, ({y}, {z}))");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QirExe/QirExe.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Exe
4 | net6.0
5 | false
6 | false
7 | false
8 | microsoft.estimator
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/QuantinuumExe/MeasurementSupportTests.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 |
5 | namespace Microsoft.Quantum.Simulation.Testing.Quantinuum.MeasurementSupportTests {
6 |
7 | open Microsoft.Quantum.Intrinsic;
8 |
9 | operation MeasureInMiddle() : Unit {
10 | using (qs = Qubit[2]) {
11 | H(qs[0]);
12 | let r1 = M(qs[0]);
13 | H(qs[1]);
14 | let r2 = M(qs[1]);
15 | Reset(qs[0]);
16 | Reset(qs[1]);
17 | }
18 | }
19 |
20 | operation QubitAfterMeasurement() : Unit {
21 | using (q = Qubit()) {
22 | H(q);
23 | let r1 = M(q);
24 | H(q);
25 | let r2 = M(q);
26 | Reset(q);
27 | }
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/Program.qs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.Quantum.Testing {
2 |
3 | open Microsoft.Quantum.Intrinsic;
4 | open Microsoft.Quantum.Measurement;
5 | open Microsoft.Quantum.Canon;
6 |
7 | @EntryPoint()
8 | operation Main() : Int {
9 |
10 | use qs = Qubit[2];
11 | Ignore(Measure([PauliX, PauliX], qs));
12 | ResetAll(qs);
13 |
14 | return 12345;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/UnitTests/Hello.qs:
--------------------------------------------------------------------------------
1 | // Used for a unit test;
2 | // do not change the name of this namespace!
3 | namespace Microsoft.Quantum.Library {
4 |
5 | open Microsoft.Quantum.Intrinsic;
6 |
7 | // Used for a unit test;
8 | // do not change the name or namespace of this type!
9 | newtype Token = Unit;
10 |
11 | // Used for a unit test;
12 | // do not change the name or namespace of this callable!
13 | operation Hello(dummy : Token) : Unit {
14 | Message("Hello!");
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Tests/TestProjects/UnitTests/SpaceTests.qs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.Quantum.Testing.SpacesInFileName {
2 | open Microsoft.Quantum.Diagnostics;
3 | open Microsoft.Quantum.Testing;
4 |
5 | @Test("QuantumSimulator")
6 | @Test("SparseSimulator")
7 | function LibraryWithSpacesTest() : Unit {
8 | FactS("Hello quantum world!", LibraryWithSpaces.HelloQ());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Type1.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Type2.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Type3.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators.Type4.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/.gitignore:
--------------------------------------------------------------------------------
1 | Microsoft.Quantum.Simulators.nuspec
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyControlledX.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyControlledX.Body(Qubit control, Qubit target)
12 | {
13 | this.CheckQubits(new QArray(new Qubit[]{ control, target }));
14 |
15 | MCX(1, new uint[]{(uint)control.Id}, (uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyControlledZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyControlledZ.Body(Qubit control, Qubit target)
12 | {
13 | this.CheckQubits(new QArray(new Qubit[]{ control, target }));
14 |
15 | MCZ(1, new uint[]{(uint)control.Id}, (uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledH.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledH.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | H((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledRx.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledRx.Body(double angle, Qubit target)
12 | {
13 | this.CheckQubit(target, nameof(target));
14 | CheckAngle(angle);
15 | R(Pauli.PauliX, angle, (uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledRy.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledRy.Body(double angle, Qubit target)
12 | {
13 | this.CheckQubit(target, nameof(target));
14 | CheckAngle(angle);
15 | R(Pauli.PauliY, angle, (uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledRz.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledRz.Body(double angle, Qubit target)
12 | {
13 | this.CheckQubit(target, nameof(target));
14 | CheckAngle(angle);
15 | R(Pauli.PauliZ, angle, (uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledS.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledS.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | S((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledSAdj.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledSAdj.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | AdjS((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledT.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledT.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | T((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledTAdj.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledTAdj.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | AdjT((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledX.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledX.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | X((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledY.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledY.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | Y((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/ApplyUncontrolledZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicApplyUncontrolledZ.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | Z((uint)target.Id);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/H.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicH.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | H((uint)target.Id);
16 | }
17 |
18 | void IIntrinsicH.ControlledBody(IQArray controls, Qubit target)
19 | {
20 | this.CheckQubits(controls, target);
21 |
22 | SafeControlled(controls,
23 | () => ((IIntrinsicH)this).Body(target),
24 | (count, ids) => MCH(count, ids, (uint)target.Id));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/MZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | Result IIntrinsicMZ.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 | //setting qubit as measured to allow for release
15 | target.IsMeasured = true;
16 | return M((uint)target.Id).ToResult();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/Reset.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicReset.Body(Qubit target)
12 | {
13 | // The native simulator doesn't have a reset operation, so simulate
14 | // it via an M follow by a conditional X.
15 | this.CheckQubit(target);
16 | var res = M((uint)target.Id);
17 | if (res == 1)
18 | {
19 | X((uint)target.Id);
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/X.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicX.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | X((uint)target.Id);
16 | }
17 |
18 | void IIntrinsicX.ControlledBody(IQArray controls, Qubit target)
19 | {
20 | this.CheckQubits(controls, target);
21 |
22 | SafeControlled(controls,
23 | () => ((IIntrinsicX)this).Body(target),
24 | (count, ids) => MCX(count, ids, (uint)target.Id));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/Y.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicY.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | Y((uint)target.Id);
16 | }
17 |
18 | void IIntrinsicY.ControlledBody(IQArray controls, Qubit target)
19 | {
20 | this.CheckQubits(controls, target);
21 |
22 | SafeControlled(controls,
23 | () => ((IIntrinsicY)this).Body(target),
24 | (count, ids) => MCY(count, ids, (uint)target.Id));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/CommonNativeSimulator/Z.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 | using Microsoft.Quantum.Intrinsic.Interfaces;
6 |
7 | namespace Microsoft.Quantum.Simulation.Simulators
8 | {
9 | public partial class CommonNativeSimulator
10 | {
11 | void IIntrinsicZ.Body(Qubit target)
12 | {
13 | this.CheckQubit(target);
14 |
15 | Z((uint)target.Id);
16 | }
17 |
18 | void IIntrinsicZ.ControlledBody(IQArray controls, Qubit target)
19 | {
20 | this.CheckQubits(controls, target);
21 |
22 | SafeControlled(controls,
23 | () => ((IIntrinsicZ)this).Body(target),
24 | (count, ids) => MCZ(count, ids, (uint)target.Id));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | global using System;
5 | global using System.Collections.Generic;
6 | global using System.Linq;
7 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/OpenSystemsSimulator/Decompositions/README.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | The decompositions in this folder should eventually be converted into a new "type 4" targeting package.
4 | We use the legacy approach to making intrinsics available to simulators, however, on a temporary basis for compatibility with Python and IQ#.
5 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/OpenSystemsSimulator/IsExternalInit.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace System.Runtime.CompilerServices;
5 | public class IsExternalInit
6 | {
7 | }
8 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | // Allow the test assembly to use our internal methods
7 | [assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)]
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/CCX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Summary
8 | /// Doubly-controlled X. Maps qubits in computational state |a,b,c⟩ to
9 | /// |a,b,(c⊕(a∧b)⟩
10 | ///
11 | /// # Input
12 | /// ## control1
13 | /// qubit corresponding to 'a' above
14 | /// ## control2
15 | /// qubit corresponding to 'b' above
16 | /// ## target
17 | /// qubit corresponding to 'c' above
18 | operation CCX (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit
19 | is Adj {
20 | PauliZFlip(PauliX, target);
21 | CCZ(control1, control2, target);
22 | Adjoint PauliZFlip(PauliX, target);
23 | }
24 |
25 | }
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/CCminusIX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Summary
8 | /// Controlled-controlled -iX
9 | operation CCminusIX (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit
10 | is Adj {
11 | PauliZFlip(PauliX, target);
12 | CCminusIZ(control1, control2, target);
13 | Adjoint PauliZFlip(PauliX, target);
14 | }
15 |
16 | }
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/CCminusIZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation CCminusIZ (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit
8 | is Adj {
9 |
10 | InternalRzFrac(1, 3, target);
11 | ExpFracZZ(-1, 3, target, control1);
12 | ExpFracZZ(-1, 3, target, control2);
13 | ExpFracZZZ(1, 3, target, control1, control2);
14 | }
15 |
16 | }
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/CZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// #Summary
8 | /// Controlled Z operation
9 | ///
10 | /// #Remark
11 | /// Controlled Z is symmetric, so there is no need to call one qubit control and another target
12 | operation CZ (a : Qubit, b : Qubit) : Unit
13 | {
14 | body (...)
15 | {
16 | PauliXFlip(PauliZ, b);
17 | InternalCX(a, b);
18 | Adjoint PauliXFlip(PauliZ, b);
19 | }
20 |
21 | adjoint self;
22 | }
23 |
24 | }
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/ControlledRZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Summary
8 | /// ControlledRZ is exp( iφ|1⟩⟨1|⊗Z)
9 | ///
10 | /// # Input
11 | /// ## angle
12 | /// φ
13 | /// ## control
14 | /// first qubit operation acts on
15 | /// ## target
16 | /// second qubit operation acts on
17 | operation ControlledRZ (angle : Double, control : Qubit, target : Qubit) : Unit
18 | is Adj {
19 | InternalRz(angle / 2.0, target);
20 | ExpZZ(angle / 4.0, target, control);
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/ControlledSWAP.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Remarks
8 | /// We use a usual identity SWAP = C₁X₂ C₂X₁ C₁X₂ and control the middle gate
9 | operation ControlledSWAP (control : Qubit, target1 : Qubit, target2 : Qubit) : Unit
10 | is Adj {
11 |
12 | InternalCX(target2, target1);
13 | CCX(control, target1, target2);
14 | InternalCX(target2, target1);
15 | }
16 |
17 | }
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/ControlledT.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// #Remark
8 | /// Based on Remark 3.2 in https://arxiv.org/pdf/1210.0974.pdf
9 | /// This is a small refinement of a swap trick
10 | operation ControlledT (control : Qubit, target : Qubit) : Unit
11 | is Adj {
12 | using (ans = Qubit[1])
13 | {
14 | let a = ans[0];
15 | CCminusIX(control, target, a);
16 | InternalT(a);
17 | Adjoint CCminusIX(control, target, a);
18 | }
19 | }
20 |
21 | }
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/ControlledTS.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Remarks
8 | /// Based on Remark 3.2 in https://arxiv.org/pdf/1210.0974.pdf
9 | /// This is a small refinement of a swap trick
10 | operation ControlledTS (control : Qubit, target : Qubit) : Unit
11 | is Adj {
12 |
13 | using (ans = Qubit[1])
14 | {
15 | let a = ans[0];
16 | CCminusIX(control, target, a);
17 | InternalT(a);
18 | InternalS(a);
19 | Adjoint CCminusIX(control, target, a);
20 | }
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/FailOn.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Summary
8 | /// Calls "fail message" when the first argument is True
9 | function FailOn (failIfTrue : Bool, message : String) : Unit
10 | {
11 | if (failIfTrue)
12 | {
13 | fail message;
14 | }
15 | }
16 |
17 | }
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Mod.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 | /// # Summary
7 | /// returns 'val' modulo modulus
8 | function Mod (value : Int, modulus : Int) : Int
9 | {
10 | let mod = value % modulus;
11 | return mod < 0 ? mod + modulus | mod;
12 | }
13 |
14 | }
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/MultiCX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation MultiCX (control : Qubit, targets : Qubit[]) : Unit
8 | {
9 | body (...)
10 | {
11 | for (i in 0 .. Length(targets) - 1)
12 | {
13 | InternalCX(control, targets[i]);
14 | }
15 | }
16 |
17 | adjoint self;
18 | }
19 |
20 | }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/MultiControlledMultiNot.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation MultiControlledMultiNot (controls : Qubit[], targets : Qubit[]) : Unit
8 | is Adj {
9 |
10 | FailOn(Length(controls) < 2, $"function is defined for 2 or more controls");
11 |
12 | using (ands = Qubit[Length(controls) - 1])
13 | {
14 | AndLadder(controls, ands);
15 | MultiCX(ands[Length(ands) - 1], targets);
16 | Adjoint AndLadder(controls, ands);
17 | }
18 | }
19 |
20 | }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/PauliArrayByIndex.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | /// # Summary
8 | /// Creates a new array
9 | /// of the form [ paulies[i] : i ∈ indices ]
10 | function PauliArrayByIndex (paulies : Pauli[], indices : Int[]) : Pauli[]
11 | {
12 | mutable result = new Pauli[Length(indices)];
13 |
14 | for (i in 0 .. Length(indices) - 1)
15 | {
16 | set result = result w/ i <- paulies[indices[i]];
17 | }
18 |
19 | return result;
20 | }
21 |
22 | }
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.CCNOT.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation CCNOT (control1 : Qubit, control2 : Qubit, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | CCX(control1, control2, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | if (Length(ctrls) == 0)
18 | {
19 | CCX(control1, control2, target);
20 | }
21 | else
22 | {
23 | MultiControlledUTwoTargets(CCX, ctrls + [control1], control2, target);
24 | }
25 | }
26 | }
27 |
28 | }
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.CNOT.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation CNOT (control : Qubit, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalCX(control, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | MultiControlledFromOpAndSinglyCtrldOp2(InternalCX, CCX, ctrls, control, target);
18 | }
19 | }
20 |
21 | }
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.H.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation H (target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalH(target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | MultiControlledFromOpAndSinglyCtrldOp(InternalH, ControlledH, ctrls, target);
18 | }
19 | }
20 |
21 | }
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.HY.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 | operation HY (target : Qubit) : Unit
7 | is Adj + Ctl {
8 |
9 | H(target);
10 | S(target);
11 | }
12 | }
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingXX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits {
5 | internal operation ApplyUncontrolledRxx (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl {
6 | Exp([PauliX, PauliX], theta * 2.0, [qubit0, qubit1]);
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingYY.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits {
5 | internal operation ApplyUncontrolledRyy (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl {
6 | Exp([PauliY, PauliY], theta * 2.0, [qubit0, qubit1]);
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.IsingZZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits {
5 | internal operation ApplyUncontrolledRzz (theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ctl {
6 | Exp([PauliZ, PauliZ], theta * 2.0, [qubit0, qubit1]);
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.R.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation R (pauli : Pauli, angle : Double, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalR(pauli, angle, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | let op = R(pauli, angle, _);
18 | let cOp = ControlledR(pauli, angle, _, _);
19 | MultiControlledFromOpAndSinglyCtrldOp(op, cOp, ctrls, target);
20 | }
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.R1.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation R1 (angle : Double, target : Qubit) : Unit
8 | is Adj {
9 |
10 | body (...)
11 | {
12 | InternalR(PauliZ, angle, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | let op = InternalR(PauliZ, angle, _);
18 | let cOp = ControlledR1(angle, _, _);
19 | MultiControlledFromOpAndSinglyCtrldOp(op, cOp, ctrls, target);
20 | }
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.R1Frac.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation R1Frac (numerator : Int, denominatorPower : Int, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalRFrac(PauliZ, -numerator, denominatorPower + 1, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | let rfrac = InternalRFrac(PauliZ, -numerator, denominatorPower + 1, _);
18 | let crfrac = ControlledR1Frac(numerator, denominatorPower, _, _);
19 | MultiControlledFromOpAndSinglyCtrldOp(rfrac, crfrac, ctrls, target);
20 | }
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.RFrac.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation RFrac (pauli : Pauli, numerator : Int, power : Int, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalRFrac(pauli, numerator, power, target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | let op = InternalRFrac(pauli, numerator, power, _);
18 | let ctrOp = ControlledRFrac(pauli, numerator, power, _, _);
19 | MultiControlledFromOpAndSinglyCtrldOp(op, ctrOp, ctrls, target);
20 | }
21 | }
22 |
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.Rx.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation Rx (angle : Double, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | R(PauliX, angle, target);
11 | }
12 |
13 | }
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.Ry.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation Ry (angle : Double, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | R(PauliY, angle, target);
11 | }
12 |
13 | }
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.Rz.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation Rz (angle : Double, target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | R(PauliZ, angle, target);
11 | }
12 |
13 | }
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.S.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation S (target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalS(target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | let ControlledS = ControlledR1Frac(1, 1, _, _);
18 | MultiControlledFromOpAndSinglyCtrldOp(InternalS, ControlledS, ctrls, target);
19 | }
20 | }
21 |
22 | }
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Circuits/Primitive.T.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Circuits
5 | {
6 |
7 | operation T (target : Qubit) : Unit
8 | is Adj + Ctl {
9 |
10 | body (...)
11 | {
12 | InternalT(target);
13 | }
14 |
15 | controlled (ctrls, ...)
16 | {
17 | MultiControlledFromOpAndSinglyCtrldOp(InternalT, ControlledT, ctrls, target);
18 | }
19 | }
20 |
21 | }
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/Docs/Width and Depth in the Tracer.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/qsharp-runtime/da1872db685826861313ef078acab615e04f1334/src/Simulation/Simulators/QCTraceSimulator/Docs/Width and Depth in the Tracer.docx
--------------------------------------------------------------------------------
/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulator.Primitive.Measure.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators.Implementation
5 | {
6 | using System;
7 | using Microsoft.Quantum.Simulation.Core;
8 | using Microsoft.Quantum.Intrinsic.Interfaces;
9 |
10 | public partial class QCTraceSimulatorImpl
11 | {
12 | Result IIntrinsicMeasure.Body(IQArray paulis, IQArray targets)
13 | {
14 | return this.Measure(paulis, targets);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/SparseSimulator/Dump.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | #nullable enable
8 | namespace Microsoft.Quantum.Simulation.Simulators
9 | {
10 | using QubitIdType = System.UInt32;
11 |
12 | public partial class SparseSimulator
13 | {
14 | ///
15 | /// Returns the list of the qubits' ids currently allocated in the simulator.
16 | ///
17 | public override uint[] QubitIds
18 | {
19 | get
20 | {
21 | var ids = new List();
22 |
23 | QubitIds_cpp(this.Id, ids.Add);
24 | return ids.Select(id => (uint)id).ToArray();
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/ToffoliSimulator/H.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 | using Microsoft.Quantum.Intrinsic.Interfaces;
7 |
8 | namespace Microsoft.Quantum.Simulation.Simulators
9 | {
10 | public partial class ToffoliSimulator
11 | {
12 | ///
13 | /// The implementation of the operation.
14 | /// For the Toffoli simulator, the implementation throws a run-time error.
15 | ///
16 | void IIntrinsicH.Body(Qubit target) => throw new NotImplementedException();
17 |
18 | void IIntrinsicH.ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/ToffoliSimulator/Y.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 | using Microsoft.Quantum.Intrinsic.Interfaces;
7 |
8 | namespace Microsoft.Quantum.Simulation.Simulators
9 | {
10 | public partial class ToffoliSimulator
11 | {
12 | ///
13 | /// The implementation of the operation.
14 | /// For the Toffoli simulator, the implementation throws a run-time error.
15 | ///
16 | void IIntrinsicY.Body(Qubit target) => throw new NotImplementedException();
17 |
18 | void IIntrinsicY.ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Simulation/Simulators/ToffoliSimulator/Z.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 | using Microsoft.Quantum.Intrinsic.Interfaces;
7 |
8 | namespace Microsoft.Quantum.Simulation.Simulators
9 | {
10 | public partial class ToffoliSimulator
11 | {
12 | ///
13 | /// The implementation of the operation.
14 | /// For the Toffoli simulator, the implementation throws a run-time error.
15 | ///
16 | void IIntrinsicZ.Body(Qubit target) => throw new NotImplementedException();
17 |
18 | void IIntrinsicZ.ControlledBody(IQArray controls, Qubit target) => throw new NotImplementedException();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledS.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the π/4 phase gate to a single qubit. Note that the Controlled functor
9 | /// is not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// S \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & i
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | internal operation ApplyUncontrolledS (qubit : Qubit) : Unit {
24 | ApplyUncontrolledRz(PI() / 2.0, qubit);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledSAdj.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the -π/4 phase gate to a single qubit. Note that the Controlled functor
9 | /// is not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// SAdj \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & -i
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | internal operation ApplyUncontrolledSAdj (qubit : Qubit) : Unit {
24 | ApplyUncontrolledRz(-PI() / 2.0, qubit);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledT.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the π/8 gate to a single qubit. Note that the Controlled functor is
9 | /// not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// T \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & e^{i \pi / 4}
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | internal operation ApplyUncontrolledT (qubit : Qubit) : Unit {
24 | ApplyUncontrolledRz(PI() / 4.0, qubit);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledTAdj.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the -π/8 gate to a single qubit. Note that the Controlled functor is
9 | /// not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// TAdj \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & e^{i -\pi / 4}
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | internal operation ApplyUncontrolledTAdj (qubit : Qubit) : Unit {
24 | ApplyUncontrolledRz(-PI() / 4.0, qubit);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the Pauli $X$ gate. Note that the Controlled functor is not supported.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// \sigma_x \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 0 & 1 \\\\
15 | /// 1 & 0
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | internal operation ApplyUncontrolledX (qubit : Qubit) : Unit is Adj {
23 | body (...) {
24 | ApplyUncontrolledRx(PI(), qubit);
25 | }
26 | adjoint self;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ApplyUncontrolledZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Math;
6 |
7 | /// # Summary
8 | /// Applies the Pauli $Z$ gate. Note that the Controlled functor is not supported.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// \sigma_z \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 1 & 0 \\\\
15 | /// 0 & -1
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | internal operation ApplyUncontrolledZ (qubit : Qubit) : Unit is Adj {
23 | body (...) {
24 | ApplyUncontrolledRz(PI(), qubit);
25 | }
26 | adjoint self;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/I.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Performs the identity operation (no-op) on a single qubit.
8 | ///
9 | /// # Remarks
10 | /// This is a no-op. It is provided for completeness and because
11 | /// sometimes it is useful to call the identity in an algorithm or to pass it as a parameter.
12 | operation I (target : Qubit) : Unit is Adj + Ctl {
13 | body (...) { }
14 | adjoint self;
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/PreparePostM.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | internal operation PreparePostM(result : Result, qubit : Qubit) : Unit {
7 | // This platform requires reset after measurement, and then must
8 | // re-prepare the measured state in the qubit.
9 | Reset(qubit);
10 | if (result == One) {
11 | X(qubit);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/PreparePostMNoop.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | internal operation PreparePostM(result : Result, qubit : Qubit) : Unit {
7 | // This platform does not require any post-measurement reset, so
8 | // no additional work is needed.
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/Reset.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Diagnostics;
6 | open Microsoft.Quantum.Targeting;
7 |
8 | /// # Summary
9 | /// Given a single qubit, measures it and ensures it is in the |0⟩ state
10 | /// such that it can be safely released.
11 | ///
12 | /// # Input
13 | /// ## qubit
14 | /// The qubit whose state is to be reset to $\ket{0}$.
15 | @RequiresCapability(
16 | "Opaque",
17 | "Empty",
18 | "Reset is replaced by a supported implementation on all execution targets."
19 | )
20 | operation Reset (qubit : Qubit) : Unit {
21 | if (M(qubit) == One) {
22 | X(qubit);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ResetAll.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Given an array of qubits, measure them and ensure they are in the |0⟩ state
8 | /// such that they can be safely released.
9 | ///
10 | /// # Input
11 | /// ## qubits
12 | /// An array of qubits whose states are to be reset to $\ket{0}$.
13 | operation ResetAll (qubits : Qubit[]) : Unit {
14 | for qubit in qubits {
15 | Reset(qubit);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Decompositions/ResultArrayAsInt.qs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.Quantum.Convert {
2 | open Microsoft.Quantum.Arrays;
3 |
4 | /// # Summary
5 | /// Produces a non-negative integer from a string of Results in little endian format.
6 | ///
7 | /// # Input
8 | /// ## results
9 | /// Results in binary representation of number.
10 | function ResultArrayAsInt(results : Result[]) : Int {
11 | mutable val = 0;
12 | for i in IndexRange(results) {
13 | set val += results[i] == One ? 2 ^ i | 0;
14 | }
15 | return val;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyControlledX.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyControlledX : IOperationFactory
9 | {
10 | void Body(Qubit control, Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyControlledZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyControlledZ : IOperationFactory
9 | {
10 | void Body(Qubit control, Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledH.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledH : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRx.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRx : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRxx.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRxx : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target1, Qubit target2);
11 |
12 | void AdjointBody(double angle, Qubit target1, Qubit target2);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRy.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRy : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRyy.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRyy : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target1, Qubit target2);
11 |
12 | void AdjointBody(double angle, Qubit target1, Qubit target2);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRz.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRz : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledRzz.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledRzz : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target1, Qubit target2);
11 |
12 | void AdjointBody(double angle, Qubit target1, Qubit target2);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target1, Qubit target2);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target1, Qubit target2);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledS.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledS : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledSAdj.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledSAdj : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledSWAP.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledSWAP : IOperationFactory
9 | {
10 | void Body(Qubit qubit1, Qubit qubit2);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledT.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledT : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledTAdj.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledTAdj : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledX.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledX : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledY.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledY : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicApplyUncontrolledZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicApplyUncontrolledZ : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicExp.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicExp : IOperationFactory
9 | {
10 | void Body(IQArray paulis, double angle, IQArray targets);
11 |
12 | void AdjointBody(IQArray paulis, double angle, IQArray targets);
13 |
14 | void ControlledBody(IQArray controls, IQArray paulis, double angle, IQArray targets);
15 |
16 | void ControlledAdjointBody(IQArray controls, IQArray paulis, double angle, IQArray targets);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicH.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicH : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void ControlledBody(IQArray controls, Qubit target);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicM.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicM : IOperationFactory
9 | {
10 | Result Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicMZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicMZ : IOperationFactory
9 | {
10 | Result Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicMeasure.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicMeasure : IOperationFactory
9 | {
10 | Result Body(IQArray paulis, IQArray targets);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicR.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicR : IOperationFactory
9 | {
10 | void Body(Pauli pauli, double angle, Qubit target);
11 |
12 | void AdjointBody(Pauli pauli, double angle, Qubit target);
13 |
14 | void ControlledBody(IQArray controls, Pauli pauli, double angle, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, Pauli pauli, double angle, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicReset.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicReset : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicRx.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicRx : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 |
12 | void AdjointBody(double angle, Qubit target);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicRy.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicRy : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 |
12 | void AdjointBody(double angle, Qubit target);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicRz.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicRz : IOperationFactory
9 | {
10 | void Body(double angle, Qubit target);
11 |
12 | void AdjointBody(double angle, Qubit target);
13 |
14 | void ControlledBody(IQArray controls, double angle, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, double angle, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicS.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicS : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void AdjointBody(Qubit target);
13 |
14 | void ControlledBody(IQArray controls, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicSWAP.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Microsoft.Quantum.Simulation.Core;
6 |
7 | namespace Microsoft.Quantum.Intrinsic.Interfaces
8 | {
9 | public interface IIntrinsicSWAP : IOperationFactory
10 | {
11 | void Body(Qubit target1, Qubit target2);
12 |
13 | void ControlledBody(IQArray controls, Qubit target1, Qubit target2);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicT.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicT : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void AdjointBody(Qubit target);
13 |
14 | void ControlledBody(IQArray controls, Qubit target);
15 |
16 | void ControlledAdjointBody(IQArray controls, Qubit target);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicX.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicX : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void ControlledBody(IQArray controls, Qubit target);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicY.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicY : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void ControlledBody(IQArray controls, Qubit target);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IIntrinsicZ.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Quantum.Simulation.Core;
5 |
6 | namespace Microsoft.Quantum.Intrinsic.Interfaces
7 | {
8 | public interface IIntrinsicZ : IOperationFactory
9 | {
10 | void Body(Qubit target);
11 |
12 | void ControlledBody(IQArray controls, Qubit target);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IQSharpCore.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic.Interfaces
5 | {
6 | public interface IQSharpCore :
7 | IIntrinsicExp,
8 | IIntrinsicH,
9 | IIntrinsicMeasure,
10 | IIntrinsicR,
11 | IIntrinsicS,
12 | IIntrinsicT,
13 | IIntrinsicX,
14 | IIntrinsicY,
15 | IIntrinsicZ
16 | { }
17 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IType1Core.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic.Interfaces
5 | {
6 | public interface IType1Core :
7 | IIntrinsicApplyControlledX,
8 | IIntrinsicApplyControlledZ,
9 | IIntrinsicApplyUncontrolledH,
10 | IIntrinsicApplyUncontrolledRx,
11 | IIntrinsicApplyUncontrolledRy,
12 | IIntrinsicApplyUncontrolledRz,
13 | IIntrinsicApplyUncontrolledS,
14 | IIntrinsicApplyUncontrolledSAdj,
15 | IIntrinsicApplyUncontrolledT,
16 | IIntrinsicApplyUncontrolledTAdj,
17 | IIntrinsicApplyUncontrolledX,
18 | IIntrinsicApplyUncontrolledY,
19 | IIntrinsicApplyUncontrolledZ,
20 | IIntrinsicMZ,
21 | IIntrinsicReset
22 | { }
23 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IType2Core.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic.Interfaces
5 | {
6 | public interface IType2Core :
7 | IIntrinsicH,
8 | IIntrinsicApplyUncontrolledRxx,
9 | IIntrinsicApplyUncontrolledRyy,
10 | IIntrinsicApplyUncontrolledRzz,
11 | IIntrinsicMZ,
12 | IIntrinsicRx,
13 | IIntrinsicRy,
14 | IIntrinsicRz,
15 | IIntrinsicS,
16 | IIntrinsicSWAP,
17 | IIntrinsicT,
18 | IIntrinsicX,
19 | IIntrinsicY,
20 | IIntrinsicZ,
21 | IIntrinsicReset
22 | { }
23 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IType3Core.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic.Interfaces
5 | {
6 | public interface IType3Core :
7 | IIntrinsicApplyControlledX,
8 | IIntrinsicApplyControlledZ,
9 | IIntrinsicApplyUncontrolledH,
10 | IIntrinsicApplyUncontrolledRx,
11 | IIntrinsicApplyUncontrolledRy,
12 | IIntrinsicApplyUncontrolledRz,
13 | IIntrinsicApplyUncontrolledS,
14 | IIntrinsicApplyUncontrolledSAdj,
15 | IIntrinsicApplyUncontrolledSWAP,
16 | IIntrinsicApplyUncontrolledT,
17 | IIntrinsicApplyUncontrolledTAdj,
18 | IIntrinsicApplyUncontrolledX,
19 | IIntrinsicApplyUncontrolledY,
20 | IIntrinsicApplyUncontrolledZ,
21 | IIntrinsicMZ,
22 | IIntrinsicReset
23 | { }
24 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Interfaces/IType4Core.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic.Interfaces
5 | {
6 | public interface IType4Core :
7 | IIntrinsicApplyControlledX,
8 | IIntrinsicApplyControlledZ,
9 | IIntrinsicApplyUncontrolledH,
10 | IIntrinsicApplyUncontrolledRx,
11 | IIntrinsicApplyUncontrolledRy,
12 | IIntrinsicApplyUncontrolledRz,
13 | IIntrinsicApplyUncontrolledS,
14 | IIntrinsicApplyUncontrolledSAdj,
15 | IIntrinsicApplyUncontrolledSWAP,
16 | IIntrinsicApplyUncontrolledT,
17 | IIntrinsicApplyUncontrolledTAdj,
18 | IIntrinsicApplyUncontrolledX,
19 | IIntrinsicApplyUncontrolledY,
20 | IIntrinsicApplyUncontrolledZ,
21 | IIntrinsicMZ,
22 | IIntrinsicReset
23 | { }
24 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledS.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the π/4 phase gate to a single qubit. Note that the Controlled functor
9 | /// is not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// S \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & i
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | @TargetInstruction("s__body")
24 | internal operation ApplyUncontrolledS (qubit : Qubit) : Unit {
25 | body intrinsic;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledSAdj.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the -π/4 phase gate to a single qubit. Note that the Controlled functor
9 | /// is not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// SAdj \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & -i
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | @TargetInstruction("s__adj")
24 | internal operation ApplyUncontrolledSAdj (qubit : Qubit) : Unit {
25 | body intrinsic;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledT.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the π/8 gate to a single qubit. Note that the Controlled functor is
9 | /// not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// T \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & e^{i \pi / 4}
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | @TargetInstruction("t__body")
24 | internal operation ApplyUncontrolledT (qubit : Qubit) : Unit {
25 | body intrinsic;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledTAdj.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the -π/8 gate to a single qubit. Note that the Controlled functor is
9 | /// not supported.
10 | ///
11 | /// # Description
12 | /// \begin{align}
13 | /// TAdj \mathrel{:=}
14 | /// \begin{bmatrix}
15 | /// 1 & 0 \\\\
16 | /// 0 & e^{i -\pi / 4}
17 | /// \end{bmatrix}.
18 | /// \end{align}
19 | ///
20 | /// # Input
21 | /// ## qubit
22 | /// Qubit to which the gate should be applied.
23 | @TargetInstruction("t__adj")
24 | internal operation ApplyUncontrolledTAdj (qubit : Qubit) : Unit {
25 | body intrinsic;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledX.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the Pauli $X$ gate. Note that the Controlled functor is not supported.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// \sigma_x \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 0 & 1 \\\\
15 | /// 1 & 0
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | @TargetInstruction("x__body")
23 | internal operation ApplyUncontrolledX (qubit : Qubit) : Unit is Adj {
24 | body intrinsic;
25 | adjoint self;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledY.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the Pauli $Y$ gate. Note that the Controlled functor is not supported.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// \sigma_y \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 0 & -i \\\\
15 | /// i & 0
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | @TargetInstruction("y__body")
23 | internal operation ApplyUncontrolledY (qubit : Qubit) : Unit is Adj {
24 | body intrinsic;
25 | adjoint self;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/ApplyUncontrolledZ.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Targeting;
6 |
7 | /// # Summary
8 | /// Applies the Pauli $Z$ gate. Note that the Controlled functor is not supported.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// \sigma_z \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 1 & 0 \\\\
15 | /// 0 & -1
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | @TargetInstruction("z__body")
23 | internal operation ApplyUncontrolledZ (qubit : Qubit) : Unit is Adj {
24 | body intrinsic;
25 | adjoint self;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/H.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Applies the Hadamard transformation to a single qubit.
8 | ///
9 | /// # Description
10 | /// \begin{align}
11 | /// H \mathrel{:=}
12 | /// \frac{1}{\sqrt{2}}
13 | /// \begin{bmatrix}
14 | /// 1 & 1 \\\\
15 | /// 1 & -1
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | operation H (qubit : Qubit) : Unit is Adj + Ctl {
23 | body intrinsic;
24 | adjoint self;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/Properties/NamespaceInfo.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | /// # Summary
5 | /// This namespace contains built-in operations that represent
6 | /// commonly used quantum gates and measurements.
7 | ///
8 | /// # Description
9 | /// To learn more about the operations in this namespace, see
10 | /// [The Prelude](xref:microsoft.quantum.libraries.overview.standard.prelude).
11 | namespace Microsoft.Quantum.Intrinsic {}
12 |
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/Reset.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Given a single qubit, measures it and ensures it is in the |0⟩ state
8 | /// such that it can be safely released.
9 | ///
10 | /// # Input
11 | /// ## qubit
12 | /// The qubit whose state is to be reset to $\ket{0}$.
13 | operation Reset (qubit : Qubit) : Unit {
14 | body intrinsic;
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/S.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Applies the π/4 phase gate to a single qubit.
8 | ///
9 | /// # Description
10 | /// \begin{align}
11 | /// S \mathrel{:=}
12 | /// \begin{bmatrix}
13 | /// 1 & 0 \\\\
14 | /// 0 & i
15 | /// \end{bmatrix}.
16 | /// \end{align}
17 | ///
18 | /// # Input
19 | /// ## qubit
20 | /// Qubit to which the gate should be applied.
21 | operation S (qubit : Qubit) : Unit is Adj + Ctl {
22 | body intrinsic;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/T.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 | open Microsoft.Quantum.Diagnostics;
6 |
7 | /// # Summary
8 | /// Applies the π/8 gate to a single qubit.
9 | ///
10 | /// # Description
11 | /// \begin{align}
12 | /// T \mathrel{:=}
13 | /// \begin{bmatrix}
14 | /// 1 & 0 \\\\
15 | /// 0 & e^{i \pi / 4}
16 | /// \end{bmatrix}.
17 | /// \end{align}
18 | ///
19 | /// # Input
20 | /// ## qubit
21 | /// Qubit to which the gate should be applied.
22 | operation T (qubit : Qubit) : Unit is Adj + Ctl {
23 | body intrinsic;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/X.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Applies the Pauli $X$ gate.
8 | ///
9 | /// # Description
10 | /// \begin{align}
11 | /// \sigma_x \mathrel{:=}
12 | /// \begin{bmatrix}
13 | /// 0 & 1 \\\\
14 | /// 1 & 0
15 | /// \end{bmatrix}.
16 | /// \end{align}
17 | ///
18 | /// # Input
19 | /// ## qubit
20 | /// Qubit to which the gate should be applied.
21 | operation X (qubit : Qubit) : Unit is Adj + Ctl {
22 | body intrinsic;
23 | adjoint self;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/Y.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Applies the Pauli $Y$ gate.
8 | ///
9 | /// # Description
10 | /// \begin{align}
11 | /// \sigma_y \mathrel{:=}
12 | /// \begin{bmatrix}
13 | /// 0 & -i \\\\
14 | /// i & 0
15 | /// \end{bmatrix}.
16 | /// \end{align}
17 | ///
18 | /// # Input
19 | /// ## qubit
20 | /// Qubit to which the gate should be applied.
21 | operation Y (qubit : Qubit) : Unit is Adj + Ctl {
22 | body intrinsic;
23 | adjoint self;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Simulation/TargetDefinitions/Intrinsic/Z.qs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Quantum.Intrinsic {
5 |
6 | /// # Summary
7 | /// Applies the Pauli $Z$ gate.
8 | ///
9 | /// # Description
10 | /// \begin{align}
11 | /// \sigma_z \mathrel{:=}
12 | /// \begin{bmatrix}
13 | /// 1 & 0 \\\\
14 | /// 0 & -1
15 | /// \end{bmatrix}.
16 | /// \end{align}
17 | ///
18 | /// # Input
19 | /// ## qubit
20 | /// Qubit to which the gate should be applied.
21 | operation Z (qubit : Qubit) : Unit is Adj + Ctl {
22 | body intrinsic;
23 | adjoint self;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Type1 Targeting support for the Q# programming language.
6 |
7 |
8 |
9 |
10 | PreserveNewest
11 | true
12 | build/
13 | false
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.Type1.Core.dll
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Type2 Targeting support for the Q# programming language.
7 |
8 |
9 |
10 |
11 | PreserveNewest
12 | true
13 | build/
14 | false
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.Type2.Core.dll
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Type3 Targeting support for the Q# programming language.
7 |
8 |
9 |
10 |
11 | PreserveNewest
12 | true
13 | build/
14 | false
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.Type3.Core.dll
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/Type4Core/Microsoft.Quantum.Type4.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Type4 Targeting support for the Q# programming language.
7 |
8 |
9 |
10 |
11 | PreserveNewest
12 | true
13 | build/
14 | false
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Simulation/Type4Core/Microsoft.Quantum.Type4.Core.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.Type4.Core.dll
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/.gitignore:
--------------------------------------------------------------------------------
1 | linux
2 | osx
3 | win10
4 | target
5 | drop
6 |
7 | # In the future, it would be good to enable reproducible builds by committing
8 | # the lockfile and using --locked in calls to cargo.
9 | Cargo.lock
10 |
11 | # Ignore Python temporaries and build artifacts.
12 | *.pyd
13 | *.whl
14 | *.egg-info
15 |
16 | # Ignore generated C/C++ headers.
17 | include/
18 |
19 | # Don't ignore documentation here.
20 | !docs
21 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/build.rs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | fn main() -> Result<(), String> {
5 | built::write_built_file().expect("Failed to acquire build-time information");
6 |
7 | Ok(())
8 | }
9 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/cbindgen.toml:
--------------------------------------------------------------------------------
1 | language = "C"
2 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/docs-includes/after.html:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/docs-includes/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = ["setuptools", "wheel", "setuptools-rust"]
3 | build-backend = "setuptools.build_meta"
4 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/qdk_sim_experimental/version.py:
--------------------------------------------------------------------------------
1 | # Auto-generated file, do not edit.
2 | ##
3 | # version.py: Specifies the version of the qsharp package.
4 | ##
5 | # Copyright (c) Microsoft Corporation. All rights reserved.
6 | # Licensed under the MIT License.
7 | ##
8 | __version__ = "0.0.0.1"
9 | _is_conda = False
10 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/src/linalg/decompositions/mod.rs:
--------------------------------------------------------------------------------
1 | //! Support for various decompositions used in linear algebra.
2 |
3 | mod lu;
4 | pub use lu::*;
5 |
6 | mod eig;
7 | pub use eig::*;
8 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/src/math/mod.rs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | //! Functions and traits representing common mathematical functionality.
5 |
6 | mod sp_func;
7 | pub use sp_func::*;
8 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/tests/chp_simulation_tests.rs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | use qdk_sim::{error::QdkSimError, Pauli, Process, State};
5 |
6 | #[test]
7 | fn pauli_channel_applies_correctly() -> Result<(), QdkSimError> {
8 | let x = Process::new_pauli_channel(Pauli::X);
9 | let state = State::new_stabilizer(1);
10 | let output_state = x.apply(&state)?;
11 |
12 | let tableau = output_state.get_tableau().unwrap();
13 | tableau.assert_meas(0, true)
14 | }
15 |
--------------------------------------------------------------------------------
/src/Simulation/qdk_sim_rs/tests/serialization_tests.rs:
--------------------------------------------------------------------------------
1 | use assert_json_diff::assert_json_eq;
2 | use qdk_sim::NoiseModel;
3 | use serde_json::Value;
4 |
5 | // Use include_str! to store test case JSON as a string into the compiled
6 | // test executable.
7 | static IDEAL_NOISE_MODEL_JSON: &str = include_str!("data/ideal-noise-model.json");
8 |
9 | #[test]
10 | fn ideal_noise_model_serializes_correctly() {
11 | let noise_model = NoiseModel::ideal();
12 | let expected: Value =
13 | serde_json::from_str(&(serde_json::to_string(&noise_model).unwrap())).unwrap();
14 |
15 | assert_json_eq!(noise_model, expected);
16 | }
17 |
18 | #[test]
19 | fn ideal_noise_model_deserializes_correctly() {
20 | let actual: NoiseModel = serde_json::from_str(IDEAL_NOISE_MODEL_JSON).unwrap();
21 |
22 | assert_json_eq!(actual, NoiseModel::ideal());
23 | }
24 |
--------------------------------------------------------------------------------
/src/Xunit/Exceptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Microsoft.Quantum.Simulation.XUnit
11 | {
12 | public class TestOperationException : Exception
13 | {
14 | public TestOperationException(string message) : base(message)
15 | {
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Xunit/Microsoft.Quantum.Xunit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net6.0
8 | x64
9 | false
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------