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.
Table of Contents
Installation
CPU-only install:
pip install logicqubit
GPU (PyTorch/CUDA) extras:
pip install "logicqubit[cuda]"
Startup
logicQuBit = LogicQuBit(n_qubits, symbolic = True)
Additional optional keyword arguments let you choose the TensorNetwork backend and toggle CUDA acceleration:
logicQuBit = LogicQuBit(
n_qubits,
tn_backend="numpy", # or "jax", "pytorch", "tensorflow"
enable_cuda=False # set to True to try a GPU-capable backend
)
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
Metadata
Release files for logicqubit 1.7.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logicqubit-1.7.9-py3-none-any.whl | Python 3 | none | any | Details for logicqubit-1.7.9-py3-none-any.whl |
Release files / logicqubit-1.7.9-py3-none-any.whl
| Download URL | logicqubit-1.7.9-py3-none-any.whl |
|---|---|
| Size | 23.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ce62d93c1e75b2ca570c47a4c108a067fb58e9a3029113e84393f6d1330d7d5
|
|
BLAKE2b-256 checksum How to use checksums |
00f3a949fd51ae34d0a03410f1c7ae6d65e151f4433fb67b110ded01830823aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for logicqubit 1.7.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.