diff -r c4e394a9c84c -r 402d717bb5c0 src/linops.rs --- a/src/linops.rs Mon Sep 01 13:51:03 2025 -0500 +++ b/src/linops.rs Mon Sep 01 20:55:34 2025 -0500 @@ -36,6 +36,8 @@ + Sub + Sub + Neg + + for<'b> Add<&'b Self, Output = ::Owned> + + for<'b> Sub<&'b Self, Output = ::Owned> { type Field: Num; type Owned: ClosedSpace @@ -69,6 +71,8 @@ + AddAssign + SubAssign + SubAssign + + for<'b> AddAssign<&'b Self> + + for<'b> SubAssign<&'b Self> where X: Space, { @@ -89,6 +93,9 @@ fn set_zero(&mut self); } +pub trait ClosedVectorSpace: Instance + VectorSpace {} +impl + VectorSpace> ClosedVectorSpace for X {} + /// Efficient in-place application for [`Linear`] operators. #[replace_float_literals(F::cast_from(literal))] pub trait GEMV>::Codomain>: Linear { @@ -141,7 +148,7 @@ X: Space, Yʹ: Space, { - type AdjointCodomain: Space; + type AdjointCodomain: ClosedSpace; type Adjoint<'a>: Linear where Self: 'a; @@ -163,7 +170,7 @@ pub trait Preadjointable>::Codomain>: Linear { - type PreadjointCodomain: Space; + type PreadjointCodomain: ClosedSpace; type Preadjoint<'a>: Linear where Self: 'a; @@ -190,10 +197,10 @@ } impl Mapping for IdOp { - type Codomain = X::OwnedVariant; + type Codomain = X::OwnedSpace; - fn apply>(&self, x: I) -> X { - x.own() + fn apply>(&self, x: I) -> Self::Codomain { + x.own().into_owned() } } @@ -226,10 +233,10 @@ } } -impl Adjointable for IdOp { - type AdjointCodomain = X; +impl Adjointable for IdOp { + type AdjointCodomain = X::OwnedSpace; type Adjoint<'a> - = IdOp + = IdOp where X: 'a; @@ -238,10 +245,10 @@ } } -impl Preadjointable for IdOp { - type PreadjointCodomain = X; +impl Preadjointable for IdOp { + type PreadjointCodomain = X::OwnedSpace; type Preadjoint<'a> - = IdOp + = IdOp where X: 'a; @@ -297,7 +304,7 @@ where F: Num, X: VectorSpace + HasDual, - X::DualSpace: VectorSpace, + X::DualSpace: ClosedVectorSpace, { type AdjointCodomain = X::DualSpace; type Adjoint<'b> @@ -460,9 +467,9 @@ X: HasDual, Y: HasDual, F: Float, - Xprime: VectorSpace, - Xprime::Owned: AXPY, - Yprime: Space + Instance, + Xprime: ClosedVectorSpace, + //Xprime::Owned: AXPY, + Yprime: ClosedSpace, OY: OriginGenerator, OXprime: OriginGenerator, { @@ -540,7 +547,7 @@ S: Mapping, T: Mapping, S::Codomain: Add, - >::Output: Space, + >::Output: ClosedSpace, { type Codomain = >::Output; @@ -556,7 +563,7 @@ S: Linear, T: Linear, S::Codomain: Add, - >::Output: Space, + >::Output: ClosedSpace, { } @@ -693,7 +700,7 @@ A: Space, Xʹ: Space, Yʹ: Space, - R: Space + ClosedAdd, + R: ClosedSpace + ClosedAdd, S: Adjointable, T: Adjointable, Self: Linear, @@ -718,7 +725,7 @@ A: Space, Xʹ: Space, Yʹ: Space, - R: Space + ClosedAdd, + R: ClosedSpace + ClosedAdd, S: Preadjointable, T: Preadjointable, Self: Linear, @@ -802,7 +809,7 @@ B: Space, Xʹ: Space, Yʹ: Space, - R: Space, + R: ClosedSpace, S: Adjointable, T: Adjointable, Self: Linear>, @@ -825,7 +832,7 @@ B: Space, Xʹ: Space, Yʹ: Space, - R: Space, + R: ClosedSpace, S: Preadjointable, T: Preadjointable, Self: Linear>, @@ -856,7 +863,7 @@ S: BoundedLinear, T: BoundedLinear, S::Codomain: Add, - >::Output: Space, + >::Output: ClosedSpace, ExpA: NormExponent, ExpB: NormExponent, ExpR: NormExponent, @@ -912,7 +919,8 @@ impl Mapping for Scaled where F: Float, - Domain: Space + ClosedMul, + Domain: Space + Mul, + >::Output: ClosedSpace, { type Codomain = >::Output; @@ -925,6 +933,7 @@ impl Linear for Scaled where F: Float, - Domain: Space + ClosedMul, + Domain: Space + Mul, + >::Output: ClosedSpace, { }