use crate::{CausalMultiVectorError, MultiVector};
impl MultiVector<f64> for f64 {
fn grade_projection(&self, k: u32) -> Self {
if k == 0 { *self } else { 0.0 }
}
fn reversion(&self) -> Self {
*self
}
fn squared_magnitude(&self) -> Self {
self * self
}
fn inverse(&self) -> Result<Self, CausalMultiVectorError>
where
Self: Sized,
{
if *self == 0.0 {
Err(CausalMultiVectorError::zero_magnitude())
} else {
Ok(1.0 / *self)
}
}
fn dual(&self) -> Result<Self, CausalMultiVectorError>
where
Self: Sized,
{
Ok(*self)
}
fn geometric_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn outer_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn inner_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn commutator_lie(&self, _rhs: &Self) -> Self {
0.0
}
fn commutator_geometric(&self, _rhs: &Self) -> Self {
0.0
}
fn basis_shift(&self, _index: usize) -> Self {
*self
}
}
impl MultiVector<f32> for f32 {
fn grade_projection(&self, k: u32) -> Self {
if k == 0 { *self } else { 0.0 }
}
fn reversion(&self) -> Self {
*self
}
fn squared_magnitude(&self) -> Self {
self * self
}
fn inverse(&self) -> Result<Self, CausalMultiVectorError>
where
Self: Sized,
{
if *self == 0.0 {
Err(CausalMultiVectorError::zero_magnitude())
} else {
Ok(1.0 / *self)
}
}
fn dual(&self) -> Result<Self, CausalMultiVectorError>
where
Self: Sized,
{
Ok(*self)
}
fn geometric_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn outer_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn inner_product(&self, rhs: &Self) -> Self {
self * rhs
}
fn commutator_lie(&self, _rhs: &Self) -> Self {
0.0
}
fn commutator_geometric(&self, _rhs: &Self) -> Self {
0.0
}
fn basis_shift(&self, _index: usize) -> Self {
*self
}
}