Skip to main content

Multivector

Struct Multivector 

Source
pub struct Multivector<const P: usize, const Q: usize, const R: usize, const N: usize> {
    pub coords: [f32; N],
}
Expand description

Fixed-size stack-allocated Multivector in Clifford Algebra Cl(p, q, r).

  • P, Q, R: Metric signature.
  • N: Algebra dimension (2^(P + Q + R)).

Fields§

§coords: [f32; N]

Implementations§

Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Multivector<P, Q, R, N>

Source

pub const fn zero() -> Self

Zero multivector.

Source

pub fn from_scalar(alpha: f32) -> Self

Scalar multivector: alpha * 1.

Source

pub fn from_vector(vec: &[f32]) -> Self

Creates a 1-vector from coordinate slice.

Source

pub fn basis(i: usize) -> Self

Basis element e_i (1-indexed: e_1, e_2, …).

Source

pub fn scalar(&self) -> f32

Scalar part _0.

Source

pub fn grade_projection(&self, grade: usize) -> Self

Extracts the k-th grade projection _k.

Source

pub fn reverse(&self) -> Self

Clifford Reverse: A~ = sum (-1)^{k(k-1)/2} _k.

Source

pub fn grade_involution(&self) -> Self

Grade Involution: A^ = sum (-1)^k _k.

Source

pub fn conjugation(&self) -> Self

Clifford Conjugation: \bar{A} = sum (-1)^{k(k+1)/2} _k.

Source

pub fn geometric_product(&self, rhs: &Self) -> Self

Computes the Clifford Geometric Product: C = A * B.

Source

pub fn wedge(&self, rhs: &Self) -> Self

Computes the Exterior Wedge Product: C = A ^ B.

Source

pub fn left_contraction(&self, rhs: &Self) -> Self

Computes the Left Contraction: C = A _| B.

Source

pub fn right_contraction(&self, rhs: &Self) -> Self

Computes the Right Contraction: C = A |_ B.

Source

pub fn scalar_product(&self, rhs: &Self) -> f32

Scalar product <A, B> = <A B~>_0.

Source

pub fn norm_sq(&self) -> f32

Squared magnitude: ||A||^2 = <A A~>_0.

Source

pub fn norm(&self) -> f32

Magnitude / L2 norm.

Source

pub fn normalize(&self) -> Self

Normalized multivector: A / ||A||.

Source

pub fn sandwich(&self, x: &Self) -> Self

Versor sandwich product: X’ = V X V~.

Source

pub fn pseudoscalar() -> Self

Returns the unit pseudoscalar I = e_1 ^ e_2 ^ … ^ e_n.

Source

pub fn pseudoscalar_inverse() -> Option<Self>

Computes the pseudoscalar inverse I^{-1} for non-degenerate metrics (R == 0). Under signature (P, Q, 0): I^2 = (-1)^{n(n-1)/2 + Q}, so I^{-1} = I * (-1)^{n(n-1)/2 + Q}.

Source

pub fn dual(&self) -> Option<Self>

Computes the Hodge Dual: A* = A I^{-1} (Macdonald Def 6.16, Hestenes Section 1.2).

Source

pub fn undual(&self) -> Self

Computes the Undual (reverse duality): A I.

Source

pub fn commutator(&self, rhs: &Self) -> Self

Computes the Lie Commutator Product: [A, B] = 1/2 (A B - B A) (Hestenes Eq 1.55). Anticommutative: [A, B] = -[B, A]. Satisfies the Jacobi identity.

Source

pub fn anticommutator(&self, rhs: &Self) -> Self

Computes the Jordan Anticommutator (symmetric product): A ⊙ B = 1/2 (A B + B A).

Source

pub fn regressive_product(&self, rhs: &Self) -> Option<Self>

Computes the Regressive (Meet) Product: A ∨ B = (A* ∧ B*).undual() In non-degenerate spaces, gives the geometric intersection of blade subspaces.

Source

pub fn hestenes_inner_product(&self, rhs: &Self) -> Self

Computes the Hestenes Inner Product (Fat Dot): A • B = sum_{r>=1, s>=1} < _r s >{|r - s|}. As defined in Hestenes & Sobczyk (1984), Section 1.1, Eq. 1.8.

Source

pub fn inverse(&self) -> Option<Self>

Computes the exact closed-form algebraic inverse A^{-1} for multivectors:

  • For Cl(2, 0, 0): A^{-1} = \bar{A} / (A \bar{A})_0
  • For Cl(3, 0, 0): A^{-1} = \bar{A} (A \bar{A})~ / det(A)
  • General fallback for versors: A~ / ||A||^2 Returns None if multivector is singular (det(A) == 0).

Trait Implementations§

Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Add for Multivector<P, Q, R, N>

Source§

type Output = Multivector<P, Q, R, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> AddAssign for Multivector<P, Q, R, N>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Clone for Multivector<P, Q, R, N>

Source§

fn clone(&self) -> Self

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<const P: usize, const Q: usize, const R: usize, const N: usize> Copy for Multivector<P, Q, R, N>

Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Debug for Multivector<P, Q, R, N>

Source§

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

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

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Default for Multivector<P, Q, R, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Mul for Multivector<P, Q, R, N>

Source§

type Output = Multivector<P, Q, R, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Mul<f32> for Multivector<P, Q, R, N>

Source§

type Output = Multivector<P, Q, R, N>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f32) -> Self

Performs the * operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Neg for Multivector<P, Q, R, N>

Source§

type Output = Multivector<P, Q, R, N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> PartialEq for Multivector<P, Q, R, N>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> StructuralPartialEq for Multivector<P, Q, R, N>

Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Sub for Multivector<P, Q, R, N>

Source§

type Output = Multivector<P, Q, R, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> SubAssign for Multivector<P, Q, R, N>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Forget for Multivector<P, Q, R, N>

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Freeze for Multivector<P, Q, R, N>
where [f32; N]: Freeze,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Move for Multivector<P, Q, R, N>

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> RefUnwindSafe for Multivector<P, Q, R, N>
where [f32; N]: RefUnwindSafe,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Send for Multivector<P, Q, R, N>
where [f32; N]: Send,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Sync for Multivector<P, Q, R, N>
where [f32; N]: Sync,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> Unpin for Multivector<P, Q, R, N>
where [f32; N]: Unpin,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> UnsafeUnpin for Multivector<P, Q, R, N>
where [f32; N]: UnsafeUnpin,

§

impl<const P: usize, const Q: usize, const R: usize, const N: usize> UnwindSafe for Multivector<P, Q, R, N>
where [f32; N]: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.