Giter VIP home page Giter VIP logo

qcircuitgen's Introduction

Quantum Circuit Generator for LaTeX

This is a script that takes an ASCII representation of a quantum circuit and generates commands to draw it in LaTeX's picture environment.

To use it, you must first copy the gates.tex file into the same folder as your document and then, once, do:

\input{gates.tex}

The picture command generated by the script can be placed anywhere in your document below that line.

This script takes a text description of the circuit as input. Circuits are encoded as follows:

  1. Each line of the file is one qubit (horizontal line in the circuit).
  2. Each character on a line corresponds to what to draw from that position. This could be a single-qubit gate (e.g. Z for the Z gate), or part of a multi-qubit gate with a line extending upwards or downwards (explained below).

You can draw circuits using the following primitives:

  • Single Qubit Gates: X, Z, H, and I (identity).
  • Control lines: U for a control dot with a line going up, leaving room for a boxed gate above, and P for a control dot with a line going up, touching the line above. Similarly, for control lines going down, D (leaving room for a boxed gate below), and N (touching the line below).
  • For the XOR/OPLUS symbol part of a CNOT gate, use O.
  • For circuits with more than two qubits, you may have to draw a line "crossing over" another one without touching. This can be done using L (going up) and V going down.
  • Swap gates can be drawn by putting an S on the topmost qubit of the swap and W on the bottommost qubit of the swap (with optional crossover lines with L as necessary).

Your input is not sanity checked, i.e. you can have lines extending upward from the top qubit, so make sure you get your input right.

Example

Here is a three-qubit circuit illustrating how to use the primitives:

SSHXIHNN
WLHZONNV
IWUIPOOO

Once the output commands are rendered, it looks like:

Circuit Image

qcircuitgen's People

Contributors

defuse avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.