- Python 100%
| .github/workflows | ||
| .vscode | ||
| docs | ||
| examples | ||
| src/qtensor | ||
| tests | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .python-version | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| CITATION.cff | ||
| LICENSE | ||
| mkdocs.yml | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
qtensor
qtensor is a modern NumPy-based reconstruction of QTENSORSPACE, a named-party tensor library the author originally wrote in Cython/Numeric around 2002 for the quantum-communication protocols in Aschauer, Quantum communication in noisy environments, PhD thesis, LMU Munich, 2005. See CITATION.cff for how to cite this package and its predecessor.
The package implements named-party tensor algebra for small quantum-information experiments, including:
PartyandQubitQtensor, includingdagger(),normalize(),trace_value(),eigenvectors(), andis_eigenvector()Ket,Bra,P,density_operator,operator, anddiagonal_vector- convenience constructors such as
ghz_state,w_state,smolin_state,duer_state, andgraph_state - correlation-analysis helpers such as
sigma_y,pauli,expectation,correlation_tensor,flatten_correlation_tensor, andcombined_shadow_map - Named-party tensor multiplication without manually inserting identity operators
- Built-in gates such as
H,CNOT,sigma_x,sigma_z, andsigma_0 - Partial trace, basis formatting, diagonal-density evolution, and spectral helpers such as
singular_values,nuclear_norm, andfrobenius_norm
The installed console entry point is qtensor, which currently prints the package name.
Running examples
From the repository root:
uv run python examples/bell_state.py
uv run python examples/teleportation.py
uv run python examples/diagonal_density.py
uv run python examples/cluster_state.py
uv run python examples/structured_states.py
uv run python examples/correlation_analysis.py
The example coverage is:
bell_state.py: Bell-state generation from|1,0>withHandCNOTteleportation.py: pure-state teleportation and success probabilitydiagonal_density.py: diagonal-density evolution viaabs_squared(CNOT(...))cluster_state.py: cluster-state correlation signatures and reduced-state eigenvectorsstructured_states.py: GHZ, W, Smolin, Duer, and graph-state constructorscorrelation_analysis.py: Pauli expectations, correlation tensors, flattening, and combined shadow maps
Building documentation
MkDocs is configured as a docs dependency group, not as a build-system dependency. Build dependencies belong under [build-system] and are only for packaging the Python distribution itself.
Use:
uv run --group docs mkdocs serve
uv run --group docs mkdocs build --strict
The site configuration lives in mkdocs.yml and the documentation pages live in docs/.
Development notes
This codebase was written almost entirely by an AI coding agent (Claude Code, Anthropic), directed and reviewed by the author: design decisions, physics/API correctness, and acceptance testing (lint, type checks, unit tests) were the author's responsibility throughout. Commits with agent contributions carry a Co-Authored-By trailer identifying the model. See AGENTS.md for the working conventions the agent followed.
Because a work with little or no human authorship has uncertain copyright status, the package is released under CC0 rather than a traditional copyright license — see LICENSE.