quantum  Motivation

Quantum is a quantum computer simulator written with the following design goals in mind:

1. Utility: we can simulate a 5-qubit register, enough to run interesting algorithms.

2. Efficiency: we implement all important operations from scratch using primitives

3. Educational Value: the documentation is a prose description of how to implement a quantum computer in Rust.

4. Correctness: it's entirely written in safe Rust with well-defined states.

A good place to start reading the theory behind this is the Wikipedia article, and you can follow the documentation for our implementations of gates, kets, common operations, and quantum registers.

Usage

# Cargo.toml

[dependencies]
quantum = "0.1.3"
// main.rs

use computer::QuantumComputer;
use algorithms::deutsch;
use gates;

// Let's do something simple of a 3-qubit system.
let mut c1 = QuantumComputer::new(3);
c1.initialize(5);
c1.apply(gates::identity(3));
c1.collapse();
assert_eq!(5, c1.value());

// Now let's perform a coin flip using the Hadamard transform.
let mut c2 = QuantumComputer::new(1);
c2.initialize(0);
c2.collapse();
let result = if 1 == c2.value() { "heads" } else { "tails" };
println!("coin flip: {}", result);

// Finally let's determine whether f: {0, 1} -> {0, 1} is constant
// or balanced using Deutsch's algorithm.
// (see http://physics.stackexchange.com/q/3400)
let mut c3 = QuantumComputer::new(2);
c3.initialize(1);
c3.apply(deutsch::deutsch_gate(f));
c3.collapse();
let result = if 1 == c3.value() { "constant" } else { "balanced" };
println!("f is: {}", result);

Gates

We provide the following quantum gates:

• Identity
• Pauli-X
• Pauli-Y
• Pauli-Z
• Phase Shifts
• Swap
• Sqrt(Swap)
• Controlled Not
• General Controlled-U
• Controlled-X
• Controlled-Y
• Controlled-Z
• Toffoli
• Fredkin
• Quantum Fourier Transform

Contributing

• Create or take ownership of an issue
• Fork development branch
• Write code and tests
• rust test
• Commit with a reasonable message and push
• Submit a pull request

• Could you publish the latest library please

Jan 18, 2018

I am getting the following error:

Updating registry `https://github.com/rust-lang/crates.io-index`
error: no matching version `^0.1.3` found for package `quantum` (required by `quantum`)
location searched: registry `https://github.com/rust-lang/crates.io-index`
versions found: 0.1.2, 0.1.0

Thank you & BR,

Maciej

• Unitary matrices: a possible implementation.

Dec 25, 2017

Hi!

I saw that your project needs a check for the input matrix to be unitary, in some of its parts. I came across the nalgebra crate, which provides a framework for linear algebra. In particular, they provide a nice trick to avoid checks for unity, by exposing a Unit wrapper.

Best,

Filippo.

• Should have benchmarks

Aug 1, 2016

We should add some benchmarking using the best-practice Rust solution.

This will allow us to:

• measure current performance
• stop us regressing performance
• justify our README claim of efficiency
enhancement
• Should allow gate transformations

Aug 1, 2016

We need to allow, e.g. a reversed control-not gate.

At the moment the gates::* implementations are set to use, e.g. the first qubit as a control.

The solution is to allow gate transformations which will do things like permute underlying matrix rows/columns. Then we could change the interfaces to accepting parameters.

enhancement