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.
The generated function returns the sign of the first non-zero coefficient in storage order.
It returns:
1if the first non-zero coefficient is positive-1if the first non-zero coefficient is negative1for 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
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 + 2e1 - 5e12the maximum absolute component is:
5