No description
Find a file
Hans Aschauer aa50032429
Some checks failed
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / docs (push) Has been cancelled
(chore) add VSCode settings for Python testing configuration
2026-09-17 06:42:22 +02:00
.github/workflows (ci) add GitLab CI and GitHub Actions pipelines 2026-09-17 00:05:15 +02:00
.vscode (chore) add VSCode settings for Python testing configuration 2026-09-17 06:42:22 +02:00
docs Merge branch 'main' of ssh://code.hans-aschauer.de:222/hans/QTensor 2026-09-17 06:42:12 +02:00
examples (style) apply ruff format 2026-09-17 00:03:35 +02:00
src/qtensor Merge branch 'main' of ssh://code.hans-aschauer.de:222/hans/QTensor 2026-09-17 06:42:12 +02:00
tests Merge branch 'main' of ssh://code.hans-aschauer.de:222/hans/QTensor 2026-09-17 06:42:12 +02:00
.gitignore initial commit 2026-05-12 19:28:37 +02:00
.gitlab-ci.yml (ci) add GitLab CI and GitHub Actions pipelines 2026-09-17 00:05:15 +02:00
.python-version initial commit 2026-05-12 19:28:37 +02:00
AGENTS.md (doc) disclose AI-assisted development 2026-09-17 00:05:31 +02:00
CHANGELOG.md (chore) add LICENSE, CITATION.cff, and CHANGELOG.md 2026-09-17 00:04:50 +02:00
CITATION.cff (chore) add LICENSE, CITATION.cff, and CHANGELOG.md 2026-09-17 00:04:50 +02:00
LICENSE (chore) add LICENSE, CITATION.cff, and CHANGELOG.md 2026-09-17 00:04:50 +02:00
mkdocs.yml initial commit 2026-05-12 19:28:37 +02:00
pyproject.toml initial commit 2026-05-12 19:28:37 +02:00
README.md (doc) disclose AI-assisted development 2026-09-17 00:05:31 +02:00
uv.lock (chore) bump version to 0.2.0 in uv.lock 2026-05-12 19:34:04 +02:00

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:

  • Party and Qubit
  • Qtensor, including dagger(), normalize(), trace_value(), eigenvectors(), and is_eigenvector()
  • Ket, Bra, P, density_operator, operator, and diagonal_vector
  • convenience constructors such as ghz_state, w_state, smolin_state, duer_state, and graph_state
  • correlation-analysis helpers such as sigma_y, pauli, expectation, correlation_tensor, flatten_correlation_tensor, and combined_shadow_map
  • Named-party tensor multiplication without manually inserting identity operators
  • Built-in gates such as H, CNOT, sigma_x, sigma_z, and sigma_0
  • Partial trace, basis formatting, diagonal-density evolution, and spectral helpers such as singular_values, nuclear_norm, and frobenius_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> with H and CNOT
  • teleportation.py: pure-state teleportation and success probability
  • diagonal_density.py: diagonal-density evolution via abs_squared(CNOT(...))
  • cluster_state.py: cluster-state correlation signatures and reduced-state eigenvectors
  • structured_states.py: GHZ, W, Smolin, Duer, and graph-state constructors
  • correlation_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.