#![doc = " Multivector conversions for dual."]
#![doc = ""]
#![doc = " This file is auto-generated by clifford-codegen."]
#![doc = " Do not edit manually."]
use super::types::{Dual, DualUnit, Scalar};
use crate::algebra::Multivector;
use crate::basis::Blade;
use crate::scalar::Float;
use crate::signature::Cl0_0_1;
impl<T: Float> From<Dual<T>> for Multivector<T, Cl0_0_1> {
fn from(value: Dual<T>) -> Self {
Self::from_coeffs(&[value.real(), value.dual()])
}
}
impl<T: Float> From<DualUnit<T>> for Multivector<T, Cl0_0_1> {
fn from(value: DualUnit<T>) -> Self {
Self::from_coeffs(&[T::zero(), value.eps()])
}
}
impl<T: Float> From<Scalar<T>> for Multivector<T, Cl0_0_1> {
fn from(value: Scalar<T>) -> Self {
Self::from_coeffs(&[value.s(), T::zero()])
}
}
impl<T: Float> From<Multivector<T, Cl0_0_1>> for Dual<T> {
#[doc = r" Extracts this type from a multivector."]
#[doc = r""]
#[doc = r" Note: This is a lossy projection that only extracts the relevant"]
#[doc = r" grades. Other components of the multivector are discarded."]
fn from(mv: Multivector<T, Cl0_0_1>) -> Self {
Self::new_unchecked(
mv.get(Blade::from_index(0usize)),
mv.get(Blade::from_index(1usize)),
)
}
}
impl<T: Float> From<Multivector<T, Cl0_0_1>> for DualUnit<T> {
#[doc = r" Extracts this type from a multivector."]
#[doc = r""]
#[doc = r" Note: This is a lossy projection that only extracts the relevant"]
#[doc = r" grades. Other components of the multivector are discarded."]
fn from(mv: Multivector<T, Cl0_0_1>) -> Self {
Self::new_unchecked(mv.get(Blade::from_index(1usize)))
}
}
impl<T: Float> From<Multivector<T, Cl0_0_1>> for Scalar<T> {
#[doc = r" Extracts this type from a multivector."]
#[doc = r""]
#[doc = r" Note: This is a lossy projection that only extracts the relevant"]
#[doc = r" grades. Other components of the multivector are discarded."]
fn from(mv: Multivector<T, Cl0_0_1>) -> Self {
Self::new_unchecked(mv.get(Blade::from_index(0usize)))
}
}