Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grey-area/qcircuits
A Python package for simulating small-scale quantum computers.
https://github.com/grey-area/qcircuits
Last synced: about 2 months ago
JSON representation
A Python package for simulating small-scale quantum computers.
- Host: GitHub
- URL: https://github.com/grey-area/qcircuits
- Owner: grey-area
- License: mit
- Created: 2019-03-08T09:58:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-08T02:24:26.000Z (over 2 years ago)
- Last Synced: 2024-04-21T11:16:54.594Z (9 months ago)
- Language: Python
- Homepage: http://www.awebb.info/qcircuits/index.html
- Size: 503 KB
- Stars: 57
- Watchers: 2
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-quantum-software - QCircuits - User-friendly quantum circuit simulator designed for students and newcomers to quantum computing. (Quantum simulators)
README
=========
QCircuits
=========Full documentation at `www.awebb.info/qcircuits/index.html `_.
.. inclusion-marker0-do-not-remove
QCircuits is a Python package for the simulation and study of quantum computers based on the
`quantum circuit model `_.
It has been designed to have a simple, lightweight interface and to be
easy to use, particularly for those new to quantum computing... inclusion-marker1-do-not-remove
Installation
============Install with pip:
``pip install qcircuits``
.. inclusion-marker15-do-not-remove
or from the source available here.
.. inclusion-marker16-do-not-remove
Example usage: quantum teleportation
====================================.. inclusion-marker2-do-not-remove
Quantum circuit:
.. image:: http://www.awebb.info/qcircuits/_images/teleport.png
:scale: 40%Code::
import qcircuits as qc
# Instantiating the operators we will need
CNOT = qc.CNOT()
H = qc.Hadamard()
X = qc.PauliX()
Z = qc.PauliZ()# Alice's hidden state, that she wishes to transport to Bob.
alice = qc.qubit(theta=1, phi=1, global_phase=0.2)# A previously prepared Bell state, with one qubit owned by
# alice, and another by Bob, now physically separated.
bell_state = qc.bell_state(0, 0)# The state vector for the whole system.
phi = alice * bell_state# Alice applies a CNOT gate to her two qubit, and then
# a Hadamard gate to her private qubit.
phi = CNOT(phi, qubit_indices=[0, 1])
phi = H(phi, qubit_indices=[0])# Alice measures the first two bits, and transmits the classical
# bits to Bob.
# The only uncollapsed part of the state vector is Bob's.
M1, M2 = phi.measure(qubit_indices=[0, 1], remove=True)# Apply X and/or Z gates to third qubit depending on measurements
if M2:
print('First bit 1, applying X\n')
phi = X(phi)
if M1:
print('Second bit 1, applying Z\n')
phi = Z(phi)print('Original state:', alice)
print('\nTeleported state:', phi).. inclusion-marker3-do-not-remove