Skip to main content

Module discovery

Module discovery 

Source
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:

  1. Enumerates all possible grade combinations
  2. Analyzes which grade pairs conflict (create non-canceling terms)
  3. Determines what additional constraints are needed for satisfaction
  4. Names known entities using heuristics
  5. 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 conflicts

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

DiscoveredEntity
Represents a discovered geometric entity.
GradeConflict
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.