pub enum Metric {
Euclidean(usize),
NonEuclidean(usize),
Minkowski(usize),
Lorentzian(usize),
PGA(usize),
Generic {
p: usize,
q: usize,
r: usize,
},
Custom {
dim: usize,
neg_mask: u64,
zero_mask: u64,
},
}Expand description
Defines the metric signature of the Clifford Algebra Cl(p, q, r).
The metric determines the squaring behavior of the basis vectors $e_i$:
- $e_i^2 = +1$ (positive, timelike in West Coast)
- $e_i^2 = -1$ (negative, timelike in East Coast)
- $e_i^2 = 0$ (degenerate, null)
The dimension $N = p + q + r$ is the total number of basis vectors.
Variants§
Euclidean(usize)
All basis vectors square to +1. Signature: (N, 0, 0)
NonEuclidean(usize)
All basis vectors square to -1. Signature: (0, N, 0)
Minkowski(usize)
West Coast Minkowski: e₀² = +1, others = -1. Signature: (1, N-1, 0) Also known as: Weinberg, Particle Physics, “mostly minus”
Lorentzian(usize)
East Coast Lorentzian: e₀² = -1, others = +1. Signature: (N-1, 1, 0) Also known as: GR, “mostly plus”
PGA(usize)
Projective Geometric Algebra (PGA). Convention: e₀² = 0 (degenerate), others +1. Signature: (N-1, 0, 1) where the first vector is the zero vector.
Generic
Explicit generic signature Cl(p, q, r). Order of generators assumed: First p are (+), next q are (-), last r are (0).
Custom
Fully arbitrary signature defined by bitmasks. dim: Total dimension neg_mask: bit is 1 if e_i² = -1 zero_mask: bit is 1 if e_i² = 0 (If both bits are 0, default is +1)
Implementations§
Source§impl Metric
impl Metric
Sourcepub fn dimension(&self) -> usize
pub fn dimension(&self) -> usize
Returns the total dimension of the vector space (N = p + q + r)
Sourcepub fn sign_of_sq(&self, i: usize) -> i32
pub fn sign_of_sq(&self, i: usize) -> i32
Returns the value of the basis vector squared: $e_i^2$. Possible return values: 1, -1, or 0.
§Arguments
i- The 0-indexed generator index (0..N-1).
Sourcepub fn signature(&self) -> (usize, usize, usize)
pub fn signature(&self) -> (usize, usize, usize)
Returns the signature tuple (p, q, r) where:
- p: number of +1 eigenvalues
- q: number of -1 eigenvalues
- r: number of 0 eigenvalues (degenerate)
Sourcepub fn flip_time_space(&self) -> Metric
pub fn flip_time_space(&self) -> Metric
Flip time and space signs (convert between East Coast and West Coast conventions).
This swaps +1 ↔ -1 for all basis vectors while preserving degenerate (0) vectors. Minkowski(n) becomes Custom with East Coast convention (-+++…).
Sourcepub fn tensor_product(&self, other: &Metric) -> Metric
pub fn tensor_product(&self, other: &Metric) -> Metric
Merges two metrics during a Tensor Product (Monad bind). e.g., Euclidean(2) + Euclidean(2) -> Euclidean(4)
Sourcepub fn is_compatible(&self, other: &Metric) -> bool
pub fn is_compatible(&self, other: &Metric) -> bool
Check if two metrics are compatible for operations.
Two metrics are compatible if they have the same dimension and signature.
Sourcepub fn to_generic(&self) -> Metric
pub fn to_generic(&self) -> Metric
Normalize to Generic form for comparison.
This converts any Metric variant to its Generic equivalent, allowing comparison of metrics with different representations.
Sourcepub fn from_signature(p: usize, q: usize, r: usize) -> Metric
pub fn from_signature(p: usize, q: usize, r: usize) -> Metric
Create a Metric from (p, q, r) signature.
This creates the most appropriate Metric variant based on the signature:
- (n, 0, 0) -> Euclidean(n)
- (0, n, 0) -> NonEuclidean(n)
- (1, n-1, 0) -> Minkowski(n)
- (n-1, 0, 1) -> PGA(n)
- otherwise -> Generic { p, q, r }