Skip to main content

LogicQubit is a simple library for quantum computing simulation.

Project description

Features

  • Numerical and symbolic simulation of quantum algorithms
  • Plot state and current operation, density matrix and measurement graphs
  • The state values can be represented as angles, which helps in the analysis of the fourrier quantum transform.
  • Operations can be performed directly on the instantiated qubit object or using qubit indices.
  • Support GPU

Table of Contents

Installation

pip install logicqubit

Startup

logicQuBit = LogicQuBit(n_qubits, symbolic = True)

Where n_qubits is the number of qubits, and symbolic defines whether the values a and b of the qubits will be symbolic or not, if the symbolic input is omitted the calculation will be numeric.

To instantiate a qubit

q = Qubit()

To instantiate a qubit register

reg = QubitRegister(num_qubits)

Operations

Operations on one qubit

The operation can be performed as q.Gate(parameters) or logicQuBit.Gate(id_qubit, parameters).

Operations on two qubits

In this case, the operation can be performed as q.Gate(control_qubit, parameters) or logicQuBit.Gate(control_qubit, target_qubit, parameters).

*The need for parameters depends on the type of gate.

List of available gates

Single-qubit gates: X, Y, Z, V, S, T, H, RX, RY, RZ, U, U1, U2, U3.

Two-qubits gates: CX or CNOT, CY, CZ, CV, CS, CT, CRX, CRY, CRZ, CU, CU1, CU2, CU3, SWAP.

Three-qubits gates: CCX or Toffoli, Fredkin.

Measure

Measure the expected value of one or more qubits

result = logicQuBit.Measure([q1,q2,..,qn])

Measure one shot on a qubit

value = logicQuBit.Measure_One(qubit)

Plot graphs and print state

Plot expected values

logicQuBit.plot()

Generate a graph of the values obtained by the Measure([...]).

Plot the density matrix

logicQuBit.PlotDensityMatrix()

Print the current state

logicQuBit.PrintState()

Print the current state as angles

logicQuBit.getPsiAtAngles(degree=True)

The degree variable defines whether the result will be displayed in degrees or radians.

Code sample

from logicqubit.logic import *

logicQuBit  = LogicQuBit(3)

a = Qubit()
b = Qubit()
c = Qubit()

a.H()
b.H()

c.CCX(a,b) # and operation

logicQuBit.Measure([c])
logicQuBit.Plot()

Other code samples

https://github.com/clnrp/logicqubit-algorithms

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

logicqubit-1.5.9.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

logicqubit-1.5.9-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file logicqubit-1.5.9.tar.gz.

File metadata

  • Download URL: logicqubit-1.5.9.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for logicqubit-1.5.9.tar.gz
Algorithm Hash digest
SHA256 d976dad119d72eda200aa747d0412b253168bc34b74f3d33d835ef7b0d376f2e
MD5 b438606b65bceb336bb1cb0898c3047c
BLAKE2b-256 95aba02363da9464d7154aaf3f563545004aebb95689bfe963f993db41c3c993

See more details on using hashes here.

File details

Details for the file logicqubit-1.5.9-py3-none-any.whl.

File metadata

  • Download URL: logicqubit-1.5.9-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for logicqubit-1.5.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f250c5a5dd6aff4b8f592dd4b14ada287d19187dca1307ea8df8e7de86afbd35
MD5 66fe7263ce2e801d69fda8a6b6731643
BLAKE2b-256 c3cdfd3939f277439efe3e2f4dd85466a173811bcc42e09d84fa53a3adf956ce

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