Galixir.Generator.Canonical (galixir v0.23.0)

Copy Markdown View Source

Generates helpers for determining canonical properties of multivectors.

The generated functions operate on the internal coefficient storage representation of a multivector.

These helpers are used by higher-level operations that need to determine properties such as the dominant coefficient or the overall sign of a multivector.

Since multivectors may contain multiple grades and components, these functions avoid making assumptions about the geometric meaning of a multivector and operate purely on its coefficients.

Summary

Functions

Generates a canonical_sign/1 function.

Generates a max_abs_component/1 function.

Functions

canonical_sign_impl(dimension, bases)

Generates a canonical_sign/1 function.

The generated function returns the sign of the first non-zero coefficient in storage order.

It returns:

  • 1 if the first non-zero coefficient is positive
  • -1 if the first non-zero coefficient is negative
  • 1 for a completely zero multivector

The function is used to choose a deterministic sign representation for objects that are equivalent up to a scalar sign.

Examples

canonical_sign(3e1 + 2e2)
# => 1

canonical_sign(-3e1 + 2e2)
# => -1

max_abs_component_impl(dimension, bases)

Generates a max_abs_component/1 function.

The generated function returns the largest absolute coefficient contained in a multivector.

This is commonly used when selecting a numerically stable scale factor or determining whether a multivector has a significant component.

Examples

For a multivector:

3.0 + 2.0e1 - 5.0e12

the maximum absolute component is:

5.0