Skip to main content

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-toolkit

Quick Start

import ds2_toolkit

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

# Cascade 4 devices: just multiply eigenvalues
result = ds2_toolkit.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_toolkit.correct(0.3, k=3)  # 0.4365 — repels from 0

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

# Landauer efficiency (quasistatic erasure)
ds2_toolkit.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_toolkit.domains.bsc(epsilon=0.1)          # 0.8
ds2_toolkit.domains.beam_splitter(reflectance=0.3)  # -0.4
ds2_toolkit.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_toolkit.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.

Metadata

Release files for ds2-toolkit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ds2-toolkit 0.1.1
File Size Uploaded Provenance
ds2_toolkit-0.1.1.tar.gz 19.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ds2-toolkit 0.1.1
File Interpreter ABI Platform
ds2_toolkit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / ds2_toolkit-0.1.1.tar.gz

Download URL ds2_toolkit-0.1.1.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1f71e60a08059e9ad999a9482c1ab965d2e1ae9d8aff3c7f44929ad95a589366
BLAKE2b-256 checksum
How to use checksums
069e447e72f9d80aeba42a3fd87a95643f92eb2a031ac1348bfbdbff64f69028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / ds2_toolkit-0.1.1-py3-none-any.whl

Download URL ds2_toolkit-0.1.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70909ba3c4abc377d18cd09591a5e4109d68bed1b224d4bec38731b0c7c9eae2
BLAKE2b-256 checksum
How to use checksums
7f74c9bd2a8c6499668919a3d63782721145c7fc641d0c19465261079f2f508b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for ds2-toolkit 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page