Skip to main content

Module algebra

Module algebra 

Source
Expand description

Core blade algebra computations.

This module provides the mathematical foundation for code generation:

  • Blade: Represents a basis blade with canonical ordering
  • Algebra: Encapsulates a geometric algebra with its metric signature
  • ProductTable: 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:

BladeBinaryIndex
100000
e₁00011
e₂00102
e₁₂00113
e₃01004

§Sign Computation

When computing eₐ * eᵦ, the sign comes from:

  1. Swaps needed to reorder into canonical form
  2. 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.
ProductTable
Precomputed product table for a geometric algebra.
VersorInfo
Information about a verified versor type.

Enums§

VersorParity
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§

ProductContribution
A single product contribution: (sign, left_blade_index, right_blade_index).
ProductContributions
Result of collecting all product contributions grouped by output blade. Each entry is (output_blade_index, contributions_to_that_blade).