src/direct_product.rs

branch
dev
changeset 129
d2994e34a5f5
parent 124
6aa955ad8122
child 130
0a689881b0f1
--- a/src/direct_product.rs	Sun May 11 02:03:45 2025 -0500
+++ b/src/direct_product.rs	Mon May 12 15:42:48 2025 -0500
@@ -244,13 +244,13 @@
 impl_binary_mut!(SubAssign, sub_assign);
 
 macro_rules! impl_scalar_mut {
-    ($trait:ident, $fn:ident, $F:ty) => {
-        impl<'a, A, B> $trait<$F> for Pair<A, B>
+    ($trait:ident, $fn:ident) => {
+        impl<'a, A, B, F: Num> $trait<F> for Pair<A, B>
         where
-            A: $trait<$F>,
-            B: $trait<$F>,
+            A: $trait<F>,
+            B: $trait<F>,
         {
-            fn $fn(&mut self, t: $F) {
+            fn $fn(&mut self, t: F) {
                 let Pair(ref mut a, ref mut b) = self;
                 a.$fn(t);
                 b.$fn(t);
@@ -259,10 +259,8 @@
     };
 }
 
-impl_scalar_mut!(MulAssign, mul_assign, f32);
-impl_scalar_mut!(MulAssign, mul_assign, f64);
-impl_scalar_mut!(DivAssign, div_assign, f32);
-impl_scalar_mut!(DivAssign, div_assign, f64);
+impl_scalar_mut!(MulAssign, mul_assign);
+impl_scalar_mut!(DivAssign, div_assign);
 
 /// We only support 'closed' `Euclidean` `Pair`s, as more general ones cause
 /// compiler overflows.
@@ -303,17 +301,20 @@
     }
 }
 
-impl<F, A, B, U, V> AXPY<F, Pair<U, V>> for Pair<A, B>
+impl<F, A, B, U, V> AXPY<Pair<U, V>> for Pair<A, B>
 where
     U: Space,
     V: Space,
-    A: AXPY<F, U>,
-    B: AXPY<F, V>,
+    A: AXPY<U, Field = F>,
+    B: AXPY<V, Field = F>,
     F: Num,
     Self: MulAssign<F>,
     Pair<A, B>: MulAssign<F>,
-    Pair<A::Owned, B::Owned>: AXPY<F, Pair<U, V>>,
+    //A::Owned: MulAssign<F>,
+    //B::Owned: MulAssign<F>,
+    //Pair<A::Owned, B::Owned>: AXPY<Pair<U, V>, Field = F>,
 {
+    type Field = F;
     type Owned = Pair<A::Owned, B::Owned>;
 
     fn axpy<I: Instance<Pair<U, V>>>(&mut self, α: F, x: I, β: F) {

mercurial