Skip to main content

No project description provided

Project description

pyqubits

A Python module for quantum computing simulations.

Setup

$ git clone https://github.com/tombch/pyqubits.git
$ cd pyqubits/
$ conda env create -f environment.yml
$ conda activate pyqubits
$ pip install .

Usage

Creating a QuantumState

>>> from pyqubits import QuantumState
>>> s = QuantumState(3)
>>> t = QuantumState.from_bits('00')

Viewing a QuantumState

>>> s
QuantumState([-0.29615118+0.50152956j,  0.37355584-0.06041027j,
               0.40094705-0.13785654j, -0.17540328-0.25628919j,
              -0.26399075+0.28541768j,  0.11632225-0.12028472j,
               0.08627474-0.14452522j,  0.04189382+0.17920989j])
>>> s.vector
array([-0.29615118+0.50152956j,  0.37355584-0.06041027j,
        0.40094705-0.13785654j, -0.17540328-0.25628919j,
       -0.26399075+0.28541768j,  0.11632225-0.12028472j,
        0.08627474-0.14452522j,  0.04189382+0.17920989j])
>>> print(s)
= (- 0.29615 + 0.50153j) |000> + (  0.37356 - 0.06041j) |001> 
+ (  0.40095 - 0.13786j) |010> + ( - 0.1754 - 0.25629j) |011> 
+ (- 0.26399 + 0.28542j) |100> + (  0.11632 - 0.12028j) |101> 
+ (  0.08627 - 0.14453j) |110> + (  0.04189 + 0.17921j) |111> 
>>> print(s.circuit)
1---
    
2---
    
3---
>>> print(s.dist)
000     0.34    |=================
001     0.14    |=======
010     0.18    |=========
011     0.1     |=====
100     0.15    |========
101     0.03    |=
110     0.03    |=
111     0.03    |==
>>> t
QuantumState([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> t.vector
array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> print(t)
= (1 + 0j) |00> 
>>> print(t.circuit)
1---
    
2---
>>> print(t.dist)
00      1.0     |==================================================
01      0.0     |
10      0.0     |
11      0.0     |

Manipulating a QuantumState

>>> t.H(1)
QuantumState([0.70710678+0.j, 0.        +0.j, 0.70710678+0.j, 0.        +0.j])
>>> t.CNOT(1, 2)
QuantumState([0.70710678+0.j, 0.        +0.j, 0.        +0.j, 0.70710678+0.j])
>>> print(t)
= (0.70711 + 0j) |00> + (0.70711 + 0j) |11> 
>>> print(t.circuit)
1---H---O---
        |   
2-------X---
>>> print(t.dist)
00      0.5     |=========================
01      0.0     |
10      0.0     |
11      0.5     |=========================
>>> t.measure(1)
QuantumState([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> result = t.bit
>>> result
0
>>> print(t)
= (1 + 0j) |00>

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

pyqubits-0.2.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

pyqubits-0.2.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file pyqubits-0.2.1.tar.gz.

File metadata

  • Download URL: pyqubits-0.2.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyqubits-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3750e238b79ba6a32e41517f027002681f4bacff45160decfbb0252895f6f28f
MD5 7325fc82c5b81aff647ca9f16c24c9ea
BLAKE2b-256 fe30b3075e01f2f5c69836311b72657e71a1a625eef152a65439f7c13463452f

See more details on using hashes here.

File details

Details for the file pyqubits-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyqubits-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyqubits-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc9813d0bd1e2818795a85a788fbae356281350cf3b42de4003938631f8ca6b
MD5 5b106f8e7879121282e5c27bdbd8c602
BLAKE2b-256 137810cdd20eeefbb4f5782915e777eee7087bec45e66df32e9a7c08c697dc33

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page