Skip to main content

A simple qubit simulator

Project description

Qubit Simulator

Qubit Simulator is a simple and lightweight library that provides a quantum statevector simulator for simulating qubits and quantum gates. It supports basic quantum operations and gates using NumPy.

Installation

Install Qubit Simulator via pip:

pip install qubit-simulator

Usage

Initializing the Simulator

Create a simulator with a specified number of qubits:

from qubit_simulator import QubitSimulator

simulator = QubitSimulator(3)

Applying Gates

Apply various quantum gates to the qubits:

simulator.h(0)      # Hadamard gate
simulator.t(1)      # π/8 gate
simulator.cx(0, 2)  # Controlled-Not gate

Custom Gates

Define and apply custom gates using angles:

simulator.u(0.3, 0.4, 0.5, 2)  # Generic gate

Measurements

Measure the state of the qubits:

print(simulator.run(shots=100))
{'000': 46, '001': 4, '100': 4, '101': 46}

Testing

Tests are included in the package to verify its functionality and provide more advanced examples:

python3 -m pytest tests/

License

This project is licensed 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

qubit_simulator-0.0.9.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qubit_simulator-0.0.9-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file qubit_simulator-0.0.9.tar.gz.

File metadata

  • Download URL: qubit_simulator-0.0.9.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for qubit_simulator-0.0.9.tar.gz
Algorithm Hash digest
SHA256 0c54df6a3300ae59c233aa0183e7ab28133b2f9cdf6427cd30cb04d3213644ad
MD5 261ee6ddb3a0416fa115b980e305b5c8
BLAKE2b-256 ce4dfc29541475e8860bc336e9ead4c7e71a19ed50f60f60eb5a92f02b4656b2

See more details on using hashes here.

File details

Details for the file qubit_simulator-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for qubit_simulator-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8997987224ab3c87daeacb8b932619d12d7b9ae8b4fac9f1fe8e86b8ded101b3
MD5 31323f5c9484bff7bb2fd265aedd8f79
BLAKE2b-256 616686d3badce5c0520ec3d07801c19c0709479b721a213dd43e22d068610fff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page