A quantum circuit simulator based on http://arxiv.org/abs/1601.07601. Features:
- A simple programming language for quantum circuits in the Clifford+T gate set
- An algorithm for sampling from the output distribution of a circuit
- An algorithm for calculating the probability of a particular output for a circuit
This application is written in python, a cross-platform programming language. A C implementation also is available for the slow part of both algorithms. The C implementation is used by default, but a python-only version is also available.
See the documentation for a complete description, once it is available.
- Install python
Python 3 is recommended, although the code should still work in python 2. Download from https://www.python.org/downloads/ or use your favorite package manager.
- Install numpy
Download numpy from https://pypi.python.org/pypi/numpyor use pip. Scipy is not required.
- (Optional) Install matplotlib
circuits/hiddenshift.py test script generates a plot similar to the one in http://arxiv.org/abs/1601.07601 using matplotlib. You can disable this but setting
plot = False on line 30, or you can download and install matplotlib from http://matplotlib.org/users/installing.html.
- Download the code
Press the clone or download button above and press "Download ZIP" or open up a terminal and type
$ git clone email@example.com:patrickrall/CircuitSimulator.git
- Compile the code C implementation
On Mac OS X and Linux simply:
- Open a terminal
- Change into the root directory:
$ cd CircuitSimulator
- Call make:
On Windows, a precompiled executable is available at
libcirc/sample.exe. Tell the
main.py executable to use it by passing
cpath=libcirc/sample.exe as an option. If that does not work, try the
-py option to use the python back-end.
There are two ways to use CircuitSimulator:
- Use the
main.pyhandle to compile a circuit and run an algorithm.
python main.py circuits/toffoli.circ MMM python main.py circuits/HTstack.circ 0
A full usage statement is available:
python main.py -h
Or just read the documentation.
- Import the
libcirc/probability.pyfile and use the
This is useful for automatically generated circuits that need to be evaluated. The
circuits/hiddenshift.py file does exactly this: it randomly generates a circuit implementing the hidden shift algorithm and evaluates it immediately.
circuits/hiddenshift.py for guidance when writing your own code and/or consult the documentation.