Skip to content

Support Lorentz spinors as complex quaternions#91

Open
moble wants to merge 20 commits intomainfrom
lorentz
Open

Support Lorentz spinors as complex quaternions#91
moble wants to merge 20 commits intomainfrom
lorentz

Conversation

@moble
Copy link
Copy Markdown
Owner

@moble moble commented Mar 31, 2026

Preview docs here

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for treating complexified quaternions as Lorentz-group spinors (STA rotors) by switching complex-quaternion normalization/“norm” behavior to the spinor norm, and documents the geometric-algebra foundations. Also restructures test/docs environments and extends test coverage for the new Lorentz behavior.

Changes:

  • Implement spinor-norm behavior for abs, abs2, absvec, abs2vec on Complex-component quaternions (and add _hypot support).
  • Add a dedicated Lorentz/STA normalization test suite and update existing math tests accordingly.
  • Expand documentation with new Geometric Algebra and Spacetime Algebra pages; introduce workspace-style test/docs projects and a more capable test runner CLI.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/quaternion.jl Adds _hypot and new vector normalize methods used by rotor normalization.
src/math.jl Changes abs/abs2/absvec/abs2vec semantics for Complex components to use spinor norm.
test/runtests.jl Reworks test runner with CLI filtering (--file, --tags, etc.) and adds lorentz.jl to the suite.
test/math.jl Updates expected values for complex norms to match the new spinor-norm definitions.
test/lorentz.jl New tests validating STA/Lorentz normalization and _hypot behavior for boosts/rotations/phases.
test/basis.jl Skips selected basis/normalization tests for Symbolics.Num due to simplification limitations.
test/base.jl Adjusts Symbolics rotor test and LaTeX rendering expectations.
test/Project.toml Introduces a dedicated test environment with explicit deps/compat.
test.jl Removes the old top-level test/coverage runner script.
docs/src/geometric_algebra.md New documentation page deriving quaternion conventions from GA.
docs/src/spacetime_algebra.md New documentation page explaining complexified quaternions and the spinor norm in STA.
docs/src/references.bib Adds citations used by the new GA/STA docs.
docs/make.jl Adds the new docs pages and conditional inclusion of local notes/remotes.
docs/local_notes.jl Optional “local notes” integration for docs builds (detects and wires extra pages/remotes).
docs/serve.jl Adds a simple LiveServer-based doc serving script.
docs/Project.toml Adds workspace-style sources entry for local package development.
Project.toml Adds [workspace] and removes test-only extras/targets in favor of test/Project.toml.
.gitignore Ignores optional local docs notes and some tool configuration files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/quaternion.jl
Comment on lines +19 to 23
# We need that helper to normalize complex quaternions
normalize(v::AbstractVector{Complex{T}}) where T = v ./ _hypot(v)

# We simplify for real-valued quaternions, falling back on the default `hypot`
normalize(v::AbstractVector) = v ./ hypot(v...)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining normalize(v::AbstractVector{Complex{T}}) and especially normalize(v::AbstractVector) here adds/overrides methods for LinearAlgebra.normalize globally (since using LinearAlgebra is in scope). This changes normalization semantics for all vectors in user code once Quaternionic is loaded (e.g. normalize([1,2,3]) will now call hypot(v...), and Complex vectors will use the spinor norm), which is a breaking/unsafe side effect unrelated to quaternions.

Consider restricting these methods to quaternion-component types only (e.g. SVector{4,...}), or using an internal helper (e.g. _normalize_components) that rotor calls, while leaving LinearAlgebra.normalize behavior unchanged for general vectors.

Suggested change
# We need that helper to normalize complex quaternions
normalize(v::AbstractVector{Complex{T}}) where T = v ./ _hypot(v)
# We simplify for real-valued quaternions, falling back on the default `hypot`
normalize(v::AbstractVector) = v ./ hypot(v...)
# Internal helper to normalize quaternion component vectors without extending
# LinearAlgebra.normalize for all AbstractVector values.
_normalize_components(v::AbstractVector{Complex{T}}) where T = v ./ _hypot(v)
# Real-valued quaternion components can use the default hypot-based magnitude.
_normalize_components(v::AbstractVector) = v ./ hypot(v...)

Copilot uses AI. Check for mistakes.
Comment thread src/quaternion.jl Outdated
Comment thread docs/local_notes.jl Outdated
Comment thread test/Project.toml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

2 participants