quantsim_core

Crates.ioquantsim_core
lib.rsquantsim_core
version0.2.0
created_at2025-09-21 20:51:28.52933+00
updated_at2025-09-21 22:30:35.532628+00
descriptionA quantum circuit simulator
homepage
repositoryhttps://github.com/benschneider/quantum_algorithm_simulator
max_upload_size
id1849184
size140,114
Dr. Ben (benschneider)

documentation

README

quantsim_core

License [Rust]

A pure Rust library for quantum circuit simulation. This crate provides the core simulation engine for quantum computing, designed to be portable and reusable without any UI dependencies.

Features

  • Pure Rust Implementation: No UI dependencies, making it suitable for integration into any Rust project
  • Comprehensive Gate Library: Support for standard quantum gates including single-qubit, multi-qubit, and parametric gates
  • Custom Gate Support: Define your own unitary gates programmatically
  • Embedded Circuit Templates: Built-in quantum algorithm examples (Bell states, Grover's algorithm, QFT, etc.)
  • Parallel Execution: Uses Rayon for efficient parallelization of computationally intensive operations
  • Introspection API: Detailed per-timestep snapshots of quantum state evolution
  • JSON Serialization: Easy circuit persistence and sharing

Usage

Add this to your Cargo.toml:

[dependencies]
quantsim_core = "0.1.0"

Basic Example

use quantsim_core::{Circuit, Engine, GateRegistry};

let mut registry = GateRegistry::new();
registry.register_standard_gates();

// Create a Bell state circuit
let mut circuit = Circuit::new(2);
circuit.add_gate("H", &[0]).unwrap();
circuit.add_gate("CX", &[0, 1]).unwrap();

// Simulate
let mut engine = Engine::new();
let result = engine.run(&circuit, None).unwrap();

println!("Final state: {:?}", result.final_state);

Loading Built-in Templates

use quantsim_core::circuits;

let bell_circuit = circuits::load_template("bell").unwrap();

Architecture

The library is organized into several key modules:

  • circuit: Quantum circuit representation and manipulation
  • engine: Simulation execution engine
  • gates: Gate definitions and registry system
  • types: Core data types and representations
  • circuits: Built-in circuit templates

Performance

  • Parallel gate application using Rayon
  • Efficient state vector representation
  • Optimized for both small educational circuits and larger quantum algorithms

License

Licensed under either of

at your option.

Commit count: 40

cargo fmt