#![cfg_attr(all(target_arch = "wasm32", target_feature = "simd128"), feature(wasm_simd))]
#![cfg_attr(all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "neon"), feature(stdsimd))]
pub mod simd;
pub mod complex;
pub mod ppga2d;
pub mod ppga3d;
impl complex::Scalar {
pub const fn new(real: f32) -> Self {
Self { g0: real }
}
pub fn real(self) -> f32 {
self.g0
}
pub fn sqrt(self) -> complex::MultiVector {
if self.g0 < 0.0 {
complex::MultiVector::new(0.0, (-self.g0).sqrt())
} else {
complex::MultiVector::new(self.g0.sqrt(), 0.0)
}
}
}
impl complex::MultiVector {
pub const fn new(real: f32, imaginary: f32) -> Self {
Self {
g0: simd::Simd32x2 {
f32x2: [real, imaginary],
},
}
}
pub fn real(self) -> f32 {
self.g0.get_f(0)
}
pub fn imaginary(self) -> f32 {
self.g0.get_f(1)
}
pub fn from_polar(magnitude: f32, angle: f32) -> Self {
Self::new(magnitude * angle.cos(), magnitude * angle.sin())
}
pub fn arg(self) -> f32 {
self.imaginary().atan2(self.real())
}
pub fn powf(self, exponent: f32) -> Self {
Self::from_polar(self.magnitude().g0.powf(exponent), self.arg() * exponent)
}
}
pub trait Zero {
fn zero() -> Self;
}
pub trait One {
fn one() -> Self;
}
pub trait Dual {
type Output;
fn dual(self) -> Self::Output;
}
pub trait Automorph {
type Output;
fn automorph(self) -> Self::Output;
}
pub trait Transpose {
type Output;
fn transpose(self) -> Self::Output;
}
pub trait Conjugate {
type Output;
fn conjugate(self) -> Self::Output;
}
pub trait GeometricProduct<T> {
type Output;
fn geometric_product(self, other: T) -> Self::Output;
}
pub trait RegressiveProduct<T> {
type Output;
fn regressive_product(self, other: T) -> Self::Output;
}
pub trait OuterProduct<T> {
type Output;
fn outer_product(self, other: T) -> Self::Output;
}
pub trait InnerProduct<T> {
type Output;
fn inner_product(self, other: T) -> Self::Output;
}
pub trait LeftContraction<T> {
type Output;
fn left_contraction(self, other: T) -> Self::Output;
}
pub trait RightContraction<T> {
type Output;
fn right_contraction(self, other: T) -> Self::Output;
}
pub trait ScalarProduct<T> {
type Output;
fn scalar_product(self, other: T) -> Self::Output;
}
pub trait Reflection<T> {
type Output;
fn reflection(self, other: T) -> Self::Output;
}
pub trait Transformation<T> {
type Output;
fn transformation(self, other: T) -> Self::Output;
}
pub trait SquaredMagnitude {
type Output;
fn squared_magnitude(self) -> Self::Output;
}
pub trait Magnitude {
type Output;
fn magnitude(self) -> Self::Output;
}
pub trait Signum {
type Output;
fn signum(self) -> Self::Output;
}
pub trait Inverse {
type Output;
fn inverse(self) -> Self::Output;
}
pub trait Powi {
type Output;
fn powi(self, exponent: isize) -> Self::Output;
}