A lightweight quantum computing library for foundational tools and mathematical operations.
Project description
Qlibx: A Quantum Computing Library
Qlibx is a Python library designed to provide foundational tools for quantum computing. It offers classes and methods to represent and manipulate quantum states, operators, and their interactions. The library is lightweight and focuses on the mathematical foundations of quantum mechanics, making it an excellent choice for learning and experimentation.
Features
-
Quantum States:
KetandBraclasses to represent quantum states.- Support for operations like addition, subtraction, scalar multiplication, tensor products, and inner/outer products.
-
Quantum Operators:
Operatorclass to represent quantum operators.- Methods for Hermitian, unitary, and normality checks.
- Commutator and anti-commutator calculations.
- Spectral decomposition and partial trace.
- Von Neumann entropy calculation.
-
Predefined Operators:
- Pauli matrices (
pauli_x,pauli_y,pauli_z) and the identity matrix.
- Pauli matrices (
Installation
pip install qlibx
or
Clone the repository and include the library in your Python project:
git clone https://github.com/Suraj52721/qc_lib/tree/master
cd qlibx
Ensure the qlibx directory is in your Python path.
Usage
Importing the Library
from qlibx import Ket, Bra, Operator
Creating Quantum States
# Create a Ket vector
ket = Ket([1, 0])
# Create a Bra vector
bra = Bra([1, 0])
Quantum Operations
# Inner product
inner = ket.inner_product(bra)
# Outer product
outer = ket.outer_product(bra)
# Tensor product
tensor = ket.tensor(Ket([0, 1]))
Working with Operators
# Define an operator
op = Operator([[0, 1], [1, 0]])
# Apply operator to a Ket
result = op.op(ket)
# Check if the operator is unitary
is_unitary = op.unitary()
Example: Quantum Circuit Simulation
from qlibx import Ket, Operator
# Define a quantum state |ψ⟩
psi = Ket([1, 0])
# Define a Pauli-X gate
pauli_x = Operator(Operator.pauli_x)
# Apply the gate
new_state = pauli_x.op(psi)
print(new_state)
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Acknowledgments
Qlibx is inspired by the mathematical foundations of quantum mechanics and aims to provide an intuitive interface for quantum computing enthusiasts.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qlibx-1.0.1.tar.gz.
File metadata
- Download URL: qlibx-1.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
721ca0ad9ff02ecba724d601cc670b08eb2d3354ae8e05184a814425ca544021
|
|
| MD5 |
0158acb8e36761514cf896d0c4ae5da4
|
|
| BLAKE2b-256 |
f43a6227b867071be8577db710c489dace20b5f356c4f60de79078f1019ba4cf
|
File details
Details for the file qlibx-1.0.1-py3-none-any.whl.
File metadata
- Download URL: qlibx-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4299fbb4d594d54b0930a579ebec1df4bb84dcedbff8d369b1d0bdf81c7ea747
|
|
| MD5 |
37f0cf6eb943cd498bf2825833284984
|
|
| BLAKE2b-256 |
da3211564c30221ed467d0a224efc85bca525b75cf46901b4a87f8b42a677c9a
|