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 and a set of basis identifiers.
Usage
defmodule PGA3 do
use Galixir.GeometricAlgebra,
metric: {1, 1, 1, 0},
bases: {?1, ?2, ?3, ?0}
endMetric
The :metric 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 metric.
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 :metric 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/2for the Lie algebra commutatorrotor_between_frames/2for constructing rotors mapping one frame to another
Summary
Functions
Generates a geometric algebra implementation from a metric.
Functions
Generates a geometric algebra implementation from a metric.
This macro is intended to be used inside a module definition.
Options
:metric- required tuple describing the metric. 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 metric dimension.:epsilon- optional epsilon value that is used for florating point comparisons
Examples
defmodule GA3 do
use Galixir.GeometricAlgebra,
metric: {1, 1, 1}
end
defmodule PGA3 do
use Galixir.GeometricAlgebra,
metric: {1, 1, 1, 0},
bases: {?:1, ?:2, ?:3, ?:0},
epsilon: 1.0e-8
end