Skip to content

space: Jordan spectral primitives (trace / determinant / unit)#56

Merged
Pavlo3P merged 1 commit into
0.4.2from
jordan-spectral-primitives
Jul 1, 2026
Merged

space: Jordan spectral primitives (trace / determinant / unit)#56
Pavlo3P merged 1 commit into
0.4.2from
jordan-spectral-primitives

Conversation

@Pavlo3P

@Pavlo3P Pavlo3P commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the Jordan spectral primitives (0.4.2 W2) to every Jordan-algebra space, derived from each space's spectrum:

  • trace(x) = Σ λᵢ, determinant(x) = Π λᵢ, unit() = the algebra identity e.

All three preserve leading batch axes, and the tree/stacked composites get them for free through the leafwise mixins (no per-class edits).

Changes

  • Base JordanAlgebraSpace: derived trace/determinant; unit as @abstractmethod.
  • HermitianSpace: trace via the diagonal (real(einsum "...ii->..."), no eigendecomposition); unit = eye(n); inherits the base determinant.
  • ElementwiseJordanSpace: trace/determinant reduce the element's own axes; unit = ones(shape).
  • Tree / stacked mixins (direct sums): trace additive, determinant multiplicative, unit assembled from the leaf/copy units.
  • Test-double Jordan stubs in test_stacked_space.py updated for the new abstract unit.

Testing

  • New tests/spaces/test_jordan_invariants.py: parametrized over all five families (elementwise, Hermitian, Euclidean-elementwise, stacked, tree; real+complex) — trace == Σspectrum, determinant == Πspectrum, unit is the Jordan identity (e∘x==x), and the oracle trace(x) == ⟨unit(), x⟩ on every EJA — plus direct batch-axis, multi-dim-elementwise, and stacked direct-sum tests.
  • Full suite: 3383 passed, 170 skipped; ruff / ruff-D / jit_audit / docstring_audit all clean.

Notes

An adversarial review pass caught two real bugs pre-merge: the stacked trace/determinant used ops.sum/ops.prod without an axis, collapsing leading batch axes (unlike every other family). Fixed to axis=-1 and covered by a regression test.

🤖 Generated with Claude Code

Add trace/determinant/unit to the Jordan-algebra hierarchy (0.4.2 W2), derived
from each space's spectrum:

- Base JordanAlgebraSpace: trace = sum(spectrum), determinant = prod(spectrum),
  unit as @AbstractMethod.
- HermitianSpace: trace via the diagonal (real(einsum '...ii->...'), no eigh),
  unit = eye(n); inherits the base determinant.
- ElementwiseJordanSpace: trace/determinant reduce the element's own axes,
  unit = ones(shape).
- Tree and stacked mixins (direct sums): trace additive, determinant
  multiplicative, unit assembled from the leaf/copy units -- inherited by every
  Jordan composite with no per-class edits.

All primitives preserve leading batch axes. The oracle trace(x) == inner(unit(), x)
holds on every Euclidean Jordan algebra across all five space families.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Pavlo3P Pavlo3P merged commit 7d3582f into 0.4.2 Jul 1, 2026
5 checks passed
@Pavlo3P Pavlo3P deleted the jordan-spectral-primitives branch July 1, 2026 17:01
@Pavlo3P Pavlo3P mentioned this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant