Galixir.Generator (galixir v0.23.0)

Copy Markdown View Source

Provides compile-time helpers for generating geometric algebra modules.

The generator translates the internal bitmask representation of basis blades into Elixir functions and lookup tables.

Basis blades are represented internally as integers where each bit indicates the presence of a basis vector. This module generates the mapping between those masks and their human-readable representations.

For example, with:

bases: {1, 2, 3}

the generator creates mappings such as:

0      -> :scalar
1      -> :e1
2      -> :e2
3      -> :e12
7      -> :e123

The generated data is used by Galixir.GeometricAlgebra when building a concrete algebra implementation.

Summary

Functions

Generates aliases for all permutations of basis blade names.

Returns the canonical atom name for a blade mask.

Generates a lookup table from blade names to storage indices.

Functions

blade_aliases(bases)

Generates aliases for all permutations of basis blade names.

Basis blades have a canonical ordering, but the same blade can be written using different permutations. This function creates a lookup table that maps non-canonical forms to their canonical representation and the sign introduced by reordering.

For example:

e21 = -e12

produces an alias mapping equivalent to:

:e21 => {:e12, -1}

blade_atom(mask, bases)

Returns the canonical atom name for a blade mask.

The mask uses the internal bit representation where each bit corresponds to a basis vector. The returned atom follows the algebra naming convention:

0     -> :scalar
1     -> :e1
3     -> :e12

Examples

iex> Galixir.Generator.blade_atom(0, {1, 2, 3})
:scalar

iex> Galixir.Generator.blade_atom(3, {1, 2, 3})
:e12

blade_indices(bases)

Generates a lookup table from blade names to storage indices.

The generated index corresponds to the bitmask representation of the blade and is used as the position of the blade coefficient in the multivector storage.

For example, for a three-dimensional algebra:

:scalar -> 0
:e1     -> 1
:e2     -> 2
:e12    -> 3
:e3     -> 4
:e23    -> 6
:e123   -> 7

The index is a bitmask, where each bit represents the presence of a basis vector.