Skip to main content

Norms and block decompositions for 2x2 and 3x3 tensor powers.

Project description

tensorpow

tensorpow is a small Python library for working with norms and representations of tensor powers. Base matrices can be either 2×2 (using SL(2) representation data) or 3×3 (using SU(3) representation data). The tensor power itself may be any positive integer – the library uses precomputed representation data indexed by that power. A class-based interface computes block decompositions via precomputed SL(2)/SU(3) data and evaluates quantities such as Schatten‑p norms without building the full Kronecker power.

Installation

Requires Python 3.11–3.13.

pip install tensorpow

For development:

pip install -e ".[test]"

Dependencies (numpy, pulp, scipy, sympy) are installed automatically.

Data limits

Precomputed SU(3) symmetric representation data is bundled for degrees 1 through 26. Some large 3×3 tensor powers may require higher degrees; those cases raise a clear error.

Precomputed SL(2) data (sl2reps.txt) supports 2×2 tensor powers n ≤ 79.

Quick start

from tensorpow import TensorPowerCalculator
import numpy as np

# Example 1: 3×3 matrices (SU(3) case)
A = np.eye(3)
B = 2 * np.eye(3)
calc = TensorPowerCalculator()           # no args
# compute Schatten‑2 norm of A⊗A - 1/2 * B⊗B (tensorpower=2) 
norm_3x3 = calc.schatten_p_norm_weighted([A, B], n=2, p=2, coeffs=[1.0, -0.5])
print(f"3×3 result: {norm_3x3}")

# Example 2: 2×2 matrices (SL(2) case)
C = np.eye(2)
D = 2 * np.eye(2)
# compute Schatten‑2 norm of C⊗C - 1/2 * D⊗D (tensorpower=2)
norm_2x2 = calc.schatten_p_norm_weighted([C, D], n=2, p=2, coeffs=[1.0, -0.5])
print(f"2×2 result: {norm_2x2}")

Only the schatten_p_norm_weighted method is currently implemented. Both 2×2 and 3×3 matrices are fully supported; the library automatically dispatches to the appropriate representation system (SL(2) or SU(3)) based on matrix dimension.

Precomputed data

  • 2×2 (SL(2)): requires data/sl2reps.txt (bundled in the public tensorpow package). Supports tensor power n ≤ 79 (representations Sym^k for k = 0..79). Regenerate with:

    python -m tensorprod.sl2_sym_runner --max-k 79
    
  • 3×3 (SU(3)): requires data/piM_sym_<deg>_*.npz files for the degrees used by the Pieri decomposition at your chosen n. Additional routines (e.g. other norms or eigenvalue statistics) can be added to TensorPowerCalculator and will automatically reuse the underlying block decomposition.

Package structure

  • tensorpow/core.py – main implementation and TensorPowerCalculator, includes both SL(2) (2×2) and SU(3) (3×3) block decomposition logic
  • tensorpow/file_handler.py – loaders for bundled _data/ NPZ tensors compressed SU(3) representation data data (not part of the runtime API)
  • tensorpow/sl2_loader.py – loads data/sl2reps.txt at runtime
  • tensorpow/sl2_sym_runner.py – generator for data/sl2reps.txt (dev only)

Testing

Run pytest tests to exercise the small test suite.

License

GNU GPLv3 or later (see LICENSE).

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

tensorpow-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensorpow-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file tensorpow-0.1.0.tar.gz.

File metadata

  • Download URL: tensorpow-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tensorpow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 978e23ffd76ad7d3e512a990ada9b79c24b4ec24955003d16b4d00ae13da9b90
MD5 20b0a205414f885da81cf6a395dedc70
BLAKE2b-256 ea93838e1f90f997337a7541b149bf83e7d3a8da3023532e48dc378d6673e2d3

See more details on using hashes here.

File details

Details for the file tensorpow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tensorpow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tensorpow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a5435529663ce45f7134ac46fbb7f1283a645b0d7b29beb0563c23b91dffc16
MD5 15567a5675611e8a1771e922180a8c2f
BLAKE2b-256 77bc3ddf4484a781ee4ff5aa9708e436c95f549bcf69b6884923e0e78fab0097

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page