space: Jordan spectral primitives (trace / determinant / unit)#56
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 identitye.All three preserve leading batch axes, and the tree/stacked composites get them for free through the leafwise mixins (no per-class edits).
Changes
JordanAlgebraSpace: derivedtrace/determinant;unitas@abstractmethod.HermitianSpace:tracevia the diagonal (real(einsum "...ii->..."), no eigendecomposition);unit = eye(n); inherits the basedeterminant.ElementwiseJordanSpace:trace/determinantreduce the element's own axes;unit = ones(shape).traceadditive,determinantmultiplicative,unitassembled from the leaf/copy units.test_stacked_space.pyupdated for the new abstractunit.Testing
tests/spaces/test_jordan_invariants.py: parametrized over all five families (elementwise, Hermitian, Euclidean-elementwise, stacked, tree; real+complex) —trace == Σspectrum,determinant == Πspectrum,unitis the Jordan identity (e∘x==x), and the oracletrace(x) == ⟨unit(), x⟩on every EJA — plus direct batch-axis, multi-dim-elementwise, and stacked direct-sum tests.Notes
An adversarial review pass caught two real bugs pre-merge: the stacked
trace/determinantusedops.sum/ops.prodwithout an axis, collapsing leading batch axes (unlike every other family). Fixed toaxis=-1and covered by a regression test.🤖 Generated with Claude Code