From 48b86638a58a6e369c3c25838f8719b4cf2ea3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Sat, 26 Nov 2022 14:25:33 +0100 Subject: [PATCH] Removes Mul alias for GeometricProduct. --- codegen/src/compile.rs | 36 ------------------------------------ codegen/src/main.rs | 2 -- src/lib.rs | 16 ++++++++++++---- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/codegen/src/compile.rs b/codegen/src/compile.rs index 9b8af07..d47af00 100644 --- a/codegen/src/compile.rs +++ b/codegen/src/compile.rs @@ -592,42 +592,6 @@ impl MultiVectorClass { } } - pub fn derive_multiplication<'a>( - name: &'static str, - geometric_product: &AstNode<'a>, - parameter_a: &Parameter<'a>, - parameter_b: &Parameter<'a>, - ) -> AstNode<'a> { - let geometric_product_result = result_of_trait!(geometric_product); - AstNode::TraitImplementation { - result: Parameter { - name, - data_type: geometric_product_result.data_type.clone(), - }, - parameters: vec![parameter_a.clone(), parameter_b.clone()], - body: vec![AstNode::ReturnStatement { - expression: Box::new(Expression { - size: 1, - content: ExpressionContent::InvokeInstanceMethod( - parameter_a.data_type.clone(), - Box::new(Expression { - size: 1, - content: ExpressionContent::Variable(parameter_a.name), - }), - geometric_product_result.name, - vec![( - DataType::MultiVector(parameter_b.multi_vector_class()), - Expression { - size: 1, - content: ExpressionContent::Variable(parameter_b.name), - }, - )], - ), - }), - }], - } - } - pub fn derive_squared_magnitude<'a>( name: &'static str, scalar_product: &AstNode<'a>, diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 571be4b..2369fb9 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -158,8 +158,6 @@ fn main() { for (parameter_b, pair_trait_implementations) in pair_trait_implementations.values() { if let Some(geometric_product) = pair_trait_implementations.get("GeometricProduct") { let geometric_product_result = result_of_trait!(geometric_product); - let multiplication = MultiVectorClass::derive_multiplication("Mul", &geometric_product, ¶meter_a, ¶meter_b); - emitter.emit(&multiplication).unwrap(); if parameter_a.multi_vector_class() == parameter_b.multi_vector_class() && geometric_product_result.multi_vector_class() == parameter_a.multi_vector_class() { diff --git a/src/lib.rs b/src/lib.rs index 0a86ce7..0271d0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,9 @@ impl Powf for ppga2d::Translator { type Output = Self; fn powf(self, exponent: f32) -> Self { - (ppga2d::Scalar::from([exponent]) * self.ln()).exp() + self.ln() + .geometric_product(ppga2d::Scalar::from([exponent])) + .exp() } } @@ -127,7 +129,9 @@ impl Powf for ppga2d::Motor { type Output = Self; fn powf(self, exponent: f32) -> Self { - (ppga2d::Scalar::from([exponent]) * self.ln()).exp() + self.ln() + .geometric_product(ppga2d::Scalar::from([exponent])) + .exp() } } @@ -152,7 +156,9 @@ impl Powf for ppga3d::Translator { type Output = Self; fn powf(self, exponent: f32) -> Self { - (ppga3d::Scalar::from([exponent]) * self.ln()).exp() + self.ln() + .geometric_product(ppga3d::Scalar::from([exponent])) + .exp() } } @@ -196,7 +202,9 @@ impl Powf for ppga3d::Motor { type Output = Self; fn powf(self, exponent: f32) -> Self { - (ppga3d::Scalar::from([exponent]) * self.ln()).exp() + self.ln() + .geometric_product(ppga3d::Scalar::from([exponent])) + .exp() } }