Skip to main content

Metric

Enum Metric 

Source
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).

Fields

§

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)

Fields

§dim: usize
§neg_mask: u64
§zero_mask: u64

Implementations§

Source§

impl Metric

Source

pub fn dimension(&self) -> usize

Returns the total dimension of the vector space (N = p + q + r)

Source

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).
Source

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

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 (-+++…).

Source

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)

Source

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.

Source

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.

Source

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

pub fn from_signs(signs: &[i32]) -> Result<Metric, MetricError>

Create a Custom Metric from an explicit signs array.

§Arguments
  • signs - Array of signs for each basis vector (+1, -1, or 0)
§Returns
  • Ok(Metric) - A Custom metric with the specified signs
  • Err(MetricError) - If dimension is 0 or exceeds 64
Source

pub fn to_signs(&self) -> Vec<i32>

Extract signs as a vector.

Returns a Vec containing the sign (+1, -1, or 0) of each basis vector.

Trait Implementations§

Source§

impl Clone for Metric

Source§

fn clone(&self) -> Metric

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Metric

Source§

impl Debug for Metric

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Metric

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Metric

Source§

impl Hash for Metric

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Metric

Source§

fn eq(&self, other: &Metric) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Metric

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Satisfies<NoConstraint> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.