A simple Quantum Gate Simulator implemented in C++, paired with a Node.js-based GUI Visualizer for an interactive experience.
The simulator allows you to store and apply various quantum gates to qubit states and provides a visual interface to see the results of quantum operations in action.
This project is divided into two main parts:
- Implements basic quantum mechanics concepts such as qubit state representation and quantum gate operations.
- Provides a comprehensive set of quantum gates:
- Single-qubit gates: Identity, Pauli-X/Y/Z, Hadamard, Phase (S), T-Gate, Rotation gates (Rx, Ry, Rz)
- Two-qubit gates: CNOT, CZ, SWAP
- Advanced multi-qubit gates: Toffoli (CCX), Fredkin (CSWAP), Multi-controlled X/Z, Quantum Fourier Transform (QFT)
- Uses manual matrix operations (without external libraries like Eigen) to evolve quantum states.
- Includes validation tests for advanced algorithms like Grover's search.
- A frontend interface that communicates with the C++ simulator.
- Allows users to drag and drop gates onto qubits, build circuits, and see the resulting state evolution.
- Visualizes quantum states using:
- Bloch spheres
- Probability histograms
- Quantum Gate Storage – Manage and apply common gates easily.
- State Evolution – Apply operations on qubits and observe transformations.
- Advanced Multi-Qubit Gates – Full support for Toffoli, Fredkin, multi-controlled gates, and QFT.
- Algorithm Implementation – Grover's search algorithm validation and testing.
- Interactive GUI – User-friendly Node.js frontend with drag-and-drop interface.
- Separation of Concerns – C++ handles computation, Node.js handles visualization.
- High Precision – Numerical accuracy with < 1e-12 error tolerance.
- C++ Compiler (e.g.,
g++
) - Node.js (>= 16.0.0)
- npm (comes with Node.js)
# Navigate to the backend folder
cd backend
# Compile the simulator
g++ main.cpp -o simulator
# Run the simulator
./simulator
# Navigate to the frontend folder
cd frontend
# Install dependencies
npm install
# Start the GUI
npm start
The frontend will connect with the backend to visualize quantum gate operations.
- Start the C++ backend (
./simulator
). - Run the Node.js GUI (
npm start
). - Open the interface in your browser (default:
http://localhost:3000
). - Drag and drop gates onto qubits, then visualize state changes.
Example workflow:
- Initialize a |0⟩ qubit
- Apply a Hadamard gate → get a superposition state
- Apply a Pauli-Z gate → observe phase flip on the Bloch sphere
The simulator now includes advanced multi-qubit gates essential for quantum algorithms:
apply_toffoli_gate(state, len, ctrl1, ctrl2, target);
Applies X gate to target qubit when both control qubits are in |1⟩ state.
apply_fredkin_gate(state, len, ctrl, target1, target2);
Swaps target1 and target2 qubits when control qubit is in |1⟩ state.
// Multi-controlled X
apply_multi_controlled_x(state, len, controls, target);
// Multi-controlled Z
apply_multi_controlled_z(state, len, controls, target);
Apply X or Z gate when all control qubits are in |1⟩ state.
// Full QFT
apply_qft(state, len, qubits, inverse);
// Decomposed QFT (more efficient)
apply_qft_decomposed(state, len, qubits, inverse);
Performs quantum Fourier transform on specified qubits.
The included test file demonstrates Grover's search algorithm using the advanced gates:
# Build and run the test
cmake .
make grover_test
./grover_test
We welcome contributions! To get started:
- Fork the repository
- Create a new branch for your feature/bugfix
- Commit your changes with clear messages
- Push your branch and submit a Pull Request (PR)
Please ensure:
- Code is well-documented
- New features include usage examples or tests
qubitverse/
│── .github/workflows/
│ └── cmake-single-platform.yml
│
│── qubitverse/
│ ├── simulator/ # C++ quantum gate simulator
│ │ ├── dep/
│ │ ├── gates/
│ │ ├── lexer/
│ │ ├── parser/
│ │ └── simulator/
│ │
│ └── visualizer/ # Node.js GUI visualizer
│ ├── public/
│ ├── src/
│ ├── eslint.config.js
│ ├── index.html
│ ├── package.json
│ └── vite.config.js
│
│── .clang-format
│── .clang-tidy
│── .clangd
│── .gitignore
│── CMakeLists.txt
│── compile.rc
│── CONTRIBUTING.md
│── LICENSE
│── README.md
- Add multi-qubit support
- Implement CNOT and controlled gates
- Implement advanced multi-qubit gates (Toffoli, Fredkin, QFT)
- Improve visualization with real-time animations
- Add export/import of circuits**
- Provide a hosted live demo
- Add quantum error correction support
- Implement variational quantum algorithms
This project is licensed under the MIT License.
See the LICENSE file for details.
- Inspired by basic concepts of Quantum Computing.
- Educational references: Nielsen & Chuang - Quantum Computation and Quantum Information.
- Open-source tools and the developer community.