Giter Club home page Giter Club logo

circuitsimulator's Introduction

CircuitSimulator

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.

Installation

  1. 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.

  1. Install numpy

Download numpy from https://pypi.python.org/pypi/numpyor use pip. Scipy is not required.

  1. (Optional) Install matplotlib

The 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.

  1. Download the code

Press the clone or download button above and press "Download ZIP" or open up a terminal and type

$ git clone [email protected]:patrickrall/CircuitSimulator.git
  1. Compile the code C implementation

On Mac OS X and Linux simply:

  1. Open a terminal
  2. Change into the root directory: $ cd CircuitSimulator
  3. Call make: $ 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.

Usage

There are two ways to use CircuitSimulator:

  1. Use the main.py handle to compile a circuit and run an algorithm.

Examples:

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.

  1. Import the libcirc/probability.py file and use the probability() and sampleQubits() functions.

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. Read circuits/hiddenshift.py for guidance when writing your own code and/or consult the documentation.

circuitsimulator's People

Contributors

iskrenvankov avatar patrickrall avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.