Crates.io | bra_ket |
lib.rs | bra_ket |
version | 0.1.4 |
source | src |
created_at | 2022-06-04 14:57:54.504591 |
updated_at | 2023-09-19 16:42:07.252964 |
description | A multithreaded circuit model quanutm simulator for state vectors and density matrices. |
homepage | |
repository | https://github.com/b-vanstraaten/bra_ket |
max_upload_size | |
id | 599737 |
size | 129,809 |
This is a Rust-based quantum simulator that provides an identical interface for state vector and density matrix simulations. It is fully parallelized using the Rayon library. This project was developed as a learning exercise in Rust programming and qubit simulation.
To use this quantum simulator, you need to have Rust and Cargo (Rust's package manager) installed on your system. If you don't have Rust installed, you can download it from the official website: Rust Installation.
then add it as dependancy in your Cargo.toml
:
[dependencies]
bra_ket = "0.1.3"
Make sure to replace "0.1.2"
with the actual version number from the release you want to use.
Then, in your Rust code:
use bra_ket::*;
fn main() {
// creating the quantum program
let mut program = Program::new();
program.h(0);
program.cnot(0, 1);
program.cnot(0, 2);
// drawing the program
program.draw();
// creating a three qubit state vector / density matrix to hold the quantum state
let mut state_vector = StateVector::new(3);
let mut density_matrix = DensityMatrix::new(3);
// running the program to evolve the state vector from its
//initial state of |000> to (1 / SQRT_2) *(|000> + |111>)
program.run(&mut state_vector);
program.run(&mut density_matrix);
// printing the final state vector / density matrix
println!("state vector \n{}", state_vector);
println!("density matrix \n{}", density_matrix);
}
This code produces the GHZ state (1 / SQRT_2) *(|000> + |111>) in both state vector and density matrix representations.
For detailed documentation and examples, please refer to the official documentation.
This section provides a brief overview of the example files included in the examples
folder of this quantum simulator project. These examples demonstrate how to use the quantum simulator to simulate various quantum algorithms and circuits. You can find the complete source code for each example in the examples
folder.
ghz_state.rs
Description: This example demonstrates the creation of a Greenberger-Horne-Zeilinger (GHZ) state using a quantum circuit. The GHZ state is an entangled quantum state that plays a crucial role in quantum information theory.
Usage: To run this example, execute the following command from the project root directory:
cargo run --example ghz_state
qft.rs
Description: The Quantum Fourier Transform (QFT) is a quantum algorithm that efficiently computes the discrete Fourier transform of a quantum state. This example demonstrates the implementation of the QFT using the quantum simulator.
Usage: To run this example, execute the following command:
cargo run --example qft
shors.rs
Description: Shor's algorithm is a quantum algorithm that can efficiently factor large numbers. This example showcases the implementation of Shor's algorithm using the quantum simulator.
Usage: To run this example, execute the following command:
cargo run --example shors
vge.rs
Description: The Variational Quantum Eigensolver (VQE) is a quantum algorithm used for finding the ground state energy of a quantum system. This example demonstrates how to use the quantum simulator to perform a VQE calculation for H2, it computes the ground state energy and plots the energy landscape.
Usage: To run this example, execute the following command:
cargo run --example vqe
These example files provide a starting point for experimenting with quantum algorithms and circuits using the Rust Quantum Simulator. You can modify and extend them to explore different quantum computing concepts and applications.
This project was developed as a learning exercise, but contributions are welcome! If you want to contribute, please:
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Quantum Computing! 🌌🔬🧬