Python library for simulating quantum computor and algorithm.
Project description
Quanbit
About
Quanbit is a pythonic package for simulating quantum computer. It faciliate basic quantum algorithm exploration on a classic computer.
Platform
Quanbit is a pure python package supporting Windows
, Linux
and MacOS
.
Example: Quantum Teleportation
from quanbit import X, Y, Z, BellBasis
from quanbit import cubit, bell_state, Measure
import numpy as np
# Alice has an unknown qubit C
theta, phi, alpha = np.random.rand(3)
qubit_C = cubit(theta, phi, alpha)
# To teleport the cubit, Alice and Bob need to share a maximally entangled state
# Anyone of the four states is sufficient, we choose 1/sqrt(2) (|00> + |11>) here
qubit_AB = bell_state(0)
# Now the total state is, where @ represent tensor product:
total_state = qubit_C @ qubit_AB
# Project the state of Alice's two qubits as a superpositions of the Bell basis
total_state = BellBasis(total_state, [0, 1])
# Measuring her two cubits in Bell basis
CA, B_state = Measure(total_state, indices[0, 1])
# Rotate Bob's state based on the measurement result
# if CA == (0, 0), no change need to be made
# when CA is in state \Psi+
if CA == (0, 1):
B_state = X(B_state)
# when CA is in state \Psi-
elif CA == (1, 0):
B_state = Z(X(B_state))
# when CA is in state \Phi-
elif CA == (1, 1):
B_state = Z(B_state)
# Now Bob's state is the same as Alice initial qubit_C.
License
Quanbit is distributed under BSD 3-Clause.
Dependence
- Installation requirements:
numpy
- Testing requirement:
pytest
- QA requirement:
tox
Installation
To run tests:
pytest quanbit
To install Quanbit to system:
pip install .
Local build and Testing
To install editable Quanbit locally:
pip install -e .
To run tests:
pytest tests
Quality Assurance
To run QA locally:
tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quanbit-0.0.1.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file quanbit-0.0.1.tar.gz
.
File metadata
- Download URL: quanbit-0.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4166a5d101bf5d07f5f9f17ffcd6e831a4bad32d01d293c7eccd3bb1a433a22c |
|
MD5 | 797158b49c45f074c50f1eb19445be18 |
|
BLAKE2b-256 | 4c8b1cdc58fa285e2f10e0d68ed82d54144e7b5b2df069044475ea1d4718fa3f |
Provenance
File details
Details for the file quanbit-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: quanbit-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e854aff3655a346f237a6f55cdbbaf8fd8d48966455b022e8843a9c1e7a6f90 |
|
MD5 | 0e2ce1a72db06fe5930d0fe1f597a180 |
|
BLAKE2b-256 | 193f1939698f3b56fcda3bdbf44721e5203a4eaa912a770d332be8115f0e0ac6 |