clifford/specialized/complex/generated/
conversions.rs1#![doc = " Multivector conversions for complex."]
2#![doc = ""]
3#![doc = " This file is auto-generated by clifford-codegen."]
4#![doc = " Do not edit manually."]
5use super::types::{Complex, ImagUnit, Scalar};
6use crate::algebra::Multivector;
7use crate::basis::Blade;
8use crate::scalar::Float;
9use crate::signature::Cl0_1_0;
10impl<T: Float> From<Complex<T>> for Multivector<T, Cl0_1_0> {
11 fn from(value: Complex<T>) -> Self {
12 Self::from_coeffs(&[value.real(), value.imag()])
13 }
14}
15impl<T: Float> From<ImagUnit<T>> for Multivector<T, Cl0_1_0> {
16 fn from(value: ImagUnit<T>) -> Self {
17 Self::from_coeffs(&[T::zero(), value.i()])
18 }
19}
20impl<T: Float> From<Scalar<T>> for Multivector<T, Cl0_1_0> {
21 fn from(value: Scalar<T>) -> Self {
22 Self::from_coeffs(&[value.s(), T::zero()])
23 }
24}
25impl<T: Float> From<Multivector<T, Cl0_1_0>> for Complex<T> {
26 #[doc = r" Extracts this type from a multivector."]
27 #[doc = r""]
28 #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
29 #[doc = r" grades. Other components of the multivector are discarded."]
30 fn from(mv: Multivector<T, Cl0_1_0>) -> Self {
31 Self::new_unchecked(
32 mv.get(Blade::from_index(0usize)),
33 mv.get(Blade::from_index(1usize)),
34 )
35 }
36}
37impl<T: Float> From<Multivector<T, Cl0_1_0>> for ImagUnit<T> {
38 #[doc = r" Extracts this type from a multivector."]
39 #[doc = r""]
40 #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
41 #[doc = r" grades. Other components of the multivector are discarded."]
42 fn from(mv: Multivector<T, Cl0_1_0>) -> Self {
43 Self::new_unchecked(mv.get(Blade::from_index(1usize)))
44 }
45}
46impl<T: Float> From<Multivector<T, Cl0_1_0>> for Scalar<T> {
47 #[doc = r" Extracts this type from a multivector."]
48 #[doc = r""]
49 #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
50 #[doc = r" grades. Other components of the multivector are discarded."]
51 fn from(mv: Multivector<T, Cl0_1_0>) -> Self {
52 Self::new_unchecked(mv.get(Blade::from_index(0usize)))
53 }
54}