Expand description
Entity discovery for geometric algebra code generation.
This module automatically discovers valid geometric entities from an algebra signature by analyzing geometric constraints.
§Overview
Given an algebra signature (p, q, r), entity discovery:
- Enumerates all possible grade combinations
- Analyzes which grade pairs conflict (create non-canceling terms)
- Determines what additional constraints are needed for satisfaction
- Names known entities using heuristics
- Can generate a TOML template for further customization
§Constraint Analysis
Not all grade combinations automatically satisfy the geometric constraint
u * ũ = scalar. For combinations that don’t, we analyze:
- Which pairs of grades create conflicting (non-canceling) terms
- What constraints would be needed to satisfy the constraint
For example, [0, 1] (scalar + vector) has a conflict because:
- scalar * vector = vector, and these don’t cancel
- Constraint needed: either scalar = 0 OR vector = 0
§Example
use clifford_codegen::discovery::{discover_entities, analyze_constraints, DiscoveredEntity};
use clifford_codegen::algebra::Algebra;
let algebra = Algebra::euclidean(3);
// Analyze what constraints would be needed for the full multivector
let conflicts = analyze_constraints(&[0, 1, 2, 3], &algebra);
// Returns: conflicting grade pairs like (0, 1), (0, 3), (1, 2), (2, 3)
// Discover entities that automatically satisfy constraints
let entities = discover_entities(&algebra);
assert!(entities.iter().any(|e| e.name == "Entity_0_2")); // [0, 2] - no conflictsRe-exports§
pub use products::BladeProductResult;pub use products::EntityBladeSet;pub use products::ProductResult;pub use products::ProductTable2D;pub use products::ProductType;pub use products::infer_all_products;pub use products::infer_all_products_blades;pub use products::infer_output_blades;pub use products::infer_output_grades;pub use products::infer_product;pub use products::infer_product_blades;
Modules§
- products
- Product output inference for discovered entities.
Structs§
- Discovered
Entity - Represents a discovered geometric entity.
- Grade
Conflict - Represents a conflict between two grades in the geometric constraint.
Functions§
- analyze_
constraints - Analyzes which grade pairs conflict in the geometric constraint.
- can_
satisfy_ constraints - Checks if a grade combination can satisfy constraints with field constraints.
- derive_
antiproduct_ constraint - Derives the antiproduct field constraint expression for a grade combination.
- derive_
blade_ constraint - Derives the blade constraint expression for a grade combination.
- derive_
field_ constraint - Derives the field constraint expression for a grade combination.
- derive_
null_ constraint - Derives the null constraint expression for a grade combination.
- discover_
entities - Discovers the minimal closed set of geometric entities.
- discover_
valid_ combinations - Discovers all valid grade combinations that satisfy geometric constraints.
- enumerate_
grade_ combinations - Enumerates all non-empty grade combinations for an n-dimensional algebra.
- generate_
toml_ template - Generates a TOML template from discovered entities.
- suggest_
name - Generates a name for a grade combination.
- suggest_
required_ constraints - Suggests constraints needed to satisfy the geometric constraint.