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[visualization]

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

Circuit Drawing

Get a drawing of the circuit:

simulator.draw()

Circuit Drawing

Measurements

Measure the state of the qubits:

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

Statevector Plot

Show the amplitude and phase of all quantum states:

simulator.plot_state()

Statevector Bar Chart

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.1.0.tar.gz (8.7 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.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qubit_simulator-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 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.1.0.tar.gz
Algorithm Hash digest
SHA256 c71b19dbd50f8bea1b339e7401fae4efb028b77f0e01cd549a84c85e81ded6d7
MD5 f34858348b42be8fd838968508be3658
BLAKE2b-256 a5c1f227c0c592603b2f7765144294a3a0a23890528ab3da31e577b7869b487d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qubit_simulator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6199a78e805b0f6632725b4285b7672c908665a34cdcae98a46b5dfef6b23fa
MD5 512d902720126192ecfe9a4b8b290fb0
BLAKE2b-256 899f318446604d246cb9503f431af105b4e0b71d3ed57636cea5a55f83e9efa4

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