Crates.io | quantum |
lib.rs | quantum |
version | 0.1.2 |
source | src |
created_at | 2016-07-22 21:40:12.249065 |
updated_at | 2016-07-26 22:11:59.339475 |
description | Advanced Rust quantum computer simulator. |
homepage | https://github.com/beneills/quantum/ |
repository | https://github.com/beneills/quantum.git |
max_upload_size | |
id | 5756 |
size | 39,116 |
Advanced Rust quantum computer simulator.
Quantum is a quantum computer simulator written with the following design goals in mind:
Utility: we can simulate a 5-qubit register, enough to run interesting algorithms.
Efficiency: we implement all important operations from scratch using primitives
Educational Value: the documentation is a prose description of how to implement a quantum computer in Rust.
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.
# Cargo.toml
[dependencies]
quantum = "0.1.2"
// main.rs
use computer::QuantumComputer;
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 Hadamard transform.
let mut c2 = QuantumComputer::new(1);
c2.initialize(0);
c2.apply(gates::hadamard());
c2.collapse();
let result = if 1 == c2.value() { "heads" } else { "tails" };
println!("coin flip: {}", result);
rust test