diff -r b4a47e8e80d1 -r fd9dba51afd3 src/linops.rs --- a/src/linops.rs Wed Sep 03 09:52:30 2025 -0500 +++ b/src/linops.rs Wed Sep 03 10:08:28 2025 -0500 @@ -28,35 +28,39 @@ /// Vector spaces #[replace_float_literals(Self::Field::cast_from(literal))] pub trait VectorSpace: - Space - + Mul - + Div - + Add - + Add - + Sub - + Sub + Space + + Mul + + Div + + Add + + Add + + Sub + + Sub + Neg - + for<'b> Add<&'b Self, Output = ::Owned> - + for<'b> Sub<&'b Self, Output = ::Owned> + + for<'b> Add<&'b Self, Output = ::PrincipalV> + + for<'b> Sub<&'b Self, Output = ::PrincipalV> { + /// Underlying scalar field type Field: Num; - type Owned: ClosedSpace + + /// Principal form of the space; always equal to [`Space::Principal`], but with + /// more traits guaranteed. + type PrincipalV: ClosedSpace + AXPY< Self, Field = Self::Field, - Owned = Self::Owned, - OwnedVariant = Self::Owned, - OwnedSpace = Self::Owned, + PrincipalV = Self::PrincipalV, + OwnedVariant = Self::PrincipalV, + Principal = Self::PrincipalV, >; /// Return a similar zero as `self`. - fn similar_origin(&self) -> Self::Owned; + fn similar_origin(&self) -> Self::PrincipalV; // { // self.make_origin_generator().make_origin() // } /// Return a similar zero as `x`. - fn similar_origin_inst>(x: I) -> Self::Owned { + fn similar_origin_inst>(x: I) -> Self::PrincipalV { x.eval(|xr| xr.similar_origin()) } } @@ -68,9 +72,9 @@ + MulAssign + DivAssign + AddAssign - + AddAssign + + AddAssign + SubAssign - + SubAssign + + SubAssign + for<'b> AddAssign<&'b Self> + for<'b> SubAssign<&'b Self> where @@ -93,8 +97,8 @@ fn set_zero(&mut self); } -pub trait ClosedVectorSpace: Instance + VectorSpace {} -impl + VectorSpace> ClosedVectorSpace for X {} +pub trait ClosedVectorSpace: Instance + VectorSpace {} +impl + VectorSpace> ClosedVectorSpace for X {} /// Efficient in-place application for [`Linear`] operators. #[replace_float_literals(F::cast_from(literal))] @@ -197,7 +201,7 @@ } impl Mapping for IdOp { - type Codomain = X::OwnedSpace; + type Codomain = X::Principal; fn apply>(&self, x: I) -> Self::Codomain { x.into_owned() @@ -233,10 +237,10 @@ } } -impl Adjointable for IdOp { - type AdjointCodomain = X::OwnedSpace; +impl Adjointable for IdOp { + type AdjointCodomain = X::Principal; type Adjoint<'a> - = IdOp + = IdOp where X: 'a; @@ -245,10 +249,10 @@ } } -impl Preadjointable for IdOp { - type PreadjointCodomain = X::OwnedSpace; +impl Preadjointable for IdOp { + type PreadjointCodomain = X::Principal; type Preadjoint<'a> - = IdOp + = IdOp where X: 'a; @@ -262,9 +266,9 @@ pub struct SimpleZeroOp; impl Mapping for SimpleZeroOp { - type Codomain = X::Owned; + type Codomain = X::PrincipalV; - fn apply>(&self, x: I) -> X::Owned { + fn apply>(&self, x: I) -> X::PrincipalV { X::similar_origin_inst(x) } } @@ -323,7 +327,7 @@ where Self: 'b; - fn origin(&self) -> Y::Owned; + fn origin(&self) -> Y::PrincipalV; fn as_ref(&self) -> Self::Ref<'_>; } @@ -334,7 +338,7 @@ Self: 'b; #[inline] - fn origin(&self) -> Y::Owned { + fn origin(&self) -> Y::PrincipalV { return self.similar_origin(); } @@ -351,7 +355,7 @@ Self: 'c; #[inline] - fn origin(&self) -> Y::Owned { + fn origin(&self) -> Y::PrincipalV { return self.similar_origin(); } @@ -392,8 +396,8 @@ X: HasDual, Y: HasDual, F: Float, - Xprime: VectorSpace, - Xprime::Owned: AXPY, + Xprime: VectorSpace, + Xprime::PrincipalV: AXPY, Yprime: Space + Instance, { pub fn new_dualisable(y_og: OY, xprime_og: OXprime) -> Self { @@ -412,9 +416,9 @@ F: Float, OY: OriginGenerator, { - type Codomain = Y::Owned; + type Codomain = Y::PrincipalV; - fn apply>(&self, _x: I) -> Y::Owned { + fn apply>(&self, _x: I) -> Y::PrincipalV { self.codomain_origin_generator.origin() } } @@ -432,7 +436,7 @@ impl GEMV for ZeroOp where X: Space, - Y: AXPY, + Y: AXPY, F: Float, OY: OriginGenerator, { @@ -450,7 +454,7 @@ where X: Space + Instance + Norm, Y: VectorSpace, - Y::Owned: Clone, + Y::PrincipalV: Clone, F: Float, E1: NormExponent, E2: NormExponent, @@ -920,10 +924,10 @@ where F: Float, Domain: Space, - Domain::OwnedSpace: Mul, - >::Output: ClosedSpace, + Domain::Principal: Mul, + >::Output: ClosedSpace, { - type Codomain = >::Output; + type Codomain = >::Output; /// Compute the value of `self` at `x`. fn apply>(&self, x: I) -> Self::Codomain { @@ -935,7 +939,7 @@ where F: Float, Domain: Space, - Domain::OwnedSpace: Mul, - >::Output: ClosedSpace, + Domain::Principal: Mul, + >::Output: ClosedSpace, { }