--- a/src/direct_product.rs Mon May 12 21:56:42 2025 -0500 +++ b/src/direct_product.rs Mon May 12 22:48:16 2025 -0500 @@ -6,7 +6,9 @@ */ use crate::euclidean::Euclidean; -use crate::instance::{Decomposition, DecompositionMut, Instance, InstanceMut, MyCow}; +use crate::instance::{ + Decomposition, DecompositionMut, Instance, InstanceMut, Instantiated, MyCow, +}; use crate::linops::AXPY; use crate::loc::Loc; use crate::mapping::Space; @@ -367,6 +369,25 @@ Pair<A, B>: 'b; } +impl<A, B, U, V, D, Q> Instantiated<Pair<A, B>, PairDecomposition<D, Q>> for Pair<U, V> +where + A: Space, + B: Space, + U: Instantiated<A, D>, + V: Instantiated<B, Q>, + D: Decomposition<A>, + Q: Decomposition<B>, +{ + type RefInstance<'b> + = Pair<U::RefInstance<'b>, V::RefInstance<'b>> + where + Self: 'b; + + fn ref_inst(&self) -> Self::RefInstance<'_> { + Pair(self.0.ref_inst(), self.1.ref_inst()) + } +} + impl<A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for Pair<U, V> where A: Space, @@ -376,6 +397,12 @@ U: Instance<A, D>, V: Instance<B, Q>, { + type Instantiated = Pair<U::Instantiated, V::Instantiated>; + + fn instantiate(self) -> Self::Instantiated { + Pair(self.0.instantiate(), self.1.instantiate()) + } + fn eval_decompose<'b, R>( self, f: impl FnOnce(Pair<D::Decomposition<'b>, Q::Decomposition<'b>>) -> R, @@ -425,6 +452,14 @@ &'a U: Instance<A, D>, &'a V: Instance<B, Q>, { + type Instantiated = + Pair<<&'a U as Instance<A, D>>::Instantiated, <&'a V as Instance<B, Q>>::Instantiated>; + + fn instantiate(self) -> Self::Instantiated { + let &Pair(ref u, ref v) = self; + Pair(u.instantiate(), v.instantiate()) + } + fn eval_decompose<'b, R>( self, f: impl FnOnce(Pair<D::Decomposition<'b>, Q::Decomposition<'b>>) -> R,