Tool for decomposing unitary matrix into quantum gates
This is a Python tool which takes a unitary matrix and returns a quantum circuit implementing it as Q# code, Cirq circuit, or Qiskit circuit.
Installing
pip install quantum-decomp
Example
>>> import numpy, quantum_decomp
>>> SWAP = numpy.array([[1,0,0,0],[0,0,1,0],[0,1,0,0], [0,0,0,1]])
>>> print(quantum_decomp.matrix_to_qsharp(SWAP, op_name='Swap'))
operation Swap (qs : Qubit[]) : Unit {
CNOT(qs[1], qs[0]);
CNOT(qs[0], qs[1]);
CNOT(qs[1], qs[0]);
}
>>> print(quantum_decomp.matrix_to_cirq_circuit(SWAP))
0: ───@───X───@───
│ │ │
1: ───X───@───X───
>>> print(quantum_decomp.matrix_to_qiskit_circuit(SWAP))
┌───┐ ┌───┐
q_0: ┤ X ├──■──┤ X ├
└─┬─┘┌─┴─┐└─┬─┘
q_1: ──■──┤ X ├──■──
└───┘
See example.ipynb for more examples and instructions how to use this tool.
References
-
This tool was inspired by Microsoft Q# Coding Contest and was implemented as part of online course "Applications of Quantum Mechanics" at MIT.
-
See this paper for detailed description of the algorithm and further references to papers with algorithms.
-
Blog post about the tool.
Citation
If you use this tool in your research, please cite this paper on arXiv.
Metadata
Release files for quantum-decomp 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quantum_decomp-1.1.3.tar.gz | 17.3 kB | Without provenance | Details for quantum_decomp-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantum_decomp-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for quantum_decomp-1.1.3-py3-none-any.whl |
Total release size: 38.8 kB
Release files / quantum_decomp-1.1.3.tar.gz
| Download URL | quantum_decomp-1.1.3.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36c7c2b6490140e8b91906cd3c591f00ea00e3bee1bec5d39a35755412fa182b
|
|
BLAKE2b-256 checksum How to use checksums |
72545599995c8bde2c4efc6a156fba46439e500ce62229b2fb4045f7817a9171
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / quantum_decomp-1.1.3-py3-none-any.whl
| Download URL | quantum_decomp-1.1.3-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16f86580c455a0a26e2e7547b1ce13764236070aded5f6196f3d09fb47a4d086
|
|
BLAKE2b-256 checksum How to use checksums |
78f076c4a02cdb9d60debc684d1dad316bf0b381f10c289b0198116fc8690c7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for quantum-decomp 1.1.3
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.