Skip to main content

Module spec

Module spec 

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

AlgebraSpec
Parsed algebra specification.
BasisVector
A single basis vector in the signature.
FieldSpec
A field in a type.
NormSpec
Norm configuration for an algebra.
ProductEntry
A single product entry specifying lhs × rhs → output.
ProductsSpec
Product specifications for all product types.
SignatureSpec
Metric signature specification.
TypeSpec
A type definition in the specification.

Enums§

InvolutionKind
Involution kind for norm computation.
ParseError
Errors that can occur when parsing an algebra specification.
WrapperKind
Wrapper constraint kinds for constraint simplification.

Constants§

EUCLIDEAN2
2D Euclidean algebra specification (TOML).
EUCLIDEAN3
3D Euclidean algebra specification (TOML).

Functions§

parse_spec
Parses a TOML specification into the IR.