Galixir.Algebras.CGA2 (galixir v0.13.0)

Copy Markdown View Source

Summary

Functions

Returns the mapping between blade names and storage indices.

Returns the canonical sign of a multivector.

Returns the coefficient of a basis blade.

Returns the dimension of the algebra.

Computes the dual of a multivector.

Computes the geometric product of two multivectors.

Returns the maximum absolute coefficient of a multivector.

Returns the scalar coefficient of a multivector.

Returns the metric signature of the algebra.

Returns the number of coefficients stored by the algebra.

Returns the multiplication table for the algebra.

Computes the inverse dual operation.

Functions

add(arg1, arg2)

basis_name(int)

blade?(a)

blade_indices()

Returns the mapping between blade names and storage indices.

Blade coefficients are stored in a fixed-size tuple. This map translates canonical blade names into their corresponding tuple index.

Example

iex> Galixir.Algebras.CGA2.blade_indices()[:e1]
1

blade_inverse(b)

canonical_sign(arg1)

Returns the canonical sign of a multivector.

The canonical sign is determined by the first non-zero coefficient in storage order.

Returns:

  • 1 if the first non-zero coefficient is positive
  • -1 if the first non-zero coefficient is negative
  • 0 if all coefficients are zero

Examples

iex> Elixir.Galixir.Algebras.CGA2.canonical_sign(Elixir.Galixir.Algebras.CGA2.new(e1: 2))
1

iex> Elixir.Galixir.Algebras.CGA2.canonical_sign(Elixir.Galixir.Algebras.CGA2.new(e1: -2))
-1

iex> Elixir.Galixir.Algebras.CGA2.canonical_sign(Elixir.Galixir.Algebras.CGA2.new())
0

canonicalize(a)

coefficient(cga2, blade)

Returns the coefficient of a basis blade.

The requested blade can be given in canonical form or as any registered blade alias. Aliases are automatically converted to the canonical blade and the appropriate sign is applied.

## Examples

iex> Elixir.Galixir.Algebras.CGA2.coefficient( ...> Elixir.Galixir.Algebras.CGA2.new(e1: 3), ...> :e1 ...> ) 3

commutator(a, b)

dimension()

Returns the dimension of the algebra.

This is the number of basis vectors defined by the signature.

dual(arg1)

Computes the dual of a multivector.

The dual maps each basis blade to its complementary blade with the appropriate orientation sign. The complement is determined by the full pseudoscalar of the algebra.

The operation is linear and applies independently to every coefficient.

Examples

iex> Galixir.Algebras.CGA2.dual(Galixir.Algebras.CGA2.new(e1: 1)) Galixir.Algebras.CGA2.new(e2pm: 1)

gp(lhs, rhs)

Computes the geometric product of two multivectors.

The geometric product is the fundamental multiplication operation of geometric algebra. It combines the outer product and metric-dependent inner product into a single associative operation.

The result depends on the algebra's metric signature.

Examples

iex> Galixir.Algebras.CGA2.gp(
...>   Galixir.Algebras.CGA2.new(e1: 1),
...>   Galixir.Algebras.CGA2.new(e1: 1)
...> )
Galixir.Algebras.CGA2.new(scalar: 1)

grade(t, g)

grades(arg1)

inner(arg1, arg2)

inverse(a)

max_abs_component(arg1)

Returns the maximum absolute coefficient of a multivector.

Accepts either a multivector struct or the internal coefficient tuple.

Example

iex> Elixir.Galixir.Algebras.CGA2.max_abs_component(Elixir.Galixir.Algebras.CGA2.new(e1: 2, scalar: 5))
5

iex> Elixir.Galixir.Algebras.CGA2.max_abs_component(Elixir.Galixir.Algebras.CGA2.new(e1: 5, scalar: 2))
5

new(basis \\ [])

norm(a)

normalize(a)

reverse(arg1)

rotor_between_frames(source, target)

scalar?(cga2)

scalar?(arg, eps \\ 1.0e-12)

scalar_part(cga2)

Returns the scalar coefficient of a multivector.

This is equivalent to retrieving the coefficient of the scalar blade.

Examples

iex> Elixir.Galixir.Algebras.CGA2.scalar_part(Elixir.Galixir.Algebras.CGA2.new(scalar: 5, e1: 2))
5

scalar_product(arg1, arg2)

scale(s, s)

signature()

Returns the metric signature of the algebra.

Example:

{1, 1, 1, 0}

represents a projective geometric algebra with three Euclidean basis vectors and one null basis vector.

size()

Returns the number of coefficients stored by the algebra.

A dimension n algebra contains 2^n basis blades.

squared_norm(a)

sub(arg1, arg2)

table()

Returns the multiplication table for the algebra.

The table contains precomputed geometric products between basis blades. Each entry maps {left_blade, right_blade} to {coefficient, result_blade}.

The blades are represented internally as bitmasks.

Example

iex> Galixir.Algebras.CGA2.table() |> Map.has_key?({1, 1})
true

undual(arg1)

Computes the inverse dual operation.

undual/1 reverses the blade complement operation performed by dual/1.

For non-degenerate Euclidean algebras this corresponds to applying the dual operation twice with the appropriate pseudoscalar factor. In degenerate algebras the result depends on the implemented dual convention.

Examples

iex> Galixir.Algebras.CGA2.undual(Galixir.Algebras.CGA2.dual(Galixir.Algebras.CGA2.new(e1: 2)))
Galixir.Algebras.CGA2.new(e1: 2)

wedge(arg1, arg2)

wedge_all(vectors)

zero?(arg1)