Expand description
Algebra specification parsing and representation.
This module provides types and functions for parsing TOML specifications that describe geometric algebras and their types.
§Specification Format
Specifications are written in TOML with the following structure:
[algebra]
name = "euclidean3" # Required: identifier
module_path = "euclidean::dim3" # Optional: Rust module path
description = "3D Euclidean GA" # Optional: documentation
[signature]
positive = ["e1", "e2", "e3"] # Basis vectors squaring to +1
negative = [] # Basis vectors squaring to -1
zero = [] # Basis vectors squaring to 0
[blades]
e12 = "xy" # Custom blade names
e13 = "xz"
e23 = "yz"
[types.Vector]
grades = [1] # Which grades this type contains
field_map = [ # Field-to-blade mappings
{ name = "x", blade = "e1" },
{ name = "y", blade = "e2" },
{ name = "z", blade = "e3" }
]
[types.Rotor]
grades = [0, 2]
field_map = [
{ name = "s", blade = "s" },
{ name = "xy", blade = "e12" },
{ name = "xz", blade = "e13" },
{ name = "yz", blade = "e23" }
]§Example
use clifford_codegen::spec::parse_spec;
let spec = parse_spec(r#"
[algebra]
name = "euclidean2"
complete = false
[signature]
positive = ["e1", "e2"]
[types.Vector]
grades = [1]
field_map = [
{ name = "x", blade = "e1" },
{ name = "y", blade = "e2" }
]
"#).unwrap();
assert_eq!(spec.name, "euclidean2");
assert_eq!(spec.signature.dim(), 2);Structs§
- Algebra
Spec - Parsed algebra specification.
- Basis
Vector - A single basis vector in the signature.
- Field
Spec - A field in a type.
- Norm
Spec - Norm configuration for an algebra.
- Product
Entry - A single product entry specifying lhs × rhs → output.
- Products
Spec - Product specifications for all product types.
- Signature
Spec - Metric signature specification.
- Type
Spec - A type definition in the specification.
Enums§
- Involution
Kind - Involution kind for norm computation.
- Parse
Error - Errors that can occur when parsing an algebra specification.
- Wrapper
Kind - Wrapper constraint kinds for constraint simplification.
Constants§
- EUCLIDEA
N2 - 2D Euclidean algebra specification (TOML).
- EUCLIDEA
N3 - 3D Euclidean algebra specification (TOML).
Functions§
- parse_
spec - Parses a TOML specification into the IR.