A simple qubit simulator
Project description
QubitSimulator Library
Overview
QubitSimulator
is a simple and lightweight quantum computing simulator library implemented in Python. It provides basic functionalities for simulating quantum circuits with commonly used quantum gates, including Hadamard, $\frac{\pi}{8}$, and Controlled-NOT gates. You can also perform measurements on qubits and run the quantum circuit for multiple shots.
Features
- Universal gate set (H, T, CNOT)
- Generic gate (U)
- Measure in custom basis
- Circuit printing
Installation
pip install qubit_simulator
Usage
Initialization
Initialize the QubitSimulator with the number of qubits:
from qubit_simulator import QubitSimulator
simulator = QubitSimulator(2)
Applying Gates
Apply the H, T, and CNOT gates to the specified qubits:
simulator.H(0)
simulator.T(1)
simulator.CNOT(0, 1)
Measurements
Perform a measurement on the qubits:
simulator.Measure()
['11']
Running the Circuit
Run the quantum circuit for a specified number of shots:
simulator.run(shots=10)
{'11': 6, '00': 4}
Tests
python -m pytest
License
This library is open-source and available under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qubit_simulator-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8526ff3a54e79e14076295170a641efcb21781c7cfc1c03abf57c0c36d5b1b80 |
|
MD5 | 5bbab7ad6b164765f11b3d27cacb12c0 |
|
BLAKE2b-256 | 66fd65da0820193e76382adaf8db283a0a362fd1c0eb8eb8eb7438cb905d78ee |