Giter VIP home page Giter VIP logo

stabilizer-simulator's Introduction

AUTHOR: John Gardiner

REQUIREMENTS: Python 3.5 or higher

CODE STRUCTURE:  The file simulator.py defines five functions. The main one is
simulate(), which takes as input a qasm file, formatted as 

OPENQASM 2.0;
include "qelib1.inc";
qreg q[<number of qubits>];
creg c[<number of qubits>];
<first gate in the circuit>
<second gate in the circuit>
.
.
.
<last gate in the circuit>

where each gate is a line of the form

cx q[0],q[1];

for example. The simulator currently only allows for the single qubit 
gates h, x, t, tdg and the two-qubit gate cx, all notated thus. It 
outputs a 2**n by 1 numpy array whose entries represent the amplitudes 
of the quantum state that results from acting on |0...0> with the 
circuit. Here n is the number of qubits that are nontrivially involved
in the circuit. The output uses the same ordering convention for qubits
as the Cirq simulator and ignores any qubits that are unused in the 
circuit.

The other functions are auxiliary functions to simulate(). The function
qasm_string_to_gates() takes as input a qasm string and outputs a list
whose entries represent the gates in the circuit. The function
stabilizers_to_state() takes inputs representing the stabilizers and
destabilizers and coefficients in the stabilizer basis and outputs a 
numpy array whose entries represent the state described by the
coefficients and the stabilizer basis. See the comments within the code
for more detail. The function stabilizer_simulator() takes as input a 
list of gates (as output from qasm_string_to_gates() for example) and
outputs a numpy array whose entries represent the amplitudes of the 
quantum state obtained by acting on |0...0> with the circuit described
by the gates in the input list. There is one final function,
qasm_file_to_string(), which is not called by any other function, but is
included in the file because it can be useful for testing purposes.
This function takes as input a text file formatted according to the
grammar in a-subset-of-qasm.pdf on Bruinlearn and simply outputs the text
as a single string.

simulate() calls qasm_string_to_gates() and stabilizer_simulator().
stabilizer_simulator() calls stabilizers_to_state().

stabilizer-simulator's People

Contributors

johngoldengardiner avatar

Watchers

 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.