diff -r e98e1da2530d -r e7f1cb4bec78 src/linops.rs --- a/src/linops.rs Mon Apr 28 23:16:56 2025 -0500 +++ b/src/linops.rs Tue Apr 29 00:03:12 2025 -0500 @@ -10,6 +10,7 @@ use numeric_literals::replace_float_literals; use serde::Serialize; use std::marker::PhantomData; +use std::ops::Mul; /// Trait for linear operators on `X`. pub trait Linear: Mapping {} @@ -728,3 +729,28 @@ pairnorm!(L1); pairnorm!(L2); pairnorm!(Linfinity); + +/// The simplest linear mapping, scaling by a scalar. +/// +/// TODO: redefined/replace [`Weighted`] by composition with [`Scaled`]. +pub struct Scaled(pub F); + +impl Mapping for Scaled +where + F: Float, + Domain: Space + ClosedMul, +{ + type Codomain = >::Output; + + /// Compute the value of `self` at `x`. + fn apply>(&self, x: I) -> Self::Codomain { + x.own() * self.0 + } +} + +impl Linear for Scaled +where + F: Float, + Domain: Space + ClosedMul, +{ +}