Expand description
Core blade algebra computations.
This module provides the mathematical foundation for code generation:
Blade: Represents a basis blade with canonical orderingAlgebra: Encapsulates a geometric algebra with its metric signatureProductTable: Precomputed product lookup for efficient code generation
§Canonical Ordering
Blades are represented as bitmasks where bit i indicates the presence
of basis vector eᵢ. This representation is inherently canonical:
| Blade | Binary | Index |
|---|---|---|
| 1 | 0000 | 0 |
| e₁ | 0001 | 1 |
| e₂ | 0010 | 2 |
| e₁₂ | 0011 | 3 |
| e₃ | 0100 | 4 |
§Sign Computation
When computing eₐ * eᵦ, the sign comes from:
- Swaps needed to reorder into canonical form
- Metric contributions when basis vectors square
§Example
use clifford_codegen::algebra::{Algebra, Blade, ProductTable};
let algebra = Algebra::euclidean(3);
let table = ProductTable::new(&algebra);
// e1 * e2 = e12 with sign +1
let (sign, result) = table.geometric(1, 2);
assert_eq!(sign, 1);
assert_eq!(result, 3);
// e2 * e1 = -e12 (anticommutative)
let (sign, result) = table.geometric(2, 1);
assert_eq!(sign, -1);
assert_eq!(result, 3);Structs§
- Algebra
- A geometric algebra defined by its metric signature.
- Blade
- A basis blade in a geometric algebra.
- Product
Table - Precomputed product table for a geometric algebra.
- Versor
Info - Information about a verified versor type.
Enums§
- Versor
Parity - Versor classification by grade parity.
Functions§
- antireverse_
sign - Sign factor for the antireverse of a k-blade in an n-dimensional algebra.
- basis_
product - Computes the sign and result of multiplying basis blades.
- binomial
- Computes the binomial coefficient C(n, k) = n! / (k! * (n-k)!).
- blades_
of_ grade - Returns all blade indices of a given grade in an n-dimensional algebra.
- blades_
of_ grades - Returns all blade indices for the given grades in an n-dimensional algebra.
- clifford_
conjugate_ sign - Sign factor for the Clifford conjugate of a k-blade.
- geometric_
grades - Returns all grades present in the geometric product of two blades.
- grade
- Returns the grade (number of basis vectors) of a blade.
- grade_
involution_ sign - Sign factor for the grade involution of a k-blade.
- inner_
grade - Grade selection for inner product (symmetric).
- left_
contraction_ grade - Grade selection for left contraction.
- outer_
grade - Grade selection for outer product (wedge).
- reverse_
sign - Sign factor for the reverse of a k-blade.
- satisfies_
all_ constraints - Checks if a grade combination satisfies both geometric constraints.
- satisfies_
antiproduct_ constraint - Checks if a grade combination satisfies the antiproduct constraint.
- satisfies_
geometric_ constraint - Checks if a grade combination satisfies the geometric constraint.
- versor_
parity - Determines the versor parity of a type based on its grades.
Type Aliases§
- Product
Contribution - A single product contribution: (sign, left_blade_index, right_blade_index).
- Product
Contributions - Result of collecting all product contributions grouped by output blade. Each entry is (output_blade_index, contributions_to_that_blade).