A quantum computing simulator for Python
Project description
QSystem
A quantum computing simulator for Python.
The QSystem simulator is inspired in the quantum circuit model, so it's easy to convert any quantum circuit to Python.
Like the follow example:
from qsystem import Gates, QSystem
from cmath import exp, pi
gates = Gates()
q = QSystem(3, gates, 24) # init q0, q1, q2
q.evol(gate='H', qbit=0, count=3) # H q0; H q1; H q2
q.add_ancillas(4) # init a0, a1, a2, a3
q.evol(gate='X', qbit=6) # X a3
q.cnot(target=4, control=[2]) # CNOT a1, q2
q.cnot(5, [2]) # CNOT a2, q2
q.cnot(5, [3]) # CNOT a2, a0
q.cnot(3, [1, 5]) # Toffoli a1, q1, a2
q.cnot(5, [3]) # CNOT a2, a0
q.cnot(4, [6]) # CNOT a1, a3
q.cnot(6, [1, 4]) # Toffoli a3, q1, a1
q.cnot(4, [6]) # CNOT a1, a3
q.measure(qbit=3, count=4) # measure a0, a1, a2, a3
print('ancillas measurement =', q.bits()[3:])
# ancillas measurement = [0, 1, 0, 0]
q.rm_ancillas() # rm a0, a1, a2, a3
q.evol('H', 0) # H q0 ┐
q.cphase(phase=1j, target=1, control=[0]) # Controlled S q1, q0 │
q.evol('H', 1) # H q1 │
q.cphase(exp(pi*1j/4), 2, [0]) # Controlled T q2, q0 │ = q.qft(0, 3)
q.cphase(1j, 2, [1]) # Controlled S q2, q1 │
q.evol('H', 2) # H q1 │
q.swap(0, 2) # SWAP q0, q2 ┘
q.measure(0, 3) # measure q0, q1, q2
print('final measurement =', q.bits())
# final measurement = [1, 0, 0]
Seed the wiki for documentation.
This software is suported by
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
QSystem-1.0.0.tar.gz
(596.0 kB
view details)
File details
Details for the file QSystem-1.0.0.tar.gz
.
File metadata
- Download URL: QSystem-1.0.0.tar.gz
- Upload date:
- Size: 596.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b43c9f9033461b999d5f37240bbee196e7f122a48f752d49a2e6a8fe6a1f2cf7 |
|
MD5 | 328b250d27a6ee0a78096b9085d1ffa5 |
|
BLAKE2b-256 | de8ae0188aa06051ef26be098d1e9f1b5c5903cba7c34f702d792ba6245f4791 |