page_type | languages | products | description | |||
---|---|---|---|---|---|---|
sample |
|
|
This sample implements a simple reversible simulator for Q# using the `IQuantumProcessor` interface. |
This samples shows how to build a simple reversible simulator. It is very
similar to the existing Toffoli
simulator,
but presented as an example of how to use the IQuantumProcessor
interface. A
reversible simulator can simulate quantum programs that consist only of
classical operations: X
, CNOT
, CCNOT
(Toffoli gate), or arbitrarily
controlled X
operations. Since a reversible simulator can represent the
quantum state by assigning one Boolean value to each qubit, it can run even
quantum programs that consist of thousands of qubits. This simulator is very
useful for testing quantum operations that evaluate Boolean functions.
- The Microsoft Quantum Development Kit.
This sample can be run in a number of different ways, depending on your preferred environment.
At a terminal, run the following command:
dotnet run
Open the folder containing this sample in Visual Studio ("Open a local folder"
from the Getting Started screen or "File → Open → Folder..." from the menu bar)
and set ReversibleSimulator.csproj
as the startup project. Press Start in
Visual Studio to run the sample.
- Operation.qs: Q# code implementing quantum operations for this sample.
- Simulator.cs: C# implementation of a reversible simulator using the
IQuantumProcessor
interface. - Driver.cs: C# code running the quantum operations with the reversible simulator.
- ReversibleSimulator.csproj: C# project for the sample.