Galixir.GeometricAlgebra (galixir v0.21.0)

Copy Markdown View Source

Provides a macro for generating concrete geometric algebra modules.

A generated algebra module contains operations for creating and manipulating multivectors, including geometric products, outer products, inverses, duals, norms, grade extraction, and basis blade helpers.

The algebra is defined by a metric signature and a set of basis identifiers.

Usage

defmodule PGA3 do
  use Galixir.GeometricAlgebra,
    signature: {1, 1, 1, 0},
    bases: {1, 2, 3, 0}
end

Signature

The :signature option defines the metric of the algebra. Each element describes the square of the corresponding basis vector:

  • 1 - Euclidean basis vector (eᵢ² = 1)
  • -1 - anti-Euclidean basis vector (eᵢ² = -1)
  • 0 - null basis vector (eᵢ² = 0)

For example, {1, 1, 1, 0} defines a 3D projective geometric algebra (PGA) with three Euclidean basis vectors and one null basis vector.

Bases

The optional :bases option defines the identifiers used for basis vectors. The number of bases must match the dimension of the signature.

By default, basis identifiers are generated as consecutive integers starting from 1. For example, a four-dimensional algebra without an explicit :bases option uses:

bases: {1, 2, 3, 4}

For algebras with a special basis convention, such as projective geometric algebra (PGA), the identifiers can be customized:

bases: {1, 2, 3, 0}

This allows the null basis vector to be represented as e0, producing basis blades such as:

e1 e2 e3 e0 e123 e230

The identifiers are only used for naming basis blades; they do not affect the metric. The metric is defined exclusively by the :signature option.

Generated API

The generated module provides:

  • multivector construction with new/1
  • coefficient access
  • geometric product (gp/2)
  • outer product (wedge/2)
  • addition, subtraction, and scaling
  • reverse and dual operations
  • grade extraction
  • scalar and inner products
  • norms and normalization
  • inverses
  • blade and scalar predicates
  • basis blade constructors

It also provides higher-level helpers:

  • commutator/2 for the Lie algebra commutator
  • rotor_between_frames/2 for constructing rotors mapping one frame to another

Summary

Functions

Generates a geometric algebra implementation from a metric signature.

Functions

__using__(opts)

(macro)

Generates a geometric algebra implementation from a metric signature.

This macro is intended to be used inside a module definition.

Options

  • :signature - required tuple describing the metric signature. Each element corresponds to the square of one basis vector.

  • :bases - optional tuple containing names for the basis vectors. The number of bases must match the signature dimension.

Examples

defmodule GA3 do
  use Galixir.GeometricAlgebra,
    signature: {1, 1, 1}
end

defmodule PGA3 do
  use Galixir.GeometricAlgebra,
    signature: {1, 1, 1, 0},
    bases: {:1, :2, :3, :0}
end