Skip to main content

Algebraic toolkit for 2x2 doubly stochastic matrices: cascade, entropy, correction, phase recovery, and compilation

Project description

DS2 — Algebraic Toolkit for 2x2 Doubly Stochastic Matrices

PyPI version Python License Tests

One scalar replaces four complex scattering parameters.

Every 2x2 doubly stochastic matrix is uniquely determined by a single eigenvalue lambda in [-1, 1], and P(a) * P(b) = P(a*b). This monoid structure reduces cascade analysis to scalar multiplication — no matrix algebra needed.

Installation

pip install ds2

Quick Start

import ds2

# Build a P(lambda) matrix
P = ds2.matrix(0.7)
# array([[0.85, 0.15],
#        [0.15, 0.85]])

# Cascade 4 devices: just multiply eigenvalues
result = ds2.cascade([0.9, 0.8, -0.5, 0.95])
print(result.eigenvalue)          # -0.342
print(result.insertion_loss_db)   # 3.33 dB

# Analog error correction (k=3 repetition code)
ds2.correct(0.3, k=3)  # 0.4365 — repels from 0

# Compile a target IL from standard components
r = ds2.compile(target_il=7.0)
print(r.chain)   # ('6dB', '1dB')
print(r.error_db) # 0.0

# Landauer efficiency (quasistatic erasure)
ds2.landauer_efficiency(delta_0=0.9, delta_f=0.1, k=100)
# {'eta': 0.982, 'delta_h': 0.469, 'dissipation': 0.009, ...}

# 13-domain universality
ds2.domains.bsc(epsilon=0.1)          # 0.8
ds2.domains.beam_splitter(reflectance=0.3)  # -0.4
ds2.domains.scattering(s11_sq=0.3)    # -0.4

Five Tools

Tool What it does Key result
Cascade lambda_total = prod(lambda_i) Error < 10^-16
Thermodynamics Entropy budget + Landauer cost eta -> 1 as k -> inf
Correction f_3(lambda) = (3*lambda - lambda^3)/2 26.5x capacity gain
Phase recovery Interferometric S-matrix reconstruction 100% on 1000 unitaries
Compiler Target IL -> device chain 0.00 dB error

Thirteen Domains

The DS2 monoid appears in: microwave scattering, quantum gates, Markov chains, softmax/neural networks, optical beam splitters, population genetics, resistor dividers, polarization (Malus's law), IIR filters, binary symmetric channels, synaptic transmission, gene regulation, and epidemic transmission.

from ds2.domains import DOMAIN_TABLE
for d in DOMAIN_TABLE:
    print(f"{d['domain']:30s} lambda = {d['lambda']}")

References

  • D. T. Foss, "Algebraic Structure of Doubly Stochastic Power Matrices in Electromagnetic Scattering," Proc. ICEAA/APWC, Toyama, Japan, Sep. 2026.
  • D. T. Foss, "The DS2 Toolkit: Algebraic Methods for Two-Port Network Analysis Across Thirteen Domains," Proc. ICEAA/APWC, Toyama, Japan, Sep. 2026.

License

BSD 3-Clause. 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

ds2_toolkit-0.1.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

ds2_toolkit-0.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ds2_toolkit-0.1.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for ds2_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48e06038853bd422bdbba602950b34d1d7f27654b1544d71603aa50d3f42f0a8
MD5 8bf48b0a0efb31c11fcb9de67d9145d9
BLAKE2b-256 848b55d990569e144f6e4b3b35c31574b0a5af7a903ea84d4c7cc8c3c08ee58c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ds2_toolkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for ds2_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 477f3b0b5ccd4cc5be938aeda4bc063730c16b109c15892129cfbc4942c76ee5
MD5 b217ef711fd549226f5cc935f8eea875
BLAKE2b-256 9d526c96ea18df235822c4f9db8884713ceb02fa0b4b4250db335da4086075a9

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