Giter Site home page Giter Site logo

quantum's Introduction

quantum

Play with quantum gates

Usage

Edit src/quantum.cxx and make a circuit using C++ code, but in a way that looks much like the normal way quantum circuits are compsed. For example,

    q[1] - H - co(0) - H - measure(0);
    q[0]     - CX(0) - S - H - T_inv - H - measure(1);

Here each q[...] is a qubit, H is the Hademar gate, etc (see Gates.h for a list of all standard gates). co(int) is the control input of a controlled CNOT while CX(int) with the same int, is the corresponding controlled input. Finally, measure(int) measures to classical bit int. You must specify the number of qubits and classical bits at the moment you create q.

Note that there can only be a single minus sign between the gates.

Wave function collapse and shots

THIS IMPLEMENTATION DOES NOT COLLAPSE THE WAVE FUNCTION.

This is important to me, because I don't believe in wave function collapses. That only appears to be the case when you yourself get entangled with the quantum superposition that you try to measure.

Therefore, you can continue to put more gates after a measure(int) as well: the state was not changed (it WAS however entangled with the measured "classical" bit).

As a result, you do not need any "shots" (run the circuit many times to get approximate statistics). The statistics on chance of the measurements are simply calculated in parallel, using the normal quantum computer power of doing things in parallel.

Accuracy, round off errors and noise.

THIS IMPLEMENTATION HAS NO NOISE, AND NO ROUND OFF ERRORS.

This implementation uses a field extension to the rationals, for which GMP is used for infinite accuracy. Hence, the results are infinitely precise.

For example, the above circuit results in the following output:

0₁0₀: (1/4 + 1/4·i - 1/2·i·√½)·|0₁0₀⟩   Chance: 1/4 - 1/4·√½
1₁0₀: (1/4 + 1/4·i + 1/2·i·√½)·|0₁1₀⟩   Chance: 1/4 + 1/4·√½
0₁1₀: (1/4 - 1/4·i + 1/2·√½)·|1₁0₀⟩     Chance: 1/4 + 1/4·√½
1₁1₀: (1/4 - 1/4·i - 1/2·√½)·|1₁1₀⟩     Chance: 1/4 - 1/4·√½

where in the left column, before the colon, you see the possible classical measurements for classical bits 0 and 1, and on the right the exact chance. In the middle you see the corresponding (collapsed) wave function of the circuit that belongs to that reality.

Installation

As usual, I only support linux. If you use something else then you're on your own; although, I mostly use standard C++ - so porting shouldn't be hard for another developer.

To install this project out-of-the-box you will need to have GNU autotools installed. In order to see debug output, you need to have libcwd compiled and installed.

This project uses git submodules. To clone this project, have the above installed and simply run:

git clone --recursive https://github.com/CarloWood/quantum.git
cd quantum
./autogen.sh

After that it is the usual,

./configure
make

assuming you're familiar with GNU autotool projects.

quantum's People

Contributors

carlowood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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