pub struct Multivector<const P: usize, const Q: usize, const R: usize> { /* private fields */ }Expand description
A multivector in a Clifford algebra Cl(P,Q,R)
§Type Parameters
P: Number of basis vectors that square to +1Q: Number of basis vectors that square to -1R: Number of basis vectors that square to 0
Implementations§
Source§impl<const P: usize, const Q: usize, const R: usize> Multivector<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Multivector<P, Q, R>
Sourcepub const BASIS_COUNT: usize
pub const BASIS_COUNT: usize
Total number of basis blades (2^DIM)
Sourcepub fn from_vector(vector: &Vector<P, Q, R>) -> Self
pub fn from_vector(vector: &Vector<P, Q, R>) -> Self
Create multivector from vector
Sourcepub fn from_bivector(bivector: &Bivector<P, Q, R>) -> Self
pub fn from_bivector(bivector: &Bivector<P, Q, R>) -> Self
Create multivector from bivector
Sourcepub fn basis_vector(i: usize) -> Self
pub fn basis_vector(i: usize) -> Self
Create a basis vector e_i (i starts from 0)
Sourcepub fn from_coefficients(coefficients: Vec<f64>) -> Self
pub fn from_coefficients(coefficients: Vec<f64>) -> Self
Create a multivector from coefficients
Sourcepub fn from_slice(coefficients: &[f64]) -> Self
pub fn from_slice(coefficients: &[f64]) -> Self
Create a multivector from a slice (convenience for tests)
Sourcepub fn scalar_part(&self) -> f64
pub fn scalar_part(&self) -> f64
Get the scalar part (grade 0)
Sourcepub fn set_scalar(&mut self, value: f64)
pub fn set_scalar(&mut self, value: f64)
Set the scalar part
Sourcepub fn vector_part(&self) -> Vector<P, Q, R>
pub fn vector_part(&self) -> Vector<P, Q, R>
Get vector part as a Vector type
Sourcepub fn bivector_part(&self) -> Self
pub fn bivector_part(&self) -> Self
Get bivector part as a Multivector (grade 2 projection)
Sourcepub fn bivector_type(&self) -> Bivector<P, Q, R>
pub fn bivector_type(&self) -> Bivector<P, Q, R>
Get bivector part as a Bivector type wrapper
Sourcepub fn trivector_part(&self) -> f64
pub fn trivector_part(&self) -> f64
Get trivector part (scalar for 3D)
Sourcepub fn set_vector_component(&mut self, index: usize, value: f64)
pub fn set_vector_component(&mut self, index: usize, value: f64)
Set vector component
Sourcepub fn set_bivector_component(&mut self, index: usize, value: f64)
pub fn set_bivector_component(&mut self, index: usize, value: f64)
Set bivector component
Sourcepub fn vector_component(&self, index: usize) -> f64
pub fn vector_component(&self, index: usize) -> f64
Get vector component
Sourcepub fn grade(&self) -> usize
pub fn grade(&self) -> usize
Get the grade of a multivector (returns the highest non-zero grade)
Sourcepub fn outer_product_with_vector(&self, other: &Vector<P, Q, R>) -> Self
pub fn outer_product_with_vector(&self, other: &Vector<P, Q, R>) -> Self
Outer product with a vector (convenience method)
Sourcepub fn geometric_product(&self, rhs: &Self) -> Self
pub fn geometric_product(&self, rhs: &Self) -> Self
Geometric product with another multivector
The geometric product is the fundamental operation in geometric algebra, combining both the inner and outer products.
Sourcepub fn geometric_product_scalar(&self, rhs: &Self) -> Self
pub fn geometric_product_scalar(&self, rhs: &Self) -> Self
Scalar implementation of geometric product (fallback)
Sourcepub fn inner_product(&self, rhs: &Self) -> Self
pub fn inner_product(&self, rhs: &Self) -> Self
Inner product (grade-lowering, dot product for vectors)
Sourcepub fn outer_product(&self, rhs: &Self) -> Self
pub fn outer_product(&self, rhs: &Self) -> Self
Outer product (wedge product, grade-raising)
Sourcepub fn scalar_product(&self, rhs: &Self) -> f64
pub fn scalar_product(&self, rhs: &Self) -> f64
Scalar product (grade-0 part of geometric product)
Sourcepub fn reverse(&self) -> Self
pub fn reverse(&self) -> Self
Reverse operation (reverses order of basis vectors in each blade)
Sourcepub fn grade_projection(&self, grade: usize) -> Self
pub fn grade_projection(&self, grade: usize) -> Self
Grade projection - extract components of a specific grade
Sourcepub fn norm_squared(&self) -> f64
pub fn norm_squared(&self) -> f64
Compute the norm squared (scalar product with reverse)
Sourcepub fn magnitude(&self) -> f64
pub fn magnitude(&self) -> f64
Compute the magnitude (length) of this multivector
The magnitude is defined as |a| = √(a·ã) where ã is the reverse of a. This provides the natural norm inherited from the underlying vector space.
§Mathematical Properties
- Always non-negative: |a| ≥ 0
- Zero iff a = 0: |a| = 0 ⟺ a = 0
- Sub-multiplicative: |ab| ≤ |a||b|
§Examples
use amari_core::Multivector;
let v = Multivector::<3,0,0>::basis_vector(0);
assert_eq!(v.magnitude(), 1.0);Sourcepub fn norm(&self) -> f64
pub fn norm(&self) -> f64
Compute the norm (magnitude) of this multivector
Note: This method is maintained for backward compatibility.
New code should prefer magnitude() for clarity.
Sourcepub fn exp(&self) -> Self
pub fn exp(&self) -> Self
Exponential map for bivectors (creates rotors)
For a bivector B, exp(B) creates a rotor that performs rotation in the plane defined by B.
Sourcepub fn left_contraction(&self, other: &Self) -> Self
pub fn left_contraction(&self, other: &Self) -> Self
Left contraction: a ⌟ b
Generalized inner product where the grade of the result is |grade(b) - grade(a)|. The left operand’s grade is reduced.
Sourcepub fn right_contraction(&self, other: &Self) -> Self
pub fn right_contraction(&self, other: &Self) -> Self
Right contraction: a ⌞ b
Generalized inner product where the grade of the result is |grade(a) - grade(b)|. The right operand’s grade is reduced.
Sourcepub fn hodge_dual(&self) -> Self
pub fn hodge_dual(&self) -> Self
Hodge dual: ⋆a
Maps k-vectors to (n-k)-vectors in n-dimensional space. Essential for electromagnetic field theory and differential forms. In 3D: scalar -> pseudoscalar, vector -> bivector, bivector -> vector, pseudoscalar -> scalar
Trait Implementations§
Source§impl<const P: usize, const Q: usize, const R: usize> Add for &Multivector<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Add for &Multivector<P, Q, R>
Source§type Output = Multivector<P, Q, R>
type Output = Multivector<P, Q, R>
+ operator.Source§fn add(self, rhs: Self) -> Multivector<P, Q, R>
fn add(self, rhs: Self) -> Multivector<P, Q, R>
+ operation. Read moreSource§impl<const P: usize, const Q: usize, const R: usize> Clone for Multivector<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Clone for Multivector<P, Q, R>
Source§fn clone(&self) -> Multivector<P, Q, R>
fn clone(&self) -> Multivector<P, Q, R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const P: usize, const Q: usize, const R: usize> Mul<f64> for &Multivector<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Mul<f64> for &Multivector<P, Q, R>
Source§type Output = Multivector<P, Q, R>
type Output = Multivector<P, Q, R>
* operator.Source§impl<const P: usize, const Q: usize, const R: usize> Sub for &Multivector<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Sub for &Multivector<P, Q, R>
Source§type Output = Multivector<P, Q, R>
type Output = Multivector<P, Q, R>
- operator.Source§fn sub(self, rhs: Self) -> Multivector<P, Q, R>
fn sub(self, rhs: Self) -> Multivector<P, Q, R>
- operation. Read more