QCircuits

一个用于模拟小型量子计算机的Python包。「A Python package for simulating small-scale quantum computers.」

  • Owner: grey-area/qcircuits
  • Platform: Linux, Mac, Windows
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

QCircuits

Full documentation at
www.awebb.info/qcircuits/index.html.

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.

Installation

Install with pip:

pip install qcircuits

or from the source available here.

Example usage: quantum teleportation

Quantum circuit:

image

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)

Main metrics

Overview
Name With Ownergrey-area/qcircuits
Primary LanguagePython
Program languagePython (Language Count: 1)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2019-03-08 09:58:07
Pushed At2022-07-08 02:24:26
Last Commit At2021-01-03 12:04:15
Release Count8
Last Release Name0.6.0 (Posted on 2021-01-03 12:04:45)
First Release Name0.1.0 (Posted on 2019-03-08 12:12:21)
用户参与
Stargazers Count56
Watchers Count3
Fork Count11
Commits Count93
Has Issues Enabled
Issues Count1
Issue Open Count1
Pull Requests Count0
Pull Requests Open Count2
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private